def log(str,isupload=False): now = datetime.datetime.now() str = now.strftime('%Y-%m-%d %H:%M:%S') +"\t" +str + "\n" dt = now.strftime('%Y-%m-%d') if os.path.exists(util.get_current_path() + "\log") == False: os.mkdir(util.get_current_path() + "\log") filename = util.get_current_path() + "\log\inbody-" + dt + ".log" #print filename fp = open(filename, "a+") fp.write(str) fp.close() if isupload: deal.upload_log(str) return
def conn(): filepath = util.get_current_path() + "\license.ini" conf = ConfigParser.ConfigParser() res = conf.read(filepath) mdb = conf.get("config", "dbpath") str = 'Driver={Microsoft Access Driver (*.mdb,*.accdb)};DBQ=' + mdb + ';' #str = 'Driver={Microsoft Access Driver (*.mdb,*.accdb)};DBQ=C:\Users\QN\PycharmProjects\inbody\LookinBody.mdb;' con = pypyodbc.win_connect_mdb(str) return con
def get_new_id(): global new_id, is_read_file, bus_id, license if is_read_file: filepath = util.get_current_path() + "\license.ini" conf = ConfigParser.ConfigParser() res = conf.read(filepath) new_id = conf.get("config", "new_id") bus_id = conf.get("config", "bus_id") license = conf.get("config", "license") return new_id
def open_inbody(): try: succ = False filepath = util.get_current_path() + "\license.ini" conf = ConfigParser.ConfigParser() res = conf.read(filepath) mylog.log("open_inbody\t filepath=" + filepath + "\tres=" + json.dumps(res)) if res == []: return succ exepath = conf.get("config", "exepath") mylog.log("exepath=" + exepath) ret = win32api.ShellExecute(0, 'open', exepath, '', '', 0) mylog.log("open_inbody\tret=" + json.dumps(ret)) return ret except Exception, e: mylog.log("open_inbody error") return False
def check(): succ = False filepath = util.get_current_path() + "\license.ini" conf = ConfigParser.ConfigParser() res = conf.read(filepath) mylog.log("check\t filepath=" + filepath + "\tres=" + json.dumps(res)) if res == []: return succ mdb = conf.get("config", "dbpath") if not os.path.exists(mdb): mylog.log("mdb=" + mdb + "\tres=False") succ = False return succ bus_id = conf.get("config", "bus_id") license = conf.get("config", "license") # mylog.log("bus_id="+bus_id+"\tlicense"+license) succ = check_license(bus_id, license) return succ
#!/usr/bin/env python # -*- coding:utf-8 -*- """ constant definition. -- [email protected] blueantelope 2015-01-10 """ from __init__ import * import util ROOT_PATH = util.get_parent_dir() # for backend BACKEND_PATH = util.get_current_path() MAIN = os.path.join(BACKEND_PATH, "main.pyc") APP_LIST = (os.path.join(BACKEND_PATH, "app.pyo"), os.path.join(BACKEND_PATH, "app.pyc"), os.path.join(BACKEND_PATH, "app.py") ) WATCHDOG_LIST = (os.path.join(BACKEND_PATH, "watchdog_app.pyo"), os.path.join(BACKEND_PATH, "watchdog_app.pyc"), os.path.join(BACKEND_PATH, "watchdog_app.py") ) # for frontend FRONTEND_DIR = os.path.join(util.get_parent_dir(), "frontend") PAGE_DIR = os.path.join(FRONTEND_DIR, "page") RESOURCE_DIR = os.path.join(FRONTEND_DIR, "resource") # for configuration CONFIG_INI_PATH = os.path.join(ROOT_PATH, "config.ini")
def set_new_id(lastest_new_id): filepath = util.get_current_path() + "\license.ini" conf = ConfigParser.ConfigParser() res = conf.read(filepath) conf.set("config", "new_id", lastest_new_id) conf.write(open(filepath, "wb"))
#!/usr/bin/env python # -*- coding:utf-8 -*- """ constant definition. -- [email protected] blueantelope 2015-01-10 """ from __init__ import * import util ROOT_PATH = util.get_parent_dir() # for backend BACKEND_PATH = util.get_current_path() MAIN = os.path.join(BACKEND_PATH, "main.pyc") APP_LIST = (os.path.join(BACKEND_PATH, "app.pyo"), os.path.join(BACKEND_PATH, "app.pyc"), os.path.join(BACKEND_PATH, "app.py")) WATCHDOG_LIST = (os.path.join(BACKEND_PATH, "watchdog_app.pyo"), os.path.join(BACKEND_PATH, "watchdog_app.pyc"), os.path.join(BACKEND_PATH, "watchdog_app.py")) # for frontend FRONTEND_DIR = os.path.join(util.get_parent_dir(), "frontend") PAGE_DIR = os.path.join(FRONTEND_DIR, "page") RESOURCE_DIR = os.path.join(FRONTEND_DIR, "resource") # for configuration CONFIG_INI_PATH = os.path.join(ROOT_PATH, "config.ini") LOG_INI_PATH = os.path.join(ROOT_PATH, "log.ini") WATCHDOG_PATH = os.path.join(ROOT_PATH, ".watchdog") ETC_DIR = os.path.join(util.get_parent_dir(), "etc")