def index(request): if request.META['REMOTE_ADDR'] != '127.0.0.1': return render_to_response('404.html', {'content': _('You must change options from your website!')}, RequestContext(request, {})) if request.method == 'GET': x = dict4ini.DictIni('attsite.ini') WebPort = x.Options.Port return render_to_response('setoption.html', {'WebPort': WebPort, 'DbEngine': settings.DATABASE_ENGINE, 'DatabaseName': settings.DATABASE_NAME, 'DatabaseUser': settings.DATABASE_USER, 'DatabasePassword': settings.DATABASE_PASSWORD, 'DatabasePort': settings.DATABASE_PORT, 'DatabaseHost': settings.DATABASE_HOST, 'PIN_WIDTH': settings.PIN_WIDTH, 'ENCRYPT': settings.ENCRYPT, 'PAGE_LIMIT': settings.PAGE_LIMIT, 'REALTIME': settings.TRANS_REALTIME, 'AUTO_REG': settings.ICLOCK_AUTO_REG, 'DBEC': ENGINE_CHOICES, 'YN': YN_CHOICES}, RequestContext(request, {})) if request.method == 'POST': x = dict4ini.DictIni('attsite.ini') x.Options.Port = int(request.REQUEST['WebPort']) x.DATABASE.ENGINE = request.REQUEST['DbEngine'].encode('ASCII') x.DATABASE.NAME = request.REQUEST['DatabaseName'].encode('ASCII') x.DATABASE.USER = request.REQUEST['DatabaseUser'].encode('ASCII') x.DATABASE.PASSWORD = request.REQUEST['DatabasePassword'].encode('ASCII') x.DATABASE.PORT = int(request.REQUEST['DatabasePort']) x.DATABASE.HOST = request.REQUEST['DatabaseHost'].encode('ASCII') x.SYS.PIN_WIDTH = int(request.REQUEST['PIN_WIDTH']) x.SYS.ENCRYPT = int(request.REQUEST['ENCRYPT']) x.SYS.PAGE_LIMIT = int(request.REQUEST['PAGE_LIMIT']) x.SYS.REALTIME = int(request.REQUEST['REALTIME']) x.SYS.AUTO_REG = int(request.REQUEST['AUTO_REG']) x.save() return render_to_response('info.html', {'content': _('Set options OK!')}, RequestContext(request, {}))
def index(request): a = os.path.join("/home/web/", "site.ini") obj = dict4ini.DictIni(a) b = obj["SERVER"]["A"] logger.info("======>1={0}, 2={1}".format(a, b)) logger.info("url={0}".format(request.get_full_path())) return render(request, 'main/index.html')
def __init__(self, configFile='attsite.ini'): os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' p=os.getcwd() self.p=p os.environ['PATH']="%(p)s\\Apache2\\bin;%(p)s\\Python25;%(p)s\\mssql"%{"p":p}+os.environ['PATH'] newpath="%INSTALL_PATH%\\mssql;%INSTALL_PATH%\\mssql\\win32;%INSTALL_PATH%\\mssql\\win32\\lib;%INSTALL_PATH%\\Python25;%INSTALL_PATH%\\Python25\\Lib\\site-packages;%INSTALL_PATH%".replace('%INSTALL_PATH%',p).split(";") for p in newpath: if p not in sys.path: sys.path.append(p) # print "sys.path:", sys.path self.address='0.0.0.0:80' self.numthreads=10 self.queue_size=200 self.port=80 self.fcgiPort=10026 if os.path.exists(p+"/"+configFile+".dev"): configFile+=".dev" if os.path.exists(p+"/"+configFile): cfg=dict4ini.DictIni(p+"/"+configFile, values={'Options': {'Port':80, 'IPAddress':'0.0.0.0', 'Type': self.server_type, 'NumThreads': 10, 'QueueSize': 200, 'FcgiPort': 10026, }}) self.port=cfg.Options.Port self.address="%s:%s"%(cfg.Options.IPAddress, cfg.Options.Port) self.server_type=cfg.Options.Type self.numthreads=cfg.Options.NumThreads self.queue_size=cfg.Options.QueueSize self.fcgiPort=cfg.Options.FcgiPort # print "address=%s,number of threads=%s,queue size=%s"%(self.address,self.numthreads,self.queue_size) print "Start Automatic Data Master Server ... ...\nOpen your web browser and go http://%s"%(self.address.replace("0.0.0.0","127.0.0.1"))+"/"
def app_options(): # 配置数据容器 ''' 系统全局配置参数 ''' from base.options import SYSPARAM, PERSONAL import dict4ini # 读取配置文件appconfig.ini appconf = dict4ini.DictIni(settings.APP_HOME + "/appconfig.ini") language = appconf["language"]["language"] # 设置语言 return ( #参数名称, 参数默认值,参数显示名称,解释,参数类别,是否可见 ('date_format', '%Y-%m-%d', u"%s" % _(u'日期格式'), '', PERSONAL, True), ('time_format', '%H:%M:%S', u"%s" % _(u'时间格式'), '', PERSONAL, True), ('datetime_format', '%Y-%m-%d %H:%M:%S', u"%s" % _(u'时间日期格式'), '', PERSONAL, True), ('shortdate_format', '%y-%m-%d', u"%s" % _(u'短日期格式'), '', PERSONAL, True), ('shortdatetime_format', '%y-%m-%d %H:%M', u"%s" % _(u'短日期时间格式'), '', PERSONAL, True), ('language', language, u'语言', '', PERSONAL, True), ('base_default_page', 'data/auth/User/', u"%s" % _(u'系统默认页面'), '', PERSONAL, False), ('site_default_page', 'data/worktable/', u"%s" % _(u'整个系统默认页面'), "", PERSONAL, False), ('backup_sched', '', u'备份时间', "", SYSPARAM, True), )
def get_appconfig_value(p_key, key): from django.conf import settings import dict4ini current_path = settings.APP_HOME app_config = dict4ini.DictIni(current_path + "/appconfig.ini") return app_config[p_key][key]
def index(request): if request.META['REMOTE_ADDR'] != '127.0.0.1': return render_to_response( "404.html", {'content': _('You must change options from your website!')}, RequestContext(request, {})) if request.method == "GET": x = dict4ini.DictIni('attsite.ini') WebPort = x.Options.Port return render_to_response( "setoption.html", { "WebPort": WebPort, "DbEngine": settings.DATABASE_ENGINE, "DatabaseName": settings.DATABASE_NAME, "DatabaseUser": settings.DATABASE_USER, "DatabasePassword": settings.DATABASE_PASSWORD, "DatabasePort": settings.DATABASE_PORT, "DatabaseHost": settings.DATABASE_HOST, "PIN_WIDTH": settings.PIN_WIDTH, "ENCRYPT": settings.ENCRYPT, "PAGE_LIMIT": settings.PAGE_LIMIT, "REALTIME": settings.TRANS_REALTIME, "AUTO_REG": settings.ICLOCK_AUTO_REG, "DBEC": ENGINE_CHOICES, "YN": YN_CHOICES }, RequestContext(request, {})) elif request.method == "POST": x = dict4ini.DictIni('attsite.ini') x.Options.Port = int(request.REQUEST['WebPort']) x.DATABASE.ENGINE = request.REQUEST['DbEngine'].encode('ASCII') x.DATABASE.NAME = request.REQUEST['DatabaseName'].encode('ASCII') x.DATABASE.USER = request.REQUEST['DatabaseUser'].encode('ASCII') x.DATABASE.PASSWORD = request.REQUEST['DatabasePassword'].encode( 'ASCII') x.DATABASE.PORT = int(request.REQUEST['DatabasePort']) x.DATABASE.HOST = request.REQUEST['DatabaseHost'].encode('ASCII') x.SYS.PIN_WIDTH = int(request.REQUEST['PIN_WIDTH']) x.SYS.ENCRYPT = int(request.REQUEST['ENCRYPT']) x.SYS.PAGE_LIMIT = int(request.REQUEST['PAGE_LIMIT']) x.SYS.REALTIME = int(request.REQUEST['REALTIME']) x.SYS.AUTO_REG = int(request.REQUEST['AUTO_REG']) x.save() return render_to_response("info.html", {'content': _('Set options OK!')}, RequestContext(request, {}))
def option(request, usr, catalog): from base.options import OptionForm from django.core.cache import cache from django.utils.translation import get_language if usr.is_anonymous(): return HttpResponse(_(u'没有权限')) if request.method == 'POST': from django.conf import settings if "mysite.iaccess" in settings.INSTALLED_APPS: from redis_self.server import start_dict_server import dict4ini is_contain_att = request.POST.get("is_contain_att") d_server = start_dict_server() att_dict = d_server.get_from_dict("IS_CONTAINS_ATT") if att_dict != None: att_dict = int(att_dict) cfg = dict4ini.DictIni(os.getcwd() + "/appconfig.ini", values={"iaccess": { "is_contain_att": 0 }}) if is_contain_att == "on": if att_dict != 1: d_server.set_to_dict("IS_CONTAINS_ATT", '1') cfg.iaccess.is_contain_att = 1 cfg.save() elif is_contain_att == None: if att_dict == 1: d_server.set_to_dict("IS_CONTAINS_ATT", '0') cfg.iaccess.is_contain_att = 0 cfg.save() f = OptionForm(catalog, usr, request.POST) if f.is_valid( ): # All validation rules pass Process the data in form.cleaned_data try: f.save() k = "user_id_%s" % usr.pk cache.delete(k) except Exception, e: #保存失败 import traceback traceback.print_exc() from data_edit import NON_FIELD_ERRORS f.errors[ NON_FIELD_ERRORS] = u'<ul class="errorlist"><li>%s</li></ul>' % e else: lng = get_language() cache.delete(u"%s_%s_%s" % (lng, usr.username, "menu_list")) if request.is_ajax(): return getJSResponse('{ Info:"OK" }') else: return HttpResponse(u"%s" % f.errors)
def is_contain_att(site): #site变量暂无实际意义。 import dict4ini from django.conf import settings from redis_self.server import start_dict_server current_path = settings.APP_HOME if 'mysite.iaccess' in settings.INSTALLED_APPS: d_server = start_dict_server() is_contain_att = d_server.get_key('IS_CONTAINS_ATT') if is_contain_att == None: #print '*******read is_att from file***' app = dict4ini.DictIni(current_path + "/appconfig.ini") is_contain_att = app["iaccess"].has_key( "is_contain_att") and app["iaccess"]["is_contain_att"] or "0" d_server.set_to_dict('IS_CONTAINS_ATT', is_contain_att) d_server.close() return settings.ZKACCESS_ATT and int(is_contain_att) return True
def reload_config(): global CONF global USE_MULTI_PROCESS global url_worker global url_client global url_exitsocket global url_worker_cmd global WORKER_NUM global thread_num_of_worker CONF = dict4ini.DictIni(config_file) USE_MULTI_PROCESS = CONF.wordp.use_multi_process url_worker = CONF.wordp.url_worker url_client = CONF.wordp.url_client url_exitsocket = CONF.wordp.url_exitsocket url_worker_cmd = CONF.wordp.url_worker_cmd WORKER_NUM = CONF.wordp.worker_num thread_num_of_worker = CONF.wordp.thread_num_of_worker
def replaceSetting(): defaultMainSettingsIni() mainConfigFile = datapath + '\\config.ini' iniMainSettings = dict4ini.DictIni(mainConfigFile) for section in list(iniMainSettings.keys()): #print (iniMainSettings[section].keys()) for opt in list(iniMainSettings[section].keys()): value = iniMainSettings[section][opt] #print (str(value)) if isinstance(value, list): cybeSystemsMainSettings[section][opt] = value else: cybeSystemsMainSettings[section][opt] = str(value) if value == 'true' or value == 'True': cybeSystemsMainSettings[section][opt] = True if value == 'false' or value == 'False': cybeSystemsMainSettings[section][opt] = False if str(value).isdigit() == True: cybeSystemsMainSettings[section][opt] = int(value)
def ini2acl_dict(fp): import dict4ini ini = dict4ini.DictIni(fp) acldict = {} groups = ini.groups for config_name, value in ini.ordereditems(ini): if config_name[-1:] == ":": repo_name = config_name[:-1] for role in value: if role[0] == "@": groupname = role[1:] if groups.has_key(groupname): for user in groups[groupname]: if not acldict.has_key(repo_name): acldict[repo_name] = {} acldict[repo_name][user] = value[role] else: if not acldict.has_key(repo_name): acldict[repo_name] = {} acldict[repo_name][role] = value[role] return acldict, ini
def process_visitor_option(request): func = request.GET.get("func", "") cfg = dict4ini.DictIni(os.getcwd() + "/appconfig.ini", values={ "visitor": { "time_length": 5, "time_table": 3, "times": 3, "is_warn": 1, "photo_path": "D:\\trunk\\units\\adms\\files\\photo" } }) #初始化访客参数初始值 if func == "set_option": #设置信息 try: cfg.visitor.time_length = request.POST.get("time_length", "") cfg.visitor.time_table = request.POST.get("time_table", "") cfg.visitor.times = request.POST.get("times", "") cfg.visitor.is_warn = request.POST.get("is_warn", "") cfg.visitor.is_warn = request.POST.get("photo_path", "") cfg.save() return HttpResponse(smart_str(simplejson.dumps({"ret": 0}))) except: return HttpResponse(smart_str(simplejson.dumps({"ret": -1}))) #未知错误 if func == "get_option": #获取信息 param_info = { "time_length": cfg.visitor.time_length, "time_table": cfg.visitor.time_table, "times": cfg.visitor.times, "is_warn": cfg.visitor.is_warn, "photo_path": cfg.visitor.photo_path, } return HttpResponse(smart_str(simplejson.dumps(param_info)))
def run(self): init_Email() d_server = start_dict_server() q_server = FileQueue() email_count = q_server.get_from_file("EMAILS") if email_count: d_server.set_to_dict("EMAIL_COUNT", 1) # try: while True: #修改邮件参数不需要重启服务。-darcy20120220 change_args = d_server.get_from_dict("CHANGE_IACCESS_EMAIL_ARGS") # print '-------change_iaccess_argument-----',change_args if change_args: cfg = dict4ini.DictIni(os.getcwd() + "/appconfig.ini", values={ "iaccess": { "down_newlog": 0, "realtime_forever": 0 } }) realtime_forever = int(cfg.iaccess.realtime_forever) down_log_time = cfg.iaccess.down_newlog init_Email(cfg) d_server.set_to_dict("CHANGE_IACCESS_EMAIL_ARGS", 0) email_info = d_server.get_from_dict("EMAIL_INFO") # print "EMAIL_INFO:---",email_info d_server.set_to_dict("EMAIL_INFO", "") process_send_email(email_info, q_server, d_server) # print "one round" time.sleep(10) # except: # pass # finally: q_server.connection.disconnect() d_server.close()
datapath + '\\ShellScript\\Testscript.sh') QtCore.QFile.copy( scriptpathWinSep + '\\DefaultData\\Shortcuts\\C_Users.lnk', datapath + '\\Shortcuts\\C_Users.lnk') if scriptpathParentParentFolderDirName == 'PortableApps': os.environ["PORTABLEAPPS"] = "true" else: os.environ["PORTABLEAPPS"] = "false" cybeSystemsMainSettings = {} iniMainSettings = None mainConfigFile = datapath + '\\config.ini' cybeSystemsMainSettings = dict4ini.DictIni(mainConfigFile) iniMainSettings = dict4ini.DictIni(mainConfigFile) def defaultMainSettingsIni(): cybeSystemsMainSettings['Main'] = {} cybeSystemsMainSettings['Main'][ 'ExecutableExtension'] = "exe,bat,sh,pl,bat,py" cybeSystemsMainSettings['Main']['ExitAfterExec'] = False cybeSystemsMainSettings['Main']['SetContextMenu'] = True cybeSystemsMainSettings['Main']['TrayMenu'] = True cybeSystemsMainSettings['Main']['Shell'] = "ConEmu" cybeSystemsMainSettings['Main']['NoMsgBox'] = False cybeSystemsMainSettings['Main'][ 'CygwinMirror'] = "http://lug.mtu.edu/cygwin" cybeSystemsMainSettings['Main'][
def get_pos_site_file(): current_path = settings.WORK_PATH pos_config=dict4ini.DictIni(current_path+"/pos/pos_config.ini") return pos_config
from webtool import get_img_to_tmpdir import logging, logging.handlers rootLogger = logging.getLogger('') rootLogger.setLevel(logging.DEBUG) socketHandler = logging.handlers.SocketHandler( 'localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) rootLogger.addHandler(socketHandler) logger = logging.getLogger('mywpcrawler') import dict4ini configpath = '/etc/wordp.ini' CONF = dict4ini.DictIni(configpath) tmpdir = CONF.client0.tmpdir CRAWLER_CLASS = CONF.client0.crawler_class WEBSERVER_DOC_DIR = CONF.client0.webserver_doc_dir WEBSERVER_IMAGE_DIR = CONF.client0.webserver_image_dir WEBSERVER_IMAGE_HOST = CONF.client0.webserver_image_host WP_XMLRPC_URL = CONF.client0.wp_xmlrpc_url WP_XMLRPC_USER = CONF.client0.wp_xmlrpc_user WP_XMLRPC_PASS = CONF.client0.wp_xmlrpc_pass WEIXIN_TRY_TIME = CONF.weixin.try_time CLIENT_NAME = CONF.client0.name from wordp.modules import User, Task
def __init__(self, configFile='attsite.ini'): #global sync_dict os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings' p=os.getcwd() self.p=p # os.environ['PATH']="%(p)s\\Apache2\\bin;%(p)s\\Python25;%(p)s\\mssql"%{"p":p}+os.environ['PATH'] # newpath="%INSTALL_PATH%\\mssql;%INSTALL_PATH%\\mssql\\win32;%INSTALL_PATH%\\mssql\\win32\\lib;%INSTALL_PATH%\\Python25;%INSTALL_PATH%\\Python25\\Lib\\site-packages;%INSTALL_PATH%".replace('%INSTALL_PATH%',p).split(";") # for p in newpath: # if p not in sys.path: # sys.path.append(p) # print "sys.path:", sys.path self.address='0.0.0.0:80' self.numthreads=10 self.queue_size=200 self.port=80 self.fcgiPort=10026 self.WebPort=20001 self.portcount=1#cpu_count() self.webportcount=1#cpu_count() if os.path.exists(p+"/"+configFile+".dev"): configFile+=".dev" if os.path.exists(p+"/"+configFile): cfg=dict4ini.DictIni(p+"/"+configFile, values={'Options': {'Port':80, 'IPAddress':'0.0.0.0', 'Type': self.server_type, 'NumThreads': 10, 'QueueSize': 200, 'FcgiPort': 10026, }}) self.port=cfg.Options.Port self.address="%s:%s"%(cfg.Options.IPAddress, cfg.Options.Port) self.server_type=cfg.Options.Type self.numthreads=cfg.Options.NumThreads self.queue_size=cfg.Options.QueueSize self.fcgiPort=cfg.Options.FcgiPort # print "address=%s,number of threads=%s,queue size=%s"%(self.address,self.numthreads,self.queue_size) print "Start Automatic Data Master Server ... ...\nOpen your web browser and go http://%s"%(self.address.replace("0.0.0.0","127.0.0.1"))+"/" if EN_POS: from mysite.pos.pos_ic.ic_sync_action import init_pos_batch init_pos_batch() from mysite.utils import printf # from mysite.iaccess.linux_or_win import run_commend # printf("start now", True) # try: ## from redis_self.filequeue import FileQueue ## q_server = FileQueue() ## main_pid = q_server.get_from_file("WEB_SERVER_PID") ## #print '--pid2=',pid ## if main_pid: ## main_process_info = os.popen(run_commend(1) % main_pid).read() ## if run_commend(3) in main_process_info.lower(): ## os.system(run_commend(2) % main_pid)#启动时收尸 ## ## q_server.set_to_file("WEB_SERVER_PID", "%d"%(os.getpid())) ## from mysite import settings ## if "mysite.iaccess" in settings.INSTALLED_APPS: ## p = Process(target=run_acc_dictmanager, args=(q_server,)) ## p.start() # #启动时检测数据库版本和当前软件版本是否一致,不一致则同步数据库 # SyncDB().start() # except Exception, e: # printf('------e=%s'%e, True) printf("init finished", True)
def loadConfig(inifile): return dict4ini.DictIni(inifile)
# -*- coding: utf-8 -*- from django.core.cache import cache from django.conf import settings import dict4ini current_path = settings.WORK_PATH pos_config = dict4ini.DictIni(current_path + "/pos/pos_config.ini") TIMEOUT = settings.COMMAND_TIMEOUT * 3600 * 24 POS_IC_ADMS_MODEL = True #----------------------------IC消费数据解析批次最大值 POS_DEAL_BAT_SIZE = 50 POS_DEAL_BAT_SIZE = pos_config["Options"]["POS_DEAL_BAT_SIZE"] #---------------------------------IC消费在线补贴------------------------ ONLINE_ALLOWANCE = False is_online_allowance = pos_config["Options"]["ONLINE_ALLOWANCE"] if is_online_allowance.lower() == "true": #是否在线补贴模式 ONLINE_ALLOWANCE = True ONLINE_ALLOWANCE = ONLINE_ALLOWANCE #---------------------------------消费模块业务调试开关------------------------ POS_DEBUG = False #消费模块调试开关,用来打印日志信息跟踪调试 pos_debug = pos_config["Options"]["POS_DEBUG"] if pos_debug.lower() == "true": #是否在线补贴模式 POS_DEBUG = True POS_DEBUG = POS_DEBUG #----------------------------IC消费数据解析是否需要多进程模式 IS_DISTRIBUTED = False is_distributed = pos_config["Options"]["IS_DISTRIBUTED"] if is_distributed.lower() == "true": #是否分布式部署
cfg = None if os.path.exists(p_path + '.dev'): p_path = p_path + '.dev' if os.path.exists(p_path): import dict4ini cfg = dict4ini.DictIni(p_path, values={ 'DATABASE': DATABASES['default'].copy(), 'SYS': { 'PIN_WIDTH': PIN_WIDTH, 'ENCRYPT': ENCRYPT, 'PAGE_LIMIT': PAGE_LIMIT, 'REALTIME': TRANS_REALTIME, 'AUTO_REG': ICLOCK_AUTO_REG, 'NATIVE_ENCODE': NATIVE_ENCODE, 'MAX_EXPORT_COUNT': MAX_EXPORT_COUNT, 'TIME_ZONE': TIME_ZONE, 'memcached': 'locmem://', }, 'LOG': { 'DIR': LOG_DIR, 'FILE': "", 'LEVEL': LOG_LEVEL, } }) TIME_ZONE = cfg.SYS.TIME_ZONE DATABASES['default'] = dict(cfg.DATABASE).copy() DATABASE_NAME = cfg.DATABASE.NAME if "{unit}" in DATABASE_NAME: DATABASE_NAME = DATABASE_NAME.replace("{unit}", UNIT) elif DATABASE_NAME.startswith('{tmp_file}'):
def get_attsite_file(): current_path = os.getcwd() attsite = dict4ini.DictIni(current_path + "/attsite.ini") return attsite
def __init__(self): self.config = dict4ini.DictIni('conf.ini') a = "ninni"
cfg = dict4ini.DictIni(p_path, values={'DATABASE': {'ENGINE': DATABASE_ENGINE, 'NAME': DATABASE_NAME, 'USER': DATABASE_USER, 'PASSWORD': DATABASE_PASSWORD, 'HOST': DATABASE_HOST, 'PORT': DATABASE_PORT}, 'SYS': {'PIN_WIDTH': PIN_WIDTH, 'ENCRYPT': ENCRYPT, 'PAGE_LIMIT': PAGE_LIMIT, 'AutoDelTmp': AutoDelTmp, 'AutoDelTmpDay': AutoDelTmpDay, 'REALTIME': TRANS_REALTIME, 'AUTO_REG': ICLOCK_AUTO_REG, 'NATIVE_ENCODE': NATIVE_ENCODE, 'MAX_EXPORT_COUNT': MAX_EXPORT_COUNT, 'TIME_ZONE': TIME_ZONE, 'memcached': '', 'redis': '', 'LOG_DIR': LOG_DIR}, 'FTP': {'HOST': '10.1.1.254', 'USER': '******', 'PASSWORD': '******', 'EMP_PATH': '/sap/emp', 'SCH_PATH': '/sap/sch', 'TRANS_PATH': '/sap/trans', 'EMP_LOCAL': APP_HOME + '/tmp/processed/emp/', 'SCH_LOCAL': APP_HOME + '/tmp/processed/sch/'}, 'LOCALE': {'SHORT_DATETIME_FMT': SHORT_DATETIME_FMT, 'VSHORT_DATETIME_FMT': VSHORT_DATETIME_FMT, 'SHORT_DATETIME_FMT2': SHORT_DATETIME_FMT2, 'DATE_FMT': DATE_FMT, 'DATE_FMT4': DATE_FMT4, 'TIME_FMT': TIME_FMT}})
def get_backup_path(): current_path = settings.APP_HOME attsite = dict4ini.DictIni(current_path + "/attsite.ini") return attsite["Options"]["BACKUP_PATH"]
def get_attsite_file(): current_path = settings.APP_HOME attsite=dict4ini.DictIni(current_path+"/attsite.ini") return attsite
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker import dict4ini CONF = dict4ini.DictIni('/etc/wordp.ini') MYSQL_USER = CONF.weixin.mysql_user MYSQL_PASS = CONF.weixin.mysql_pass MYSQL_HOST = CONF.weixin.mysql_host MYSQL_DBNAME = CONF.weixin.mysql_dbname MYSQL_TABLE_PRE = CONF.weixin.mysql_table_pre DB_CONNECT_STRING = \ 'mysql+mysqldb://%(user)s:%(pass)s@%(host)s/%(dbname)s?charset=utf8' %{ 'user': MYSQL_USER, 'pass': MYSQL_PASS, 'host': MYSQL_HOST, 'dbname': MYSQL_DBNAME, } engine = create_engine(DB_CONNECT_STRING, echo=True) DB_Session = sessionmaker(bind=engine) session = DB_Session() from sqlalchemy import Column, Integer, String, Text from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class Task(Base): __tablename__ = '%stask' % MYSQL_TABLE_PRE id = Column(Integer, primary_key=True) uid = Column(Integer, index=True)
#-*- coding: utf-8 -*- #import pymssql #args = (0,0,0,100,0,0,None ) #conn_kwargs = { # 'host':'127.0.0.1\SQLEXPRESS', # 'user':'******', # 'charset':'utf8', # 'password':'******', # 'database': 'ltcj_x'} import dict4ini cfg = dict4ini.DictIni("../attsite.ini") db_cfg = cfg["DATABASE"] HOST = "" PORT = "" if db_cfg["ENGINE"] == "sqlserver_ado": import pymssql as pyDB HOST = db_cfg.has_key("HOST") and db_cfg["HOST"].replace( "\\\\", "\\") or "127.0.0.1" PORT = db_cfg.has_key("PORT") and db_cfg["PORT"] or 1433 elif db_cfg["ENGINE"] == "mysql": import MySQLdb as pyDB HOST = db_cfg.has_key("HOST") and db_cfg["HOST"] or "127.0.0.1" PORT = db_cfg.has_key("PORT") and db_cfg["PORT"] or 3306 elif db_cfg["ENGINE"] == "oracle": # 如果需要支持 oracle 请自行配置 pass CHARSET = 'utf8'
manage = "manage.pyc" websvr = "svr8000.pyc" '''配置python 解释器''' if sys.platform == 'win32': pythoner = "python" else: pythoner = "python" python_path = "python.exe" memcached_path = "memcached.exe" cur_path = os.getcwd() ####################### 读取配置文件相关项 ############################### import dict4ini att_file = dict4ini.DictIni("attsite.ini") VISIBLE_POS = att_file["Options"]["APP_POS"] VISIBLE_ATT = att_file["Options"]["APP_ATT"] VISIBLE_IACCESS = att_file["Options"]["APP_IACCESS"] VISIBLE_POS_IC = att_file["Options"]["POS_IC"] STD_PRINT = att_file["Options"]["STD_PRINT"] EN_POS = EN_ATT = EN_IACCESS = EN_POS_IC = False if VISIBLE_POS.lower() == "true": EN_POS = True if VISIBLE_POS_IC.lower() == "true": EN_POS_IC = True if VISIBLE_ATT.lower() == "true": EN_ATT = True if VISIBLE_IACCESS.lower() == "true": EN_IACCESS = True
# Get an instance of a logger logger = logging.getLogger() from werobot.robot import BaseRoBot import urllib2 import json import dict4ini from django.conf import settings from django.utils.translation import ugettext as _ from myweixin.utils.zmqclient import send_message_to_task_manager from wordp.modules import User, Option, Task from wordp.modules import session CONF = dict4ini.DictIni(settings.CONFIG_PATH) WEIXIN_TOKEN = CONF.weixin.token WEIXIN_APPID = CONF.weixin.appid WEIXIN_SECRET = CONF.weixin.secret WEIXIN_RETRY_TIME = CONF.weixin.retry_time CLIENT_NAME_LIST = CONF.weixin.client_name_list ADMIN_MAIL = CONF.weixin.admin_mail class WeRoBot(BaseRoBot): def __init__(self, token, request, response): BaseRoBot.__init__(self, token=token, logger=logger, enable_session=False, session_storage=None)