mirror of
https://github.com/Kilian/Trimage.git
synced 2026-01-26 10:08:40 -05:00
more peb8-ing
This commit is contained in:
parent
318e2afa8a
commit
17fae20713
1 changed files with 7 additions and 4 deletions
11
trimage.py
11
trimage.py
|
|
@ -231,6 +231,7 @@ class TriTableModel(QAbstractTableModel):
|
||||||
|
|
||||||
|
|
||||||
class Worker(QThread):
|
class Worker(QThread):
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QThread.__init__(self, parent)
|
QThread.__init__(self, parent)
|
||||||
self.exiting = False
|
self.exiting = False
|
||||||
|
|
@ -264,13 +265,14 @@ class Worker(QThread):
|
||||||
if extention in ['.jpg', '.jpeg']:
|
if extention in ['.jpg', '.jpeg']:
|
||||||
runString = 'jpegoptim -f --strip-all "%(file)s"'
|
runString = 'jpegoptim -f --strip-all "%(file)s"'
|
||||||
elif extention in ['.png']:
|
elif extention in ['.png']:
|
||||||
runString = 'optipng -force -o7 "%(file)s"; advpng -z4 "%(file)s"'
|
runString = '''optipng -force -o7 "%(file)s";
|
||||||
|
advpng -z4 "%(file)s"'''
|
||||||
else:
|
else:
|
||||||
raise Exception('File %s does not have the appropriate'
|
raise Exception('File %s does not have the appropriate'
|
||||||
'extention' % filename)
|
'extention' % filename)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
retcode = call(runString % {'file' : filename}, shell=True,
|
retcode = call(runString % {'file': filename}, shell=True,
|
||||||
stdout=PIPE)
|
stdout=PIPE)
|
||||||
runfile = retcode
|
runfile = retcode
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
|
|
@ -291,7 +293,8 @@ class Worker(QThread):
|
||||||
if image[4] == filename:
|
if image[4] == filename:
|
||||||
imagelist.remove(image)
|
imagelist.remove(image)
|
||||||
imagelist.insert(i, (name, oldfilesizestr,
|
imagelist.insert(i, (name, oldfilesizestr,
|
||||||
newfilesizestr,ratiostr, filename, icon))
|
newfilesizestr, ratiostr,
|
||||||
|
filename, icon))
|
||||||
|
|
||||||
self.emit(SIGNAL("updateUi"))
|
self.emit(SIGNAL("updateUi"))
|
||||||
|
|
||||||
|
|
@ -302,7 +305,7 @@ class Worker(QThread):
|
||||||
ratiostr)
|
ratiostr)
|
||||||
else:
|
else:
|
||||||
# TODO nice error recovery
|
# TODO nice error recovery
|
||||||
raise Exception('Some error occurred!')
|
raise Exception('[error] %s' % runfile)
|
||||||
|
|
||||||
if not showapp:
|
if not showapp:
|
||||||
quit()
|
quit()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue