def zip_job(job_ini, archive_zip='', risk_ini='', oq=None, log=logging.info):
    """
    Zip the given job.ini file into the given archive, together with all
    related files.
    """
    if not os.path.exists(job_ini):
        sys.exit('%s does not exist' % job_ini)
    archive_zip = archive_zip or 'job.zip'
    if isinstance(archive_zip, str):  # actually it should be path-like
        if not archive_zip.endswith('.zip'):
            sys.exit('%s does not end with .zip' % archive_zip)
        if os.path.exists(archive_zip):
            sys.exit('%s exists already' % archive_zip)
    # do not validate to avoid permissions error on the export_dir
    oq = oq or readinput.get_oqparam(job_ini, validate=False)
    if risk_ini:
        risk_ini = os.path.normpath(os.path.abspath(risk_ini))
        risk_inputs = readinput.get_params([risk_ini])['inputs']
        del risk_inputs['job_ini']
        oq.inputs.update(risk_inputs)
    files = readinput.get_input_files(oq)
    if risk_ini:
        files = [risk_ini] + files
    return general.zipfiles(files, archive_zip, log=log)
def zip_job ( job_ini , archive_zip = '' , risk_ini = '' , oq = None , log = logging . info ) : if not os . path . exists ( job_ini ) : sys . exit ( '%s does not exist' % job_ini ) archive_zip = archive_zip or 'job.zip' if isinstance ( archive_zip , str ) : if not archive_zip . endswith ( '.zip' ) : sys . exit ( '%s does not end with .zip' % archive_zip ) if os . path . exists ( archive_zip ) : sys . exit ( '%s exists already' % archive_zip ) oq = oq or readinput . get_oqparam ( job_ini , validate = False ) if risk_ini : risk_ini = os . path . normpath ( os . path . abspath ( risk_ini ) ) risk_inputs = readinput . get_params ( [ risk_ini ] ) [ 'inputs' ] del risk_inputs [ 'job_ini' ] oq . inputs . update ( risk_inputs ) files = readinput . get_input_files ( oq ) if risk_ini : files = [ risk_ini ] + files return general . zipfiles ( files , archive_zip , log = log )
Zip the given job.ini file into the given archive, together with all
    related files.