def _filename_log(output_filename, nofpass=1): """ Constructs the filename including path for the encoding err file @param output_filename: name of the video file to be created @type output_filename: string @param nofpass: number of encoding passes @type nofpass: int @return: the constructed log filename @rtype: string """ fname = os.path.split(output_filename)[1] fname = os.path.splitext(fname)[0] return CFG_BIBENCODE_FFMPEG_ENCODING_LOG % (generate_timestamp() + "_" + fname + "_%d" % nofpass)
def _filename_log(output_filename, nofpass=1): """ Constructs the filename including path for the encoding err file @param output_filename: name of the video file to be created @type output_filename: string @param nofpass: number of encoding passes @type nofpass: int @return: the constructed log filename @rtype: string """ fname = os.path.split(output_filename)[1] fname = os.path.splitext(fname)[0] return CFG_BIBENCODE_FFMPEG_ENCODING_LOG % (generate_timestamp() + "_" + fname + "_%d" % nofpass)
def create_update_jobs_by_recids(recids, batch_template_file, job_directory=CFG_BIBENCODE_DAEMON_DIR_NEWJOBS): """ Creates the job description files to update all given recids @param recids: Iterable set of recids @type recids: iterable @param batch_template_file: fullpath to the template for the update @type batch_tempalte_file: string @param job_directory: fullpath to the directory storing the job files @type job_directory: string """ batch_template = json_decode_file(batch_template_file) for recid in recids: task_update_progress("Creating Update Job for %d" % recid) write_message("Creating Update Job for %d" % recid) job = dict(batch_template) job["recid"] = recid timestamp = generate_timestamp() job_filename = "update_%d_%s.job" % (recid, timestamp) create_job_from_dictionary(job, job_filename, job_directory) return 1
def create_update_jobs_by_recids(recids, batch_template_file, job_directory=CFG_BIBENCODE_DAEMON_DIR_NEWJOBS ): """ Creates the job description files to update all given recids @param recids: Iterable set of recids @type recids: iterable @param batch_template_file: fullpath to the template for the update @type batch_tempalte_file: string @param job_directory: fullpath to the directory storing the job files @type job_directory: string """ batch_template = json_decode_file(batch_template_file) for recid in recids: task_update_progress("Creating Update Job for %d" % recid) write_message("Creating Update Job for %d" % recid) job = dict(batch_template) job['recid'] = recid timestamp = generate_timestamp() job_filename = "update_%d_%s.job" % (recid, timestamp) create_job_from_dictionary(job, job_filename, job_directory) return 1
def Video_Processing(parameters, curdir, form, user_info=None): """ Perform all the required processing of the video. Parameters are: * "batch_template": to specify the absolute path to a configuration describe which manipulation should the uploaded file receive. If empty, will use by default etc/bibencode/batch_template_submission.json * "aspect": to specify in which form element the aspect will be available * "title": to specify in which form element the title will be available """ ## Read the batch template for submissions if parameters.get("batch_template"): try: batch_template = json_decode_file(parameters.get("batch_template")) except: register_exception(prefix="The given batch template was not readable") raise else: batch_template = json_decode_file(CFG_BIBENCODE_TEMPLATE_BATCH_SUBMISSION) ## Handle the filepath file_storing_path = os.path.join(curdir, "files", str(user_info["uid"]), "NewFile", "filepath") try: fp = open(file_storing_path) fullpath = fp.read() fp.close() batch_template["input"] = fullpath except: register_exception(prefix="The file containing the path to the video was not readable") raise ## Handle the filename file_storing_name = os.path.join(curdir, "files", str(user_info["uid"]), "NewFile", "filename") try: fp = open(file_storing_name) filename = fp.read() fp.close() batch_template["bibdoc_master_docname"] = os.path.splitext(os.path.split(filename)[1])[0] batch_template["bibdoc_master_extension"] = os.path.splitext(filename)[1] batch_template["submission_filename"] = filename except: register_exception(prefix="The file containing the original filename of the video was not readable") raise ## Handle the aspect ratio if parameters.get("aspect"): try: file_storing_aspect = os.path.join(curdir, parameters.get("aspect")) fp = open(file_storing_aspect) aspect = fp.read() fp.close() batch_template["aspect"] = aspect except: register_exception(prefix="The file containing the ascpect ratio of the video was not readable") raise else: batch_template["aspect"] = None ## Handle the title if parameters.get("title"): try: file_storing_title = os.path.join(curdir, parameters["title"]) fp = open(file_storing_title) title = fp.read() fp.close() except: register_exception(prefix="The file containing the title of the video was not readable") raise else: batch_template["submission_title"] = None ## Set the rest batch_template["notify_admin"] = CFG_SITE_ADMIN_EMAIL batch_template["notify_user"] = user_info["email"] batch_template["recid"] = sysno timestamp = generate_timestamp() job_filename = "submission_%d_%s.job" % (sysno, timestamp) create_job_from_dictionary(batch_template, job_filename)
from invenio.utils.json import json_decode_file from invenio.modules.encoder.utils import generate_timestamp, getval from invenio.legacy.bibsched.bibtask import ( task_low_level_submission, task_get_task_param, write_message, task_update_progress ) from invenio.modules.encoder.config import ( CFG_BIBENCODE_DAEMON_DIR_NEWJOBS, CFG_BIBENCODE_DAEMON_DIR_OLDJOBS ) ## Globals used to generate a unique task name _TASKID = None _TIMESTAMP = generate_timestamp() _NUMBER = 0 def has_signature(string_to_check): """ Checks if the given string has the signature of a job file """ sig_re = re.compile("^.*\.job$") if sig_re.match(string_to_check): return True else: return False def job_to_args(job): """ Maps the key-value pairs of the job file to CLI arguments for a low-level task submission @param job: job dictionary to process
def Video_Processing(parameters, curdir, form, user_info=None): """ Perform all the required processing of the video. Parameters are: * "batch_template": to specify the absolute path to a configuration describe which manipulation should the uploaded file receive. If empty, will use by default etc/bibencode/batch_template_submission.json * "aspect": to specify in which form element the aspect will be available * "title": to specify in which form element the title will be available """ ## Read the batch template for submissions if parameters.get('batch_template'): try: batch_template = json_decode_file(parameters.get('batch_template')) except: register_exception(prefix="The given batch template was not readable") raise else: batch_template = json_decode_file(CFG_BIBENCODE_TEMPLATE_BATCH_SUBMISSION) ## Handle the filepath file_storing_path = os.path.join(curdir, "files", str(user_info['uid']), "NewFile", 'filepath') try: fp = open(file_storing_path) fullpath = fp.read() fp.close() batch_template['input'] = fullpath except: register_exception(prefix="The file containing the path to the video was not readable") raise ## Handle the filename file_storing_name = os.path.join(curdir, "files", str(user_info['uid']), "NewFile", 'filename') try: fp = open(file_storing_name) filename = fp.read() fp.close() batch_template['bibdoc_master_docname'] = os.path.splitext(os.path.split(filename)[1])[0] batch_template['bibdoc_master_extension'] = os.path.splitext(filename)[1] batch_template['submission_filename'] = filename except: register_exception(prefix="The file containing the original filename of the video was not readable") raise ## Handle the aspect ratio if parameters.get('aspect'): try: file_storing_aspect = os.path.join(curdir, parameters.get('aspect')) fp = open(file_storing_aspect) aspect = fp.read() fp.close() batch_template['aspect'] = aspect except: register_exception(prefix="The file containing the ascpect ratio of the video was not readable") raise else: batch_template['aspect'] = None ## Handle the title if parameters.get('title'): try: file_storing_title = os.path.join(curdir, parameters['title']) fp = open(file_storing_title) title = fp.read() fp.close() except: register_exception(prefix="The file containing the title of the video was not readable") raise else: batch_template['submission_title'] = None ## Set the rest batch_template['notify_admin'] = CFG_SITE_ADMIN_EMAIL batch_template['notify_user'] = user_info['email'] batch_template['recid'] = sysno timestamp = generate_timestamp() job_filename = "submission_%d_%s.job" % (sysno, timestamp) create_job_from_dictionary(batch_template, job_filename)
from invenio.utils.json import json_decode_file from invenio.modules.encoder.utils import generate_timestamp, getval from invenio.legacy.bibsched.bibtask import ( task_low_level_submission, task_get_task_param, write_message, task_update_progress ) from invenio.modules.encoder.config import ( CFG_BIBENCODE_DAEMON_DIR_NEWJOBS, CFG_BIBENCODE_DAEMON_DIR_OLDJOBS ) # Globals used to generate a unique task name _TASKID = None _TIMESTAMP = generate_timestamp() _NUMBER = 0 def has_signature(string_to_check): """ Checks if the given string has the signature of a job file """ sig_re = re.compile("^.*\.job$") if sig_re.match(string_to_check): return True else: return False def job_to_args(job): """ Maps the key-value pairs of the job file to CLI arguments for a low-level task submission @param job: job dictionary to process