diff options
| -rw-r--r-- | module/plugins/hooks/AntiVirus.py | 30 | ||||
| -rw-r--r-- | module/plugins/hooks/ExtractArchive.py | 29 | ||||
| -rw-r--r-- | module/plugins/hooks/XFileSharingPro.py | 4 | 
3 files changed, 27 insertions, 36 deletions
| diff --git a/module/plugins/hooks/AntiVirus.py b/module/plugins/hooks/AntiVirus.py index 27e3801b5..ac9373a37 100644 --- a/module/plugins/hooks/AntiVirus.py +++ b/module/plugins/hooks/AntiVirus.py @@ -4,6 +4,11 @@ import os  import shutil  import subprocess +try: +    import send2trash +except ImportError: +    pass +  from module.plugins.Hook import Hook, Expose, threaded  from module.utils import fs_encode, save_join @@ -11,7 +16,7 @@ from module.utils import fs_encode, save_join  class AntiVirus(Hook):      __name__    = "AntiVirus"      __type__    = "hook" -    __version__ = "0.07" +    __version__ = "0.08"      #@TODO: add trash option (use Send2Trash lib)      __config__ = [("action"    , "Antivirus default;Delete;Quarantine", "Manage infected files"                     , "Antivirus default"), @@ -33,16 +38,6 @@ class AntiVirus(Hook):      def setup(self):          self.info = {}  #@TODO: Remove in 0.4.10 -        try: -            import send2trash - -        except ImportError: -            self.logDebug("Send2Trash lib not found") -            self.trashable = False - -        else: -            self.trashable = True -      @Expose      @threaded @@ -81,13 +76,14 @@ class AntiVirus(Hook):                          if not self.getConfig('deltotrash'):                              os.remove(file) -                        elif self.trashable: -                            send2trash.send2trash(file) -                          else: -                            self.logWarning(_("Unable to move file to trash, move to quarantine instead")) -                            pyfile.setCustomStatus(_("file moving")) -                            shutil.move(file, self.getConfig('quardir')) +                            try: +                                send2trash.send2trash(file) + +                            except Exception: +                                self.logWarning(_("Unable to move file to trash, move to quarantine instead")) +                                pyfile.setCustomStatus(_("file moving")) +                                shutil.move(file, self.getConfig('quardir'))                      elif action == "Quarantine":                          pyfile.setCustomStatus(_("file moving")) diff --git a/module/plugins/hooks/ExtractArchive.py b/module/plugins/hooks/ExtractArchive.py index d40b52aa7..05a1e368a 100644 --- a/module/plugins/hooks/ExtractArchive.py +++ b/module/plugins/hooks/ExtractArchive.py @@ -6,8 +6,6 @@ import os  import sys  import traceback -from copy import copy -  # monkey patch bug in python 2.6 and lower  # http://bugs.python.org/issue6122 , http://bugs.python.org/issue1236 , http://bugs.python.org/issue1731717  if sys.version_info < (2, 7) and os.name != "nt": @@ -45,6 +43,12 @@ if sys.version_info < (2, 7) and os.name != "nt":      subprocess.Popen.wait = wait +try: +    import send2trash +except ImportError: +    pass + +from copy import copy  if os.name != "nt":      from grp import getgrnam      from pwd import getpwnam @@ -106,7 +110,7 @@ class ArchiveQueue(object):  class ExtractArchive(Hook):      __name__    = "ExtractArchive"      __type__    = "hook" -    __version__ = "1.41" +    __version__ = "1.42"      __config__ = [("activated"      , "bool"              , "Activated"                                 , True                                                                     ),                    ("fullpath"       , "bool"              , "Extract with full paths"                   , True                                                                     ), @@ -150,16 +154,6 @@ class ExtractArchive(Hook):          self.passwords   = []          self.repair      = False -        try: -            import send2trash - -        except ImportError: -            self.logDebug("Send2Trash lib not found") -            self.trashable = False - -        else: -            self.trashable = True -      def coreReady(self):          for p in ("UnRar", "SevenZip", "UnZip"): @@ -474,11 +468,12 @@ class ExtractArchive(Hook):                      if not deltotrash:                          os.remove(file) -                    elif self.trashable: -                        send2trash.send2trash(file) -                      else: -                        self.logWarning(_("Unable to move %s to trash") % os.path.basename(f)) +                        try: +                            send2trash.send2trash(file) + +                        except Exception: +                            self.logWarning(_("Unable to move %s to trash") % os.path.basename(f))              self.logInfo(name, _("Extracting finished"))              extracted_files = archive.files or archive.list() diff --git a/module/plugins/hooks/XFileSharingPro.py b/module/plugins/hooks/XFileSharingPro.py index 3205596fa..d80515a22 100644 --- a/module/plugins/hooks/XFileSharingPro.py +++ b/module/plugins/hooks/XFileSharingPro.py @@ -32,11 +32,11 @@ class XFileSharingPro(Hook):      HOSTER_BUILTIN  = [#WORKING HOSTERS:                         "backin.net", "eyesfile.ca", "file4safe.com", "fileband.com", "filedwon.com", "fileparadox.in",                         "filevice.com", "hostingbulk.com", "junkyvideo.com", "linestorage.com", "ravishare.com", "ryushare.com", -                       "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "worldbytez.com", "xvidstage.com", +                       "salefiles.com", "sendmyway.com", "sharesix.com", "thefile.me", "verzend.be", "xvidstage.com",                         #NOT TESTED:                         "101shared.com", "4upfiles.com", "filemaze.ws", "filenuke.com", "linkzhost.com", "mightyupload.com",                         "rockdizfile.com", "sharebeast.com", "sharerepo.com", "shareswift.com", "uploadbaz.com", "uploadc.com", -                       "vidbull.com", "zalaa.com", "zomgupload.com", +                       "vidbull.com", "worldbytez.com", "zalaa.com", "zomgupload.com",                         #NOT WORKING:                         "amonshare.com", "banicrazy.info", "boosterking.com", "host4desi.com", "laoupload.com", "rd-fs.com"]      CRYPTER_BUILTIN = ["junocloud.me", "rapidfileshare.net"] | 
