本文整理汇总了Python中configloader.get_config方法的典型用法代码示例。如果您正苦于以下问题:Python configloader.get_config方法的具体用法?Python configloader.get_config怎么用?Python configloader.get_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类configloader
的用法示例。
在下文中一共展示了configloader.get_config方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def main():
shell.check_python()
if False:
db_transfer.DbTransfer.thread_db()
else:
if get_config().API_INTERFACE == 'mudbjson':
thread = MainThread(db_transfer.MuJsonTransfer)
elif get_config().API_INTERFACE == 'sspanelv2':
thread = MainThread(db_transfer.DbTransfer)
else:
thread = MainThread(db_transfer.Dbv3Transfer)
thread.start()
try:
while thread.is_alive():
thread.join(10.0)
except (KeyboardInterrupt, IOError, OSError) as e:
import traceback
traceback.print_exc()
thread.stop()
示例2: __init__
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def __init__(self):
shell.check_python()
self.config = shell.get_config(False)
self.dns_resolver = asyncdns.DNSResolver()
if not self.config.get('dns_ipv6', False):
asyncdns.IPV6_CONNECTION_SUPPORT = False
self.mgr = None #asyncmgr.ServerMgr()
self.tcp_servers_pool = {}
self.tcp_ipv6_servers_pool = {}
self.udp_servers_pool = {}
self.udp_ipv6_servers_pool = {}
self.stat_counter = {}
self.loop = eventloop.EventLoop()
self.thread = MainThread( (self.loop, self.dns_resolver, self.mgr) )
self.thread.start()
示例3: __init__
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def __init__(self):
super(Dbv3Transfer, self).__init__()
self.update_node_state = True if get_config().API_INTERFACE != 'legendsockssr' else False
if self.update_node_state:
self.key_list += ['id']
self.key_list += ['method']
if self.update_node_state:
self.ss_node_info_name = 'ss_node_info_log'
if get_config().API_INTERFACE == 'sspanelv3ssr':
self.key_list += ['obfs', 'protocol']
if get_config().API_INTERFACE == 'glzjinmod':
self.key_list += ['obfs', 'protocol']
self.ss_node_info_name = 'ss_node_info'
else:
self.key_list += ['obfs', 'protocol']
self.start_time = time.time()
示例4: update_all_user
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def update_all_user(self, dt_transfer):
import json
rows = None
config_path = get_config().MUDB_FILE
with open(config_path, 'rb+') as f:
rows = json.loads(f.read().decode('utf8'))
for row in rows:
if "port" in row:
port = row["port"]
if port in dt_transfer:
row["u"] += dt_transfer[port][0]
row["d"] += dt_transfer[port][1]
if rows:
output = json.dumps(rows, sort_keys=True, indent=4, separators=(',', ': '))
with open(config_path, 'r+') as f:
f.write(output)
f.truncate()
return dt_transfer
示例5: pull_db_all_user
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def pull_db_all_user(self):
import json
rows = None
config_path = get_config().MUDB_FILE
with open(config_path, 'rb+') as f:
rows = json.loads(f.read().decode('utf8'))
for row in rows:
try:
if 'forbidden_ip' in row:
row['forbidden_ip'] = common.IPNetwork(row['forbidden_ip'])
except Exception as e:
logging.error(e)
try:
if 'forbidden_port' in row:
row['forbidden_port'] = common.PortRange(row['forbidden_port'])
except Exception as e:
logging.error(e)
if not rows:
logging.warn('no user in json file')
return rows
示例6: main
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def main():
shell.check_python()
if False:
db_transfer.DbTransfer.thread_db()
else:
if get_config().API_INTERFACE == 'mudbjson':
thread = MainThread(db_transfer.MuJsonTransfer)
elif get_config().API_INTERFACE == 'sspanelv2':
thread = MainThread(db_transfer.DbTransfer)
else:
thread = MainThread(db_transfer.Dbv3Transfer)
thread.start()
try:
while thread.is_alive():
time.sleep(10)
except (KeyboardInterrupt, IOError, OSError) as e:
import traceback
traceback.print_exc()
thread.stop()
示例7: __init__
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def __init__(self):
shell.check_python()
self.config = shell.get_config(False)
shell.print_shadowsocks()
self.dns_resolver = asyncdns.DNSResolver()
if not self.config.get('dns_ipv6', False):
asyncdns.IPV6_CONNECTION_SUPPORT = False
self.mgr = None #asyncmgr.ServerMgr()
self.tcp_servers_pool = {}
self.tcp_ipv6_servers_pool = {}
self.udp_servers_pool = {}
self.udp_ipv6_servers_pool = {}
self.stat_counter = {}
self.loop = eventloop.EventLoop()
self.thread = MainThread( (self.loop, self.dns_resolver, self.mgr) )
self.thread.start()
示例8: getApi
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def getApi(self, uri, params={}):
res = None
try:
uri_params = params.copy()
uri_params['key'] = get_config().WEBAPI_TOKEN
res = self.session_pool.get(
'%s/mod_mu/%s' %
(get_config().WEBAPI_URL, uri),
params=uri_params,
timeout=10)
data = res.json()
if data['ret'] == 0:
logging.error("Error data:%s" % (res.text))
logging.error("request %s error!wrong ret!"%(uri))
raise Exception("err ret")
return data['data']
except Exception:
import traceback
trace = traceback.format_exc()
logging.error(trace)
raise Exception('network issue or server error!')
示例9: postApi
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def postApi(self, uri, params={}, raw_data={}):
res = None
try:
uri_params = params.copy()
uri_params['key'] = get_config().WEBAPI_TOKEN
res = self.session_pool.post(
'%s/mod_mu/%s' %
(get_config().WEBAPI_URL,
uri),
params=uri_params,
json=raw_data,
timeout=10)
data = res.json()
if data['ret'] == 0:
logging.error("Error data:%s" % (res.text))
logging.error("request %s error!wrong ret!"%(uri))
raise Exception("err ret")
return data['data']
except Exception:
import traceback
trace = traceback.format_exc()
logging.error(trace)
raise Exception('network issue or server error!')
示例10: getKeys
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def getKeys():
key_list = ['id', 'port', 'u', 'd', 'transfer_enable', 'passwd', 'enable']
if get_config().API_INTERFACE == 'sspanelv3':
key_list += ['method']
elif get_config().API_INTERFACE == 'sspanelv3ssr':
key_list += ['method', 'obfs', 'protocol']
elif get_config().API_INTERFACE == 'glzjinmod':
key_list += ['method',
'obfs',
'obfs_param',
'protocol',
'protocol_param',
'id',
'node_speedlimit',
'forbidden_ip',
'forbidden_port',
'disconnect_ip',
'is_multi_user']
return key_list
# return key_list + ['plan'] # append the column name 'plan'
示例11: __init__
# 需要导入模块: import configloader [as 别名]
# 或者: from configloader import get_config [as 别名]
def __init__(self):
self.config_path = get_config().MUDB_FILE
try:
self.server_addr = get_config().SERVER_PUB_ADDR
except:
self.server_addr = '127.0.0.1'
self.data = MuJsonLoader()
if self.server_addr == '127.0.0.1':
self.server_addr = self.getipaddr()