X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=cis%2Fcis.py;h=e63b7292abdde3850f502e0fb1cca49ad2ffd70f;hb=141bdb84bf143c29a6c50eef3aee18541d2fc0e4;hp=3ae47cf36329bbd7104ebb8f4f361e8f4af21714;hpb=080b37a97e93691b3ba1c4aa3982a143167115a7;p=living-lab-site.git diff --git a/cis/cis.py b/cis/cis.py index 3ae47cf..e63b729 100755 --- a/cis/cis.py +++ b/cis/cis.py @@ -113,13 +113,18 @@ class CIWorker(threading.Thread): # Create torrent file. bt.create_torrent(transcode_config['output_file']) - # The torrent file is created in the same directory with the - # source file. Move it to the torrents directory. - shutil.move(transcode_config['output_file'] + '.tstream', \ - config.TORRENTS_PATH) - output_file = transcode_config['output_file'] + '.tstream' output_file = output_file[(output_file.rindex('/') + 1):] + + # The torrent file is created in the same directory with the + # source file. Move it to the torrents directory. + #if not os.path.exists( + # os.path.join(output_file, config.TORRENTS_PATH)): + try: + shutil.move(transcode_config['output_file'] + '.tstream', \ + config.TORRENTS_PATH) + except: + pass # * SEED TORRENTS Server.bit_torrent.start_torrent( \ @@ -151,11 +156,16 @@ class CIWorker(threading.Thread): for f in files: os.unlink(os.path.join(path, f)) - def notify_completion(self): + def notify_completion(self, code): logger.log_msg('#%s: notifying web server about the job completion...'\ % self.job_id) - f = urllib.urlopen(config.WS_COMPLETION) + if config.WS_COMPLETION[len(config.WS_COMPLETION) - 1] == '/': + url = config.WS_COMPLETION + code + else: + url = config.WS_COMPLETION + '/' + code + + f = urllib.urlopen(url) f.read() def run(self): @@ -232,7 +242,7 @@ class CIWorker(threading.Thread): # * NOTIFY WEB SERVER ABOUT CONTENT INGESTION COMPLETION # TODO in the future web server should also be notified about errors try: - self.notify_completion() + self.notify_completion(job['code']) except Exception as e: logger.log_msg( '#%s: error while notifying web server about the job completion: %s' \ @@ -246,6 +256,8 @@ class CIWorker(threading.Thread): # * JOB FINISHED Server.queue.task_done() Server.load -= job['weight'] + logger.log_msg('#%s: finished' \ + % job['code'], logger.LOG_LEVEL_INFO) class Server: