Permalink
Browse files

Call the save function after each download/upload.

  • Loading branch information...
1 parent 38c87cf commit 6bf3df5983595fad37a33e406e3f35a6089813d4 @jrhames jrhames committed Apr 25, 2010
Showing with 3 additions and 3 deletions.
  1. +2 −0 Pyrrot2.py
  2. +1 −3 Pyrrot2Service.py
View
@@ -122,6 +122,7 @@ def download_subtitles(rootdir, languages):
logger.info("download subtitle " + file)
elif result == 404:
logger.debug("subtitle not found " + file)
+ save()
time.sleep(random.uniform(1,5))
#search for subtitles to upload
@@ -147,6 +148,7 @@ def upload_subtitles(rootdir):
logger.warning("unsupported media type or the file is bigger than 200k " + file)
else:
logger.error("cannot upload subtitle " + file + "\nresult: " + result)
+ save()
time.sleep(random.uniform(1,10))
def save():
View
@@ -41,14 +41,13 @@ def SvcDoRun(self):
self.timeout = 10000
self.can_run = True
self.retries = 0
-
+
while 1:
# Wait for service stop signal, if I timeout, loop again
rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout)
# Check to see if self.hWaitStop happened
if rc == win32event.WAIT_OBJECT_0:
# Stop signal encountered
- Pyrrot2.save()
servicemanager.LogInfoMsg("Pyrrot2 - STOPPED")
break
else:
@@ -57,7 +56,6 @@ def SvcDoRun(self):
for folder in Pyrrot2.DIRECTORIES:
Pyrrot2.download_subtitles(folder, Pyrrot2.LANGUAGES)
Pyrrot2.upload_subtitles(folder)
- Pyrrot2.save()
self.can_run = False
elif self.retries == 180:
self.can_run = True

0 comments on commit 6bf3df5

Please sign in to comment.