Esempio n. 1
0
 def __exit__(self, *args, **kwargs):
     if self.write_status:
         HDFStore.__exit__(self, *args, **kwargs)
         os.close(self._flock)
         h5_size = os.path.getsize(self.fname) / 1000 / 1000
         new_limit = ((h5_size / self.big_H5_Size_limit + 1) *
                      self.big_H5_Size_limit)
         # global Compress_Count
         # if Compress_Count == 1 and self.h5_size_org > self.big_H5_Size_limit:
         #                cct.get_config_value(self.config_ini,self.fname_o,h5_size,new_limit)
         # log.info("Compress_Count init:%s h5_size_org:%s" % (Compress_Count, self.h5_size_org))
         log.info("fname:%s h5_size:%s big:%s" %
                  (self.fname, h5_size, self.big_H5_Size_limit))
         # if  h5_size >= self.big_H5_Size_limit:
         if cct.get_config_value(self.config_ini, self.fname_o, h5_size,
                                 new_limit):
             time_pt = time.time()
             if os.path.exists(self.fname) and os.path.exists(
                     self.temp_file):
                 log.error("remove tmpfile is exists:%s" % (self.temp_file))
                 os.remove(self.temp_file)
             os.rename(self.fname, self.temp_file)
             if cct.get_os_system() == 'mac':
                 p = subprocess.Popen(
                     self.ptrepack_cmds %
                     (self.complib, self.temp_file, self.fname),
                     shell=True,
                     stdout=subprocess.PIPE,
                     stderr=subprocess.STDOUT)
             else:
                 back_path = os.getcwd()
                 os.chdir(self.basedir)
                 log.info('current path is: %s after change dir' %
                          os.getcwd())
                 pt_cmd = self.ptrepack_cmds % (
                     self.complib, self.temp_file.split(self.basedir)[1],
                     self.fname.split(self.basedir)[1])
                 p = subprocess.Popen(pt_cmd,
                                      shell=True,
                                      stdout=subprocess.PIPE,
                                      stderr=subprocess.STDOUT)
                 os.chdir(back_path)
             p.wait()
             # ptrepack --chunkshape=auto --complevel=9 --complib=zlib tdx_all_df_300.h5_tmp tdx_all_df_300.h5
             if p.returncode != 0:
                 # log.error("ptrepack hdf Error:%s for tmp_file:%s Er:%s" % (self.fname,self.temp_file,p.stderr))
                 log.error("ptrepack hdf Error:%s  tofile:%s Er:%s" %
                           (self.temp_file, self.fname,
                            p.stdout.read().decode("gbk")))
                 # return -1
             else:
                 if os.path.exists(self.temp_file):
                     os.remove(self.temp_file)
                 # log.error("fname:%s h5_size:%sM Limit:%s t:%.1f" % (self.fname, h5_size, new_limit , time_pt - time.time()))
         if os.path.exists(self._lock):
             os.remove(self._lock)
Esempio n. 2
0
    # print get_linear_model_status('600671', filter='y', start='20160329', ptype='high')
    # print get_linear_model_status('999999', filter='y', dl=30, ptype='high')
    # print get_linear_model_status('999999', filter='y', dl=30, ptype='low')
    # print powerCompute_df(['300134','002171'], dtype='d',end=None, dl=10, filter='y')
    # # print powerCompute_df(['601198', '002791', '000503'], dtype='d', end=None, dl=30, filter='y')
    # print get_linear_model_status('999999', filter='y', dl=34, ptype='low', days=1)
    # print pct.get_linear_model_status('601519', filter='y', dl=34, ptype='low', days=1)
    # sys.exit()
    import re
    if cct.isMac():
        cct.set_console(80, 19)
    else:
        cct.set_console(80, 19)
    parser = parseArgmain()
    parser.print_help()
    if cct.get_os_system().find('win') >= 0:
        import win_unicode_console
        win_unicode_console.disable()
    while 1:
        try:
            # log.setLevel(LoggerFactory.INFO)
            # log.setLevel(LoggerFactory.DEBUG)
            code = raw_input("code:")
            args = parser.parse_args(code.split())
            # if not code.lower() == 'q' and not code.lower() == 'quit' and not code.lower() == 'exit' and not code == 'q' and not code == 'e' and not str(args.code) == 'None' and (args.wencai == 'y' or re.match('[a-zA-Z]+',code) is not None  or re.match('[ \u4e00 -\u9fa5]+',code) == None ):
            # if not cct.get_os_system() == 'mac':
            #     import ipdb;ipdb.set_trace()

            if not code.lower() == 'q' and not code.lower() == 'quit' and not code.lower() == 'exit' and not code == 'q' and not code == 'e' \
                and not str(args.code) == 'None' and (args.wencai == 'y' and (re.match('[a-zA-Z]+',code) is  None  and re.match(ur"[\u4e00-\u9fa5]+",code) is not None ) ):
                df  = wcd.get_wencai_Market_url(code,200,pct=False)
Esempio n. 3
0
                position = doScript(script_get_position % ('get', str(n)))
                # position = doScript(scriptposition % ('get', str(n)))
                if close:
                    # print ("close:%s %s"%(n,title))
                    os.system(closeterminalw % (n))
                return cmd, position


# positionKey = cct.terminal_positionKey
basedir = cct.get_now_basedir()
import socket
hostname = socket.gethostname()

if basedir.find('vm') >= 0:
    positionKey = cct.terminal_positionKey_VM
elif cct.get_os_system() == 'mac':
    positionKey = cct.terminal_positionKeyMac2021
    # positionKey = cct.terminal_positionKeyMac
else:
    positionKey = cct.terminal_positionKey4K
    # positionKey = cct.terminal_positionKey1K_triton

if hostname.find('R900') >= 0:
    positionKey = cct.terminal_positionKey2K_R9000P

# print("position:%s"%(positionKey))


def setPosition(cmd=None, position=None):
    count = doScript(scriptcount)
    # print count