コード例 #1
0
ファイル: io.py プロジェクト: gzt200361/ThirdParty-2.0.0
def save_vistrail_to_zip_xml(vistrail, filename):
    """save_vistrail_to_zip_xml(vistrail: Vistrail, filename:str)-> None
    Generate a zip compressed version of vistrail.
    It raise an Exception if there was an error
    
    """

    (file_, xmlfname) = tempfile.mkstemp(suffix='.xml')

    os.close(file_)
    save_vistrail_to_xml(vistrail,xmlfname)
    vt_fname = os.path.join(os.path.dirname(xmlfname), 'vistrail')
    os.rename(xmlfname, vt_fname)
    zip_fnames = [vt_fname, ]

    if vistrail.log is not None and len(vistrail.log.workflow_execs) > 0:
        if vistrail.log_filename is None:
            (log_file, log_filename) = tempfile.mkstemp(suffix='.xml')
            os.close(log_file)
            log_file = open(log_filename, "wb")
        else:
            log_filename = vistrail.log_filename
            log_file = open(log_filename, 'ab')

        print "+++ ", log_filename
        print "*** ", log_file
        if not hasattr(log_file, "write"):
            print "no!!!"
        
        # append log to log_file
        for workflow_exec in vistrail.log.workflow_execs:
            daoList = getVersionDAO(currentVersion)
            daoList.save_to_xml(workflow_exec, log_file, {}, currentVersion)
        log_file.close()

        log_fname = os.path.join(os.path.dirname(log_filename), 'log')
        os.rename(log_filename, log_fname)
        zip_fnames.append(log_fname)

#     name_in_archive = os.path.join(os.path.dirname(xmlfname),'vistrail')
#     os.rename(xmlfname,name_in_archive)

    core.requirements.require_executable('zip')
    output = []
    cmdline = ['zip', '-r', '-j', '-q', filename] + zip_fnames
    result = execute_cmdline(cmdline,output)
    
    #print result, output
    for fname in zip_fnames:
        os.unlink(fname)
    if result != 0 and len(output) != 0:
        for line in output:
            if line.find('deflated') == -1:
                raise Exception(" ".join(output))

    return vistrail
コード例 #2
0
ファイル: __init__.py プロジェクト: CDAT/VisTrails
def uvcdat_vistrails_branch():
    git_dir = os.path.join(vistrails_root_directory(), '..')
    with Chdir(git_dir):
        release = ""
        if core.requirements.executable_file_exists('git'):
            lines = []
            result = execute_cmdline(['git', 'rev-parse', '--abbrev-ref', 'HEAD' ],
                                     lines)
            if len(lines) == 1:
                if result == 0:
                    release = lines[0].strip()
    return release
コード例 #3
0
ファイル: __init__.py プロジェクト: painter1/vistrails
def uvcdat_vistrails_branch():
    git_dir = os.path.join(vistrails_root_directory(), '..')
    with Chdir(git_dir):
        release = "update_before_release"
        if core.requirements.executable_file_exists('git'):
            lines = []
            result = execute_cmdline(['git', 'rev-parse', '--abbrev-ref', 'HEAD' ],
                                     lines)
            if len(lines) == 1:
                if result == 0:
                    release = lines[0].strip()
    return release
コード例 #4
0
ファイル: io.py プロジェクト: gzt200361/ThirdParty-2.0.0
def unzip_file(filename, name_in_archive):
    # name_in_archive = 'vistrail'
    (file_, xmlfname) = tempfile.mkstemp(suffix='.xml')
    core.requirements.require_executable('unzip')
    os.close(file_)
    output = []
    cmdline = ['unzip', '-p', filename, name_in_archive, '>', xmlfname]
    result = execute_cmdline(cmdline,output)

    # print result, output    
    if result == 0 or len(output) == 0:
        return xmlfname
    return None
コード例 #5
0
ファイル: __init__.py プロジェクト: CDAT/VisTrails
def uvcdat_revision():
    """uvcdat_revision() -> str 
    When run on a working copy, shows the current git hash else
    shows the latest release revision

    """
    git_dir = os.path.join(vistrails_root_directory(), '..')
    with Chdir(git_dir):
        release = ""
        if core.requirements.executable_file_exists('git'):
            lines = []
            result = execute_cmdline(['git', 'describe', '--tags', ],
                                     lines)
            if len(lines) == 1:
                if result == 0:
                    release = lines[0].strip()
    return release
コード例 #6
0
ファイル: __init__.py プロジェクト: imclab/vistrails
def uvcdat_revision():
    """uvcdat_revision() -> str 
    When run on a working copy, shows the current git hash else
    shows the latest release revision

    """
    git_dir = os.path.join(vistrails_root_directory(), '..')
    with Chdir(git_dir):
        release = "<update_before_release>"
        if core.requirements.executable_file_exists('git'):
            lines = []
            result = execute_cmdline(['git', 'describe', '--always', '--abbrev=12'],
                                     lines)
            if len(lines) == 1:
                if result == 0:
                    release = lines[0].strip(" \n")
    return release