def convert_sql_to_xml(filename, id):
    config = {'host': 'vistrails.sci.utah.edu', 
              'port': 3306,
              'user': '******',
              'passwd': '8edLj4',
              'db': 'vistrails'}
    try:
        db_connection = io.open_db_connection(config)        
        vistrail = io.open_vistrail_from_db(db_connection, id)
        io.save_vistrail_to_xml(vistrail, filename)
        io.close_db_connection(db_connection)
    except MySQLdb.Error, e:
        print e
예제 #2
0
def convert_sql_to_xml(filename, id):
    config = {'host': 'localhost', 
              'port': 3306,
              'user': '******',
              'passwd': 'vistrailspwd',
              'db': 'vistrails'}
    try:
        dbConnection = io.open_db_connection(config)        
        vistrail = io.open_vistrail_from_db(dbConnection, id)
        io.setDBParameters(vistrail, config)
        io.save_vistrail_to_xml(vistrail, filename)
        io.close_db_connection(dbConnection)
    except MySQLdb.Error, e:
        print e
예제 #3
0
def convert_sql_to_xml(filename, id):
    config = {'host': 'localhost', 
              'port': 3306,
              'user': '******',
              'passwd': 'vistrailspwd',
              'db': 'vistrails'}
    try:
        dbConnection = io.open_db_connection(config)        
        vistrail = io.open_vistrail_from_db(dbConnection, id)
        io.setDBParameters(vistrail, config)
        io.save_vistrail_to_xml(vistrail, filename)
        io.close_db_connection(dbConnection)
    except MySQLdb.Error, e:
        print e
예제 #4
0
def convert_sql_to_xml(filename, id):
    config = {
        'host': 'vistrails.sci.utah.edu',
        'port': 3306,
        'user': '******',
        'passwd': '8edLj4',
        'db': 'vistrails'
    }
    try:
        db_connection = io.open_db_connection(config)
        vistrail = io.open_vistrail_from_db(db_connection, id)
        io.save_vistrail_to_xml(vistrail, filename)
        io.close_db_connection(db_connection)
    except MySQLdb.Error, e:
        print e
예제 #5
0
def new_save_vistrail_to_zip_xml(vistrail, filename):
    # Dumb hack to figure out if we are autosaving 
    if filename.find('vt_autosaves') > 0:
        getBuilderWindow().startProgress('Autosaving...')
    else:
        getBuilderWindow().startProgress('Saving...')

    # Write the vistrail file to disk
    (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')
    if os.path.exists(vt_fname):
        os.remove(vt_fname)
    os.rename(xmlfname, vt_fname)
    zip_fnames = [vt_fname, ]

    #Audio Dir
    ###################################################
    zip_audio_folder = []
    audio_dir = vistrail.db_audio_dir
    zip_audio_folder.append(audio_dir)
    ###################################################
    #Video Dir
    ###################################################
    zip_video_folder = []
    video_dir = vistrail.db_video_dir
    zip_video_folder.append(video_dir)
    ###################################################

    getBuilderWindow().updateProgress(0.2)

    # Save binary data
    (bin_file, bin_filename) = tempfile.mkstemp(suffix='.bin')
    os.close(bin_file)
    bfile = open(bin_filename, "wb")
    vistrail.binary_data.tofile(bfile)
    bfile.close()
    bin_fname = os.path.join(os.path.dirname(bin_filename), 'data')
    if os.path.exists(bin_fname):
        os.remove(bin_fname)
    os.rename(bin_filename, bin_fname)
    zip_fnames.append(bin_fname)
    
    getBuilderWindow().updateProgress(0.5)

    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')
        if os.path.exists(log_fname):
            os.remove(log_fname)
        os.rename(log_filename, log_fname)
        zip_fnames.append(log_fname)

    try:
        zf = zipfile.ZipFile(file=filename,mode='w',
                             allowZip64=True)
        # Add standard vistrails files
        for f in zip_fnames:
            zf.write(f,os.path.basename(f),zipfile.ZIP_DEFLATED)

        if zip_audio_folder[0] != None:
            if os.path.isdir(zip_audio_folder[0]) == True:
                for d in zip_audio_folder:
                    addFolderToZipFile(zf, d, "audio")
        
        if zip_video_folder[0] != None:
            if os.path.isdir(zip_video_folder[0]) == True:
                for v in zip_video_folder:
                    addFolderToZipFile(zf, v, "video")
                    

        getBuilderWindow().updateProgress(0.75)
        # Add saved files. Append indicator of file type because it needed
        # when extracting the zip on Windows
        for (f,b) in vistrail.saved_files:
            basename = os.path.join("vt_saves",os.path.basename(f))
            if b:
                basename += ".b"        
            else:
                basename += ".a"
            zf.write(f, basename, zipfile.ZIP_DEFLATED)
        zf.close()
        
        currentFolder = []
        
    except Exception, e:
        # Allow autosaves to fail silently
        if filename.find('vt_autosaves') <0:
            raise Exception('Error writing file!\nThe file may be invalid or you\nmay have insufficient permissions.')