mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 09:46:25 +00:00
Improved cleanup (close #58)
This commit is contained in:
@@ -228,8 +228,10 @@ class WorkerThread(QtCore.QThread):
|
||||
continue
|
||||
if not self.conversionAlive:
|
||||
for item in outputPath:
|
||||
os.remove(item)
|
||||
os.remove(item.replace('.epub', '.mobi'))
|
||||
if os.path.exists(item):
|
||||
os.remove(item)
|
||||
if os.path.exists(item.replace('.epub', '.mobi')):
|
||||
os.remove(item.replace('.epub', '.mobi'))
|
||||
self.clean()
|
||||
return
|
||||
if self.kindlegenErrorCode == 0:
|
||||
@@ -532,8 +534,15 @@ class Ui_KCC(object):
|
||||
def hideProgressBar(self):
|
||||
GUI.ProgressBar.hide()
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def saveSettings(self, event):
|
||||
if self.conversionAlive:
|
||||
GUI.ConvertButton.setEnabled(False)
|
||||
self.addMessage('Process will be interrupted. Please wait.', 'warning')
|
||||
self.conversionAlive = False
|
||||
self.worker.sync()
|
||||
event.ignore()
|
||||
if not GUI.ConvertButton.isEnabled():
|
||||
event.ignore()
|
||||
self.settings.setValue('lastPath', self.lastPath)
|
||||
self.settings.setValue('lastDevice', GUI.DeviceBox.currentIndex())
|
||||
self.settings.setValue('currentFormat', GUI.FormatBox.currentIndex())
|
||||
|
||||
@@ -364,7 +364,7 @@ def dirImgProcess(path):
|
||||
pass
|
||||
if not GUI.conversionAlive:
|
||||
pool.terminate()
|
||||
rmtree(path)
|
||||
rmtree(os.path.join(path, '..', '..'))
|
||||
raise UserWarning("Conversion interrupted.")
|
||||
GUI.emit(QtCore.SIGNAL("progressBarTick"))
|
||||
pool.join()
|
||||
@@ -372,7 +372,7 @@ def dirImgProcess(path):
|
||||
try:
|
||||
splitpages = splitpages.get()
|
||||
except:
|
||||
rmtree(path)
|
||||
rmtree(os.path.join(path, '..', '..'))
|
||||
raise RuntimeError("One of workers crashed. Cause: " + str(sys.exc_info()[1]))
|
||||
splitpages = filter(None, splitpages)
|
||||
splitpages.sort()
|
||||
@@ -382,7 +382,7 @@ def dirImgProcess(path):
|
||||
pagenumbermodifier += 1
|
||||
pagenumbermodifier += 1
|
||||
else:
|
||||
rmtree(path)
|
||||
rmtree(os.path.join(path, '..', '..'))
|
||||
raise UserWarning("Source directory is empty.")
|
||||
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ def main(argv=None, qtGUI=None):
|
||||
try:
|
||||
workers.get()
|
||||
except:
|
||||
rmtree(options.targetDir)
|
||||
rmtree(options.targetDir, True)
|
||||
raise RuntimeError("One of workers crashed. Cause: " + str(sys.exc_info()[1]))
|
||||
if GUI:
|
||||
GUI.emit(QtCore.SIGNAL("progressBarTick"), 1)
|
||||
|
||||
Reference in New Issue
Block a user