def redumpConfig(): from common import ConfigFiles source = request.POST.getone("source") or '' if not source: return FAILURE name = request.POST.getone("name") regionID = int(request.GET['regionID']) config_files = ConfigFiles(regionID) config_files.set_file(name, source) return SUCCESS
def check_configs(): import re import os import logging from common import ConfigFiles logger = logging.getLogger('config') pattern = re.compile("region([0-9]{3})") for d in os.walk("data").next()[1]: match = pattern.match(d) if not match: continue config_files = ConfigFiles(match.groups()[0]) path = os.path.join("data", d) logger.info("Config check %s" % path) config_files.check_files(path) logger.info("Config check success")
def getConfig(name): import settings from yy.config.dump import config_path from common import ConfigFiles regionID = int(request.GET['regionID']) config_files = ConfigFiles(regionID) source = config_files.get_file(name) if not source: path = config_path(name, settings.CONFIG_FILE_PATH) try: source = open(path, 'r').read() except IOError as e: return json.dumps(e.strerror) try: result = json.dumps(source) except UnicodeDecodeError: result = json.dumps(source.decode("cp936")) return result
def ping_proxy(self): import settings as st from gm.proxy import proxy while True: try: proxy.ping() except urllib3.exceptions.MaxRetryError: logger.info( "Can't connect proxy {host}:{port}".format(**st.PROXY)) else: logger.info("Connected proxy {host}:{port}".format(**st.PROXY)) from config.configs import get_registereds from yy.config.fields import ValidationError from common import ConfigFiles config_files = ConfigFiles(st.REGION['ID']) try: config_files.load_configs(get_registereds(), st.CONFIG_FILE_PATH) except ValidationError as e: print e.message.encode("utf-8") raise e logger.info('Config loaded %s', st.CONFIG_FILE_PATH) from pvp.rank import g_rankManager g_rankManager.start() from friend.manager import g_friendManager g_friendManager.start() from task.manager import check_daily_sp_state check_daily_sp_state() from campaign.manager import g_campaignManager g_campaignManager.start() from explore.dlc import g_dlcCampaignManager g_dlcCampaignManager.start() from explore.boss import g_bossCampaignManager g_bossCampaignManager.start() from pvp.swap import g_swapManager # NOQA self.started = True from chat.red import g_redManager g_redManager.start() break sleep(1)
def ping_proxy(self): import settings as st from gm.proxy import proxy while True: try: proxy.ping() except urllib3.exceptions.MaxRetryError: logger.info( "Can't connect proxy {host}:{port}".format(**st.PROXY)) else: logger.info("Connected proxy {host}:{port}".format(**st.PROXY)) from config.configs import get_registereds from yy.config.fields import ValidationError from common import ConfigFiles config_files = ConfigFiles(st.REGION['ID']) try: config_files.load_configs(get_registereds(), st.CONFIG_FILE_PATH) except ValidationError as e: print e.message.encode("utf-8") raise e logger.info('Config loaded %s', st.CONFIG_FILE_PATH) break sleep(1)
import settings settings.watch() from common import ConfigFiles from config.configs import get_registereds from yy.config.fields import ValidationError config_files = ConfigFiles(settings.REGION['ID']) try: config_files.load_configs(get_registereds(), settings.CONFIG_FILE_PATH) except ValidationError as e: print e.message.encode("utf-8") raise e from player.model import Player p = Player.load(11) print p.name from task.manager import on_end_fb_count, on_levelup import timeit import cProfile timeit.main( ['-s', 'from __main__ import on_levelup, p', '-n', '1', 'on_levelup(p)']) cProfile.run('for i in xrange(1):on_levelup(p)', sort='time') #timeit.main(['-s', 'from __main__ import on_end_fb_count, p', # '-n', '1000', 'on_end_fb_count(p, 100111)']) # #cProfile.run('for i in xrange(1000):on_end_fb_count(p, 100111)', # sort='time')
def reloadConfig(name): import settings from common import ConfigFiles from config.configs import get_registereds from yy.config.fields import ValidationError from entity.manager import g_entityManager source = request.POST.getone("source") or '' config_files = ConfigFiles(settings.REGION['ID']) try: if name == "all": config_files.load_configs(get_registereds(), settings.CONFIG_FILE_PATH) else: configs = [] for each in get_registereds(): if each.__Meta__.table == name: configs.append(each) if not configs: raise ValidationError("找不到文件%s对应的Config" % name) if source: data = {configs[0].__Meta__.table: source} config_files.load_configs(configs, '', **data) else: config_files.load_configs(configs, settings.CONFIG_FILE_PATH) except ValidationError as e: return json.dumps(e.message) if name == "daytime" or name == "all": from pvp.rank import g_rankManager g_rankManager.start() if name == "campaign" or name == "all": from campaign.manager import g_campaignManager g_campaignManager.start() if name == "Dlc_campaign" or name == "all": from explore.dlc import g_dlcCampaignManager g_dlcCampaignManager.start() if name == "gve_campaign" or name == "all": from campaign.manager import g_campaignManager g_campaignManager.gve_campaign.start() if name == "boss_campaign" or name == "all": from explore.boss import g_bossCampaignManager g_bossCampaignManager.start() if name == "ranking_campaign" or name == 'all': from ranking.manager import g_rankingCampaignManager g_rankingCampaignManager.reload() if name == "city_campaign" or name == 'all': from campaign.manager import g_campaignManager g_campaignManager.city_dungeon_campaign.start() g_campaignManager.city_dungeon_campaign.sync() g_campaignManager.city_contend_campaign.start() g_campaignManager.city_contend_campaign.sync() if name == "limit" or name == "all": from world.service import get_limited_packs_time t = get_limited_packs_time() if t: for p in g_entityManager.players.values(): p.clear_limited_packs_flag() p.sync('limited_packs_flag') if name == "ExSceneInfo" or name == "all": from scene.constants import FbType from scene.manager import sync_scene_infos for p in g_entityManager.players.values(): sync_scene_infos(p, FbType.Campaign) return SUCCESS