當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。