summaryrefslogtreecommitdiffstats
path: root/module/plugins/hooks/MergeFiles.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/hooks/MergeFiles.py')
-rw-r--r--module/plugins/hooks/MergeFiles.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/module/plugins/hooks/MergeFiles.py b/module/plugins/hooks/MergeFiles.py
index 02d343096..060dae7a2 100644
--- a/module/plugins/hooks/MergeFiles.py
+++ b/module/plugins/hooks/MergeFiles.py
@@ -19,7 +19,6 @@
import os
import re
-import sys
import traceback
from os.path import join
@@ -28,13 +27,12 @@ from module.plugins.Hook import Hook
BUFFER_SIZE = 4096
+
class MergeFiles(Hook):
__name__ = "MergeFiles"
- __version__ = "0.1"
+ __version__ = "0.11"
__description__ = "Merges parts splitted with hjsplit"
- __config__ = [
- ("activated" , "bool" , "Activated" , "False"),
- ]
+ __config__ = [("activated", "bool", "Activated", "False")]
__threaded__ = ["packageFinished"]
__author_name__ = ("and9000")
__author_mail__ = ("me@has-no-mail.com")
@@ -42,7 +40,7 @@ class MergeFiles(Hook):
def setup(self):
# nothing to do
pass
-
+
def packageFinished(self, pack):
files = {}
fid_dict = {}
@@ -53,18 +51,18 @@ class MergeFiles(Hook):
files[data["name"][:-4]].append(data["name"])
files[data["name"][:-4]].sort()
fid_dict[data["name"]] = fid
-
+
download_folder = self.core.config['general']['download_folder']
-
+
if self.core.config['general']['folder_per_package']:
download_folder = save_join(download_folder, pack.folder)
for name, file_list in files.iteritems():
- self.core.log.info("Starting merging of %s" % name)
+ self.logInfo("Starting merging of %s" % name)
final_file = open(join(download_folder, fs_encode(name)), "wb")
for splitted_file in file_list:
- self.core.log.debug("Merging part %s" % splitted_file)
+ self.logDebug("Merging part %s" % splitted_file)
pyfile = self.core.files.getFile(fid_dict[splitted_file])
pyfile.setStatus("processing")
try:
@@ -76,19 +74,17 @@ class MergeFiles(Hook):
if f_buffer:
final_file.write(f_buffer)
size_written += BUFFER_SIZE
- pyfile.setProgress((size_written*100)/s_file_size)
+ pyfile.setProgress((size_written * 100) / s_file_size)
else:
break
s_file.close()
- self.core.log.debug("Finished merging part %s" % splitted_file)
+ self.logDebug("Finished merging part %s" % splitted_file)
except Exception, e:
print traceback.print_exc()
finally:
pyfile.setProgress(100)
pyfile.setStatus("finished")
pyfile.release()
-
- final_file.close()
- self.core.log.info("Finished merging of %s" % name)
-
+ final_file.close()
+ self.logInfo("Finished merging of %s" % name)