import os import glob import olx import olex import time from olexFunctions import OlexFunctions OV = OlexFunctions() from ImageTools import ImageTools IT = ImageTools() import olex_core import OlexVFS print "Hello" def db_test(): pass # from sqlalchemy import create_engine # engine = create_engine('sqlite:///:memory:', echo=True)# def t(cmd): d = {} d.setdefault('make_bitmap_image',"$spy.MakeHoverButton(button_small-go@bitmapp,cursor\(busy,'Please Wait. Making image. This may take some time')>>run 'pict -pq strcat\(GetValue\(IMAGE_BITMAP_NAME).,GetValue\(IMAGE_BITMAP_TYPE)) GetValue\(IMAGE_BITMAP_SIZE)'>>cursor\()") html = '%s>>html.hide test)' %d[cmd] x = int(olx.GetMouseX()) y = int(olx.GetMouseY()) name = 'test' boxWidth = 200 boxHeight = 200 pop_name = "Test" wFilePath = r"%s.htm" %(name) OV.write_to_olex(wFilePath, html) olx.Popup(pop_name, wFilePath, "-b=tc -t='%s' -w=%i -h=%i -x=%i -y=%i" %(name, boxWidth, boxHeight, x, y)) print 'Hello' OV.registerFunction(t) def bulk_copy_files (mask="hklres", path_from=r"Z:", path_to=r"C:\DS\Data",overwrite=True,lowercase=True): import FileSystem as FS print "Hello" path_from = OV.standardizePath(path_from) path_to = OV.standardizePath(path_to) folders = [] p1 = os.listdir(path_from) for item in p1: folders.append(OV.standardizePath("%s/%s" %(path_from, item))) try: p2 = os.listdir("%s/%s" %(path_from, item)) for tem in p2: folders.append(OV.standardizePath("%s/%s/%s" %(path_from, item, tem))) except: continue #for item in items: ##folders.append(OV.standardizePath(item.path._str)) #path = item.path._str #if os.path.isdir(path): #folders.append(item.path._str) ##itemPath = '/'.join([path_from,item]) ##if os.path.isdir(itemPath): ##folders.append(OV.standardizePath(itemPath)) masks = [] if "*" in mask: masks.append(mask) else: if "hkl" in mask: masks.append("*.hkl") if "ins" in mask: masks.append("*.ins") if "res" in mask: masks.append("*.res") if "lst" in mask: masks.append("*.lst") for folder in folders: print repr(folder) for mask in masks: g = glob.glob("%s/%s" %(folder,mask)) new_folder = folder.replace(path_from,path_to) for file in g: if not os.path.exists(new_folder): os.makedirs(new_folder) try: FS.Node("%s" %file.lower()).copy_file((file.replace(path_from,path_to)),overwrite=overwrite) except: pass OV.registerFunction(bulk_copy_files) class HealthOfStructure(): def __init__(self): self.hkl_stats = {} phil_file = "%s\etc\CIF\diagnostics.phil" %(OV.BaseDir()) olx.phil_handler.adopt_phil(phil_file=phil_file) def run_HealthOfStructure(self): self.hkl_stats = olex_core.GetHklStat() self.make_HOS_html() def make_HOS_html(self): txt = "
%s: %s | '''%(bg_colour, 100/len(l), display, value) txt += "