check for CPS renamer complete. + comments

Can we still use logger while logfile open?

We might want to review those two log entries... or add logging to the autoPorcess* scripts.
This commit is contained in:
Clinton Hall 2013-02-25 23:19:11 -08:00
commit 08a05ef748

View file

@ -393,6 +393,7 @@ for dirpath, dirnames, filenames in os.walk(outputDestination):
Logger.info("file %s is a sample file. Removing", filePath) Logger.info("file %s is a sample file. Removing", filePath)
os.unlink(filePath) #remove samples os.unlink(filePath) #remove samples
else: else:
videofile = filePath
video2 = video2 + 1 video2 = video2 + 1
if video2 >= video and video2 > 0: # Check that all video files were moved if video2 >= video and video2 > 0: # Check that all video files were moved
status = 0 status = 0
@ -408,12 +409,6 @@ elif failed_extract == 1 and failed_link == 0: #failed to extract files only.
else: else:
Logger.info("MAIN: Something failed! Please check logs. Exiting") Logger.info("MAIN: Something failed! Please check logs. Exiting")
sys.exit(-1) sys.exit(-1)
# Now we pass off to CouchPotato or Sick-Beard
# Log this output
old_stdout = sys.stdout # Still crude, but we wat to capture this for now
logFile = os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log")
log_file = open(logFile,"a+")
sys.stdout = log_file
# Hardlink solution with uTorrent # Hardlink solution with uTorrent
if inputHash and useLink: if inputHash and useLink:
@ -421,16 +416,32 @@ if inputHash and useLink:
utorrentClass.stop(inputHash) utorrentClass.stop(inputHash)
time.sleep(5) # Give uTorrent some time to catch up with the change time.sleep(5) # Give uTorrent some time to catch up with the change
# Log this output
old_stdout = sys.stdout # Still crude, but we wat to capture this for now
logFile = os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log")
log_file = open(logFile,"a+")
sys.stdout = log_file
# Now we pass off to CouchPotato or Sick-Beard
if inputCategory == movieCategory: if inputCategory == movieCategory:
Logger.info("MAIN: Calling postprocessing script for CouchPotatoServer") Logger.info("MAIN: Calling postprocessing script for CouchPotatoServer") ###can we use logger while logfile open?
autoProcessMovie.process(outputDestination, inputName, status) autoProcessMovie.process(outputDestination, inputName, status)
elif inputCategory == tvCategory: elif inputCategory == tvCategory:
Logger.info("MAIN: Calling postprocessing script for Sick-Beard") Logger.info("MAIN: Calling postprocessing script for Sick-Beard") ###can we use logger while logfile open?
autoProcessTV.processEpisode(outputDestination, inputName, status) autoProcessTV.processEpisode(outputDestination, inputName, status)
sys.stdout = old_stdout
log_file.close()
now = datetime.datetime.now() #set time for timeout
while os.path.exists(videofile): #while this file is still here, CPS hasn't finished renaming
if (datetime.datetime.now() - now) > datetime.timedelta(minutes=3): #note; minimum 1 minute delay in autoProcessMovie
Logger.info("MAIN: The file %s has not been moved after 3 minutes.")
break
else: #CPS (and SickBeard) have finished. We can now resume seeding.
Logger.info("MAIN: The file %s has been moved. Postprocessing appears to have succeeded." %videofile)
# Hardlink solution with uTorrent # Hardlink solution with uTorrent
if inputHash and useLink: if inputHash and useLink:
Logger.debug("MAIN: We are using hardlinks with uTorrent, calling uTorrent to resume download") Logger.debug("MAIN: We are using hardlinks with uTorrent, calling uTorrent to resume download")
utorrentClass.start(inputHash) utorrentClass.start(inputHash)
sys.stdout = old_stdout
log_file.close()