def batch_export(): from Experiment import config dss = __DATASOURCE__.getSelectedDatasets() if dss is None or len(dss) == 0: print 'Please select one or more files to export.' return path = selectSaveFolder() if path == None: return fi = File(path) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + path return eid = int(experiment_id.value) exp_folder = path + '/exp' + str(eid) fi = File(exp_folder) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + exp_folder return ILL_folder = exp_folder + '/ILLfiles' exp_folder += '/Datafiles' fi = File(exp_folder) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + exp_folder return fi = File(ILL_folder) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + ILL_folder return count = 0 for dinfo in dss: loc = dinfo.getLocation() f = File(loc) fsn = f.getName() # count = int(fsn[3:10]) # new_fname = 'TAIPAN_exp' + ('%(value)04d' % {'value':eid}) + '_scan' + ('%(value)04d' % {'value':count}) + '.dat' df.datasets.clear() try: export.graffiti_export(df, loc, exp_folder, eid, get_prof_value) except: traceback.print_exc() traceback.print_exc(file = __buffer_logger__) df.datasets.clear() try: export.ILL_export(df, loc, ILL_folder, eid, get_prof_value) except: traceback.print_exc() traceback.print_exc(file = __buffer_logger__) # export.graffiti_export(df, loc, exp_folder, eid, get_prof_value) # df.datasets.clear() # export.ILL_export(df, loc, ILL_folder, eid, get_prof_value) print 'done'
def __export__(fn): if fn.__contains__('/'): items = fn.split('/') fn = items[-1] input_path = __data_folder__ + '/' + fn exp_id = get_prof_value('taipan.experiment.id') exp_folder = __export_folder__ + '/exp' + exp_id fi = File(exp_folder) if not fi.exists(): if not fi.mkdirs(): print 'Error: failed to make directory: ' + exp_folder return ILL_folder = exp_folder + '/ILLfiles' exp_folder += '/Datafiles' fi = File(exp_folder) if not fi.exists(): if not fi.mkdirs(): print 'Error: failed to make directory: ' + exp_folder return fi = File(ILL_folder) if not fi.exists(): if not fi.mkdirs(): print 'Error: failed to make directory: ' + ILL_folder return # df.datasets.clear() # export.graffiti_export(df, input_path, exp_folder, int(exp_id), get_prof_value) # df.datasets.clear() # export.ILL_export(df, input_path, ILL_folder, int(exp_id), get_prof_value) df.datasets.clear() try: export.graffiti_export(df, input_path, exp_folder, int(exp_id), get_prof_value) except: try: export.graffiti_export(df, input_path, exp_folder, int(exp_id), get_prof_value) except: traceback.print_exc() traceback.print_exc(file = __buffer_logger__) df.datasets.clear() try: export.ILL_export(df, input_path, ILL_folder, int(exp_id), get_prof_value) except: try: export.ILL_export(df, input_path, ILL_folder, int(exp_id), get_prof_value) except: traceback.print_exc() traceback.print_exc(file = __buffer_logger__)
def batch_export(): from Experiment import config dss = __get_selected_files__() if dss is None or len(dss) == 0: print 'Please select one or more files to export.' return path = selectSaveFolder() if path == None: return fi = File(path) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + path return eid = int(experiment_id.value) exp_folder = path + '/exp' + str(eid) fi = File(exp_folder) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + exp_folder return ILL_folder = exp_folder + '/ILLfiles' exp_folder += '/Datafiles' fi = File(exp_folder) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + exp_folder return fi = File(ILL_folder) if not fi.exists(): if not fi.mkdir(): print 'Error: failed to make directory: ' + ILL_folder return count = 0 flist = [] for loc in dss: f = File(loc) fsn = f.getName() # count = int(fsn[3:10]) # new_fname = 'TAIPAN_exp' + ('%(value)04d' % {'value':eid}) + '_scan' + ('%(value)04d' % {'value':count}) + '.dat' df.datasets.clear() fn = export.graffiti_export(df, loc, exp_folder, eid, get_pref_value) flist.append(fn) df.datasets.clear() fn = export.ILL_export(df, loc, ILL_folder, eid, get_pref_value) flist.append(fn) if len(flist) > 0: zip_files(flist, 'TAIPAN_rd_' + str(int(time.time()))[2:] + '.zip') print 'done'