Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_item_finished(err, mission):
if not err:
missions.popleft()
mission_manager.add("view", mission)
download_ch.pub("BATCH_ANALYZE_UPDATE", list(missions))
try:
crawl(mission, savepath)
# Check if mission is complete
for ep in mission.episodes:
if not ep.complete and not ep.skip:
raise Exception("Mission is not completed")
except WorkerExit:
mission.state = "PAUSE"
download_ch.pub('DOWNLOAD_PAUSE', mission)
raise
except PauseDownloadError as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_INVALID', (err, mission))
except Exception as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_ERROR', (err, mission))
raise
else:
mission.state = "FINISHED"
download_ch.pub("DOWNLOAD_FINISHED", mission)
for ep in mission.episodes:
if not ep.complete and not ep.skip:
raise Exception("Mission is not completed")
except WorkerExit:
mission.state = "PAUSE"
download_ch.pub('DOWNLOAD_PAUSE', mission)
raise
except PauseDownloadError as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_INVALID', (err, mission))
except Exception as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_ERROR', (err, mission))
raise
else:
mission.state = "FINISHED"
download_ch.pub("DOWNLOAD_FINISHED", mission)
def analyze(mission):
"""Analyze mission."""
try:
Analyzer(mission).analyze()
except WorkerExit:
raise
except Exception as err: # pylint: disable=broad-except
traceback.print_exc()
download_ch.pub("ANALYZE_FAILED", (err, mission))
except PauseDownloadError as err:
download_ch.pub("ANALYZE_INVALID", (err, mission))
else:
download_ch.pub("ANALYZE_FINISHED", mission)
# warning there is a deadlock,
# never do mission.lock.acquire in callback...
print("Start downloading " + mission.title)
mission.state = "DOWNLOADING"
try:
crawl(mission, savepath)
# Check if mission is complete
for ep in mission.episodes:
if not ep.complete and not ep.skip:
raise Exception("Mission is not completed")
except WorkerExit:
mission.state = "PAUSE"
download_ch.pub('DOWNLOAD_PAUSE', mission)
raise
except PauseDownloadError as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_INVALID', (err, mission))
except Exception as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_ERROR', (err, mission))
raise
else:
mission.state = "FINISHED"
download_ch.pub("DOWNLOAD_FINISHED", mission)
# warning there is a deadlock,
# never do mission.lock.acquire in callback...
print("Start downloading " + mission.title)
mission.state = "DOWNLOADING"
try:
crawl(mission, savepath)
# Check if mission is complete
for ep in mission.episodes:
if not ep.complete and not ep.skip:
raise Exception("Mission is not completed")
except WorkerExit:
mission.state = "PAUSE"
download_ch.pub('DOWNLOAD_PAUSE', mission)
raise
except PauseDownloadError as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_INVALID', (err, mission))
except Exception as err:
mission.state = "ERROR"
download_ch.pub('DOWNLOAD_ERROR', (err, mission))
raise
else:
mission.state = "FINISHED"
download_ch.pub("DOWNLOAD_FINISHED", mission)
"""Analyze mission."""
try:
Analyzer(mission).analyze()
except WorkerExit:
raise
except Exception as err: # pylint: disable=broad-except
traceback.print_exc()
download_ch.pub("ANALYZE_FAILED", (err, mission))
except PauseDownloadError as err:
download_ch.pub("ANALYZE_INVALID", (err, mission))
else:
download_ch.pub("ANALYZE_FINISHED", mission)