From 7b8a3da53f3780859c67b06293586440840260ba Mon Sep 17 00:00:00 2001 From: Leonardo Date: Tue, 15 Jun 2010 14:38:19 +0200 Subject: [PATCH] Aggiornato l'esempio --- example_script.py | 8 +++++--- mlmanager.py | 6 +++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/example_script.py b/example_script.py index 6ed72e1..77a7453 100755 --- a/example_script.py +++ b/example_script.py @@ -14,6 +14,8 @@ import mlmanager # Adjust some internal variables, for example add a text estension; # You can also append to # video_extensions, audio_extensions, cdimage_extensions and archive_extensions +# You can view the default values opening a python shell, improting mlmanager +# and printing mlmanager.****_extensions mlmanager.text_extensions.append ("djvu") # Change mail addr of the daemon and domain of the server. @@ -56,12 +58,12 @@ mail_text += "Duration of the download: %s.\n\n" % duration recipients = [ "user1@provider.com", "user2@anotherprovider.org" , "owner" ] # Move download to the right place -if download.get_type() == "video": +if download.get_type() is "video": download.move("/shared/Films") mail_text += "The file has been recognized as a film so it has been copied\n" mail_text += "in /shared/Films.\n" -elif download.get_type() == "audio": +elif download.get_type() is "audio": download.move("/shared/Musica") mail_text += "The file has been recognized as music so it has been copied\n" mail_text += "in /shared/Music.\n" @@ -83,7 +85,7 @@ if download.is_in_group("remote"): recipients.remove("user2@anotherprovider.org") # Script signature -mail_text += "\nmldonkey \n" +mail_text += "\n--\nmldonkey \n" # Notify users by mail download.notify_email(recipients, diff --git a/mlmanager.py b/mlmanager.py index 8bdb785..84cb704 100644 --- a/mlmanager.py +++ b/mlmanager.py @@ -286,11 +286,15 @@ class Download(): if not self._committed: self.commit () + errors = "" + # Initialize internal counter of the times we have tried to move the file self._rsync_counter = 0 s = subprocess.Popen("rsync --partial -az --compress-level=9 \"%s\" \"%s\"" % (self._dest_path, remote_destination), shell = True, stderr = subprocess.PIPE, stdout = subprocess.PIPE) + + errors += "\n" + s.communicate ()[1] ret_code = s.wait () # If we fail call this funtion recursively to retry...wait for 60 seconds and then go (it could @@ -301,7 +305,7 @@ class Download(): time.sleep (60) self.rsync(remote_destination) else: - self._notify_error("Rsync transfer of file %s failed more than 5 times, aborting" % self._filename) + self._notify_error("Rsync transfer of file %s failed more than 5 times, aborting\n\n%s" % (self._filename, errors)) def _notify_error(self, message): """Notify error via email""" -- 2.1.4