def setPosition(cmd=None, position=None): count = doScript(scriptcount) # print count if int(count) > 3: doScript(scriptquit) for n in xrange(1, int(count) + 1): # print "n:%s"%(n) title = doScript(scriptname % ('get', str(object=n))) for key in positionKey: # print "key:%s"%(key) if title.lower().find(key.lower()) >= 0: print "find:", title, key, positionKey[key] position = doScript(script_set_position % ('set', str(n), positionKey[key])) # print doScript(script_get_position % ('get', str(n))) # position = doScript(scriptposition % ('get', str(n))) # print positio else: if os.path.exists(cct.get_ramdisk_path('tdx_last_df')): f_size = os.path.getsize( cct.get_ramdisk_path('tdx_last_df')) / 1000 / 1000 else: f_size = 0 if f_size > 2: print "run Cmd" os.system(cmdRun) else: print "run Cmd200" os.system(cmdRun200) setPosition(cmd=None, position=None) os.system(closeLaunch) # getPosition('Johnson@',close=True) # getPosition('/Users/Johnson/Documents',close=True) print getPosition('Johnson — bash', close=True) # print getPosition('Johnson',close=True) # print getPosition('Johnson — bash',close=True) # print getPosition('Johnson — bash',close=True) # print getPosition('Johnson',close=True) print getPosition('Johnson — python', close=True)
def __init__(self, *args, **kwargs): self.probe_interval = kwargs.pop("probe_interval", 2) lock = cct.get_ramdisk_path(args[0], lock=True) baseDir = BaseDir self.fname_o = args[0] self.basedir = baseDir self.config_ini = baseDir + os.path.sep + 'h5config.txt' if args[0] == cct.tdx_hd5_name or args[0].find('tdx_all_df') >= 0: self.fname = cct.get_run_path_tdx(args[0]) self.basedir = self.fname.split(self.fname_o)[0] log.info("tdx_hd5:%s" % (self.fname)) else: self.fname = cct.get_ramdisk_path(args[0]) self.basedir = self.fname.split(self.fname_o)[0] log.info("ramdisk_hd5:%s" % (self.fname)) self._lock = lock self.countlock = 0 self.write_status = False self.complevel = 9 self.complib = 'zlib' # self.ptrepack_cmds = "ptrepack --chunkshape=auto --propindexes --complevel=9 --complib=%s %s %s" self.ptrepack_cmds = "ptrepack --overwrite-nodes --chunkshape=auto --complevel=9 --complib=%s %s %s" self.big_H5_Size_limit = ct.big_H5_Size_limit self.h5_size_org = 0 # self.pt_lock_file = self.fname + '.txt' global RAMDISK_KEY if not os.path.exists(baseDir): if RAMDISK_KEY < 1: log.error("NO RamDisk Root:%s" % (baseDir)) RAMDISK_KEY += 1 else: self.temp_file = self.fname + '_tmp' self.write_status = True if os.path.exists(self.fname): self.h5_size_org = os.path.getsize(self.fname) / 1000 / 1000 self.run(self.fname)
def get_hdf5_file(fpath, wr_mode='r', complevel=9, complib='blosc', mutiindx=False): """[summary] [old api out date] Parameters ---------- fpath : {[type]} [description] wr_mode : {str}, optional [description] (the default is 'r', which [default_description]) complevel : {number}, optional [description] (the default is 9, which [default_description]) complib : {str}, optional [description] (the default is 'blosc', which [default_description]) mutiindx : {bool}, optional [description] (the default is False, which [default_description]) Returns ------- [type] [description] """ # store=pd.HDFStore(fpath,wr_mode, complevel=complevel, complib=complib) fpath = cct.get_ramdisk_path(fpath) if fpath is None: log.info("don't exists %s" % (fpath)) return None if os.path.exists(fpath): if wr_mode == 'w': # store=pd.HDFStore(fpath,complevel=None, complib=None, fletcher32=False) store = pd.HDFStore(fpath) else: lock = cct.get_ramdisk_path(fpath, lock=True) while True: try: # lock_s = os.open(lock, os.O_CREAT |os.O_EXCL |os.O_WRONLY) lock_s = os.open(lock, os.O_CREAT | os.O_EXCL) log.info("SafeHDF:%s read lock:%s" % (lock_s, lock)) break # except FileExistsError: # except FileExistsError as e: except (IOError, EOFError, Exception) as e: # time.sleep(probe_interval) log.error("IOError READ ERROR:%s" % (e)) time.sleep(random.random()) store = pd.HDFStore(fpath, mode=wr_mode) # store=pd.HDFStore(fpath, mode=wr_mode, complevel=None, complib=None, fletcher32=False) os.remove(lock) # store = SafeHDFStore(fpath) else: if mutiindx: store = pd.HDFStore(fpath) # store = pd.HDFStore(fpath,complevel=9,complib='zlib') else: return None # store = pd.HDFStore(fpath, mode=wr_mode,complevel=9,complib='zlib') # store.put("Year2015", dfMinutes, format="table", append=True, data_columns=['dt','code']) return store