more peb8-ing

This commit is contained in:
Kilian Valkhof 2010-02-05 22:56:16 +01:00
parent 318e2afa8a
commit 17fae20713

View file

@ -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()