当前位置: 首页>>代码示例>>Python>>正文


Python configloader.get_config方法代码示例

本文整理汇总了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() 
开发者ID:hao35954514,项目名称:shadowsocksR-b,代码行数:21,代码来源:server.py

示例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() 
开发者ID:hao35954514,项目名称:shadowsocksR-b,代码行数:20,代码来源:server_pool.py

示例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() 
开发者ID:hao35954514,项目名称:shadowsocksR-b,代码行数:18,代码来源:db_transfer.py

示例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 
开发者ID:hao35954514,项目名称:shadowsocksR-b,代码行数:23,代码来源:db_transfer.py

示例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 
开发者ID:hao35954514,项目名称:shadowsocksR-b,代码行数:24,代码来源:db_transfer.py

示例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() 
开发者ID:AlphaBrock,项目名称:ssr-ml,代码行数:21,代码来源:server.py

示例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() 
开发者ID:AlphaBrock,项目名称:ssr-ml,代码行数:21,代码来源:server_pool.py

示例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!') 
开发者ID:PaperDashboard,项目名称:shadowsocks,代码行数:24,代码来源:webapi_utils.py

示例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!') 
开发者ID:PaperDashboard,项目名称:shadowsocks,代码行数:26,代码来源:webapi_utils.py

示例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' 
开发者ID:PaperDashboard,项目名称:shadowsocks,代码行数:22,代码来源:switchrule.py

示例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() 
开发者ID:hao35954514,项目名称:shadowsocksR-b,代码行数:12,代码来源:mujson_mgr.py


注:本文中的configloader.get_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。