Ejemplo n.º 1
0
def process_job(job):
    log_msg("Picked up job: %s" % job['ID'])
    log_debug("details:%s" % job.get_body())
    template_mappings = {}

    try:
        # Pull down the asset and assign template variables
        asset_name = job["ASSET_URL"].split('/')[-1]

        filename = "%s/%s" % (tmp_dir, asset_name)
        basename = "%s/%s" % (tmp_dir, asset_name.split('.')[0])
        template_mappings["filename"] = filename
        template_mappings["basename"] = basename

        # "wget" asset_url to $filename
        asset = open(filename, "wb")
        asset.write( wget.open(job["ASSET_URL"]).read() )
        asset.close()
    
        # Take ownership for job
        job.update( { "STATUS": "PROCESSING" } )
        log_msg("Picked up asset: %s" % asset_name)
    except Exception, e:
        log_err("Caught exception taking job: %s" % e)
Ejemplo n.º 2
0
        # "wget" asset_url to $filename
        asset = open(filename, "wb")
        asset.write( wget.open(job["ASSET_URL"]).read() )
        asset.close()
    
        # Take ownership for job
        job.update( { "STATUS": "PROCESSING" } )
        log_msg("Picked up asset: %s" % asset_name)
    except Exception, e:
        log_err("Caught exception taking job: %s" % e)
 
    try: 
        # Attempt to match suffix with job sections
        asset_suffix = "%s" % asset_name.split('.')[-1] 
        log_debug("Suffix: %s" % asset_suffix)
        suffixes = job_processes.keys() 
        suffix_check = re.compile( asset_suffix, re.IGNORECASE)
        matched_suffix = [ suffix for suffix in suffixes if re.search(suffix_check, suffix) ]
        if matched_suffix:
            log_debug("Matched suffix '%s'" % matched_suffix)
        else:
            log_err("Could not match any job configs to files with suffix '%s'" % suffix)
    except Exception, e:
        log_err("Caught exception matching execs to suffix" % e)
 
    try: 
        # Perform commands on asset
        exec_list = job_processes[matched_suffix[0]]
        for command_template in exec_list:
            log_debug("Command template [ %s ]" % command_template)