Skip to content

Commit

Permalink
VarietyWindow: migrate to (non-deprecated) shlex.quote()
Browse files Browse the repository at this point in the history
Also remove explicit cast to str from build_imagemagick_filter_cmd(); this shouldn't be needed anymore
  • Loading branch information
jlu5 committed Sep 21, 2018
1 parent a6eaec2 commit 48adbd5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions variety/VarietyWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import re
import urllib.parse
import webbrowser
import pipes
import shlex
from PIL import Image as PILImage

random.seed()
Expand Down Expand Up @@ -299,7 +299,7 @@ def _generate_pencil_tile():
try:
os.system(
"convert -size 1000x1000 xc: +noise Random -virtual-pixel tile "
"-motion-blur 0x20+135 -charcoal 2 -resize 50%% %s" % pipes.quote(pencil_tile_filename))
"-motion-blur 0x20+135 -charcoal 2 -resize 50%% %s" % shlex.quote(pencil_tile_filename))
except Exception:
logger.exception(lambda: "Could not generate pencil_tile.png")
threading.Timer(0, _generate_pencil_tile).start()
Expand Down Expand Up @@ -1105,14 +1105,14 @@ def build_imagemagick_filter_cmd(self, filename, target_file):

w = Gdk.Screen.get_default().get_width()
h = Gdk.Screen.get_default().get_height()
cmd = 'convert %s -scale %dx%d^ ' % (pipes.quote(filename), w, h)
cmd = 'convert %s -scale %dx%d^ ' % (shlex.quote(filename), w, h)

logger.info(lambda: "Applying filter: " + filter)
cmd += filter + ' '

cmd += pipes.quote(target_file)
cmd = cmd.replace("%FILEPATH%", pipes.quote(filename))
cmd = cmd.replace("%FILENAME%", pipes.quote(os.path.basename(filename)))
cmd += shlex.quote(target_file)
cmd = cmd.replace("%FILEPATH%", shlex.quote(filename))
cmd = cmd.replace("%FILENAME%", shlex.quote(os.path.basename(filename)))

logger.info(lambda: "ImageMagick filter cmd: " + cmd)
return cmd.encode('utf-8')
Expand All @@ -1123,7 +1123,7 @@ def build_imagemagick_clock_cmd(self, filename, target_file):

w = Gdk.Screen.get_default().get_width()
h = Gdk.Screen.get_default().get_height()
cmd = 'convert %s -scale %dx%d^ ' % (pipes.quote(filename), w, h)
cmd = 'convert %s -scale %dx%d^ ' % (shlex.quote(filename), w, h)

hoffset, voffset = Util.compute_trimmed_offsets(Util.get_size(filename), (w, h))
clock_filter = self.options.clock_filter
Expand All @@ -1135,7 +1135,7 @@ def build_imagemagick_clock_cmd(self, filename, target_file):

cmd += clock_filter
cmd += ' '
cmd += pipes.quote(str(target_file))
cmd += shlex.quote(target_file)
logger.info(lambda: "ImageMagick clock cmd: " + cmd)
return cmd.encode('utf-8')

Expand Down

0 comments on commit 48adbd5

Please sign in to comment.