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


Python config.username方法代码示例

本文整理汇总了Python中config.username方法的典型用法代码示例。如果您正苦于以下问题:Python config.username方法的具体用法?Python config.username怎么用?Python config.username使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config的用法示例。


在下文中一共展示了config.username方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_configs

# 需要导入模块: import config [as 别名]
# 或者: from config import username [as 别名]
def parse_configs():
    env = Env()
    env.read_env()

    config.battle_bot_module = env("BATTLE_BOT", 'safest')
    config.save_replay = env.bool("SAVE_REPLAY", config.save_replay)
    config.use_relative_weights = env.bool("USE_RELATIVE_WEIGHTS", config.use_relative_weights)
    config.gambit_exe_path = env("GAMBIT_PATH", config.gambit_exe_path)
    config.search_depth = int(env("MAX_SEARCH_DEPTH", config.search_depth))
    config.greeting_message = env("GREETING_MESSAGE", config.greeting_message)
    config.battle_ending_message = env("BATTLE_OVER_MESSAGE", config.battle_ending_message)
    config.websocket_uri = env("WEBSOCKET_URI", "sim.smogon.com:8000")
    config.username = env("PS_USERNAME")
    config.password = env("PS_PASSWORD", "")
    config.bot_mode = env("BOT_MODE")
    config.team_name = env("TEAM_NAME", None)
    config.pokemon_mode = env("POKEMON_MODE", constants.DEFAULT_MODE)
    config.run_count = int(env("RUN_COUNT", 1))

    if config.bot_mode == constants.CHALLENGE_USER:
        config.user_to_challenge = env("USER_TO_CHALLENGE")
    init_logging(env("LOG_LEVEL", "DEBUG")) 
开发者ID:pmariglia,项目名称:showdown,代码行数:24,代码来源:run.py

示例2: setUpClass

# 需要导入模块: import config [as 别名]
# 或者: from config import username [as 别名]
def setUpClass(cls):
        cls.device = EOS(config.hostname, config.username, config.password, config.use_ssl)
        cls.device.open() 
开发者ID:spotify,项目名称:pyeos,代码行数:5,代码来源:TestEOS.py

示例3: setUpClass

# 需要导入模块: import config [as 别名]
# 或者: from config import username [as 别名]
def setUpClass(cls):
        cls.device = FortiOS(config.vm_ip, vdom='test_vdom', username=config.username, password=config.password)
        cls.device.open()

        with open(config.config_file_1, 'r') as f:
            cls.config_1 = f.readlines()
        with open(config.config_file_2, 'r') as f:
            cls.config_2 = f.readlines() 
开发者ID:spotify,项目名称:pyfg,代码行数:10,代码来源:TestFortiOS.py

示例4: reddit_setup

# 需要导入模块: import config [as 别名]
# 或者: from config import username [as 别名]
def reddit_setup(self):
        print "Logging in"
        r = praw.Reddit("Sidebar livestream updater for /r/{} by /u/andygmb ".format(subreddit))
        r.login(username=username, password=password, disable_warning=True)
        sub = r.get_subreddit(subreddit)
        return r, sub 
开发者ID:Andygmb,项目名称:twitchy_the_bot,代码行数:8,代码来源:twitchy.py

示例5: showdown

# 需要导入模块: import config [as 别名]
# 或者: from config import username [as 别名]
def showdown():
    parse_configs()

    apply_mods(config.pokemon_mode)

    original_pokedex = deepcopy(pokedex)
    original_move_json = deepcopy(all_move_json)

    ps_websocket_client = await PSWebsocketClient.create(config.username, config.password, config.websocket_uri)
    await ps_websocket_client.login()

    battles_run = 0
    wins = 0
    losses = 0
    while True:
        team = load_team(config.team_name)
        if config.bot_mode == constants.CHALLENGE_USER:
            await ps_websocket_client.challenge_user(config.user_to_challenge, config.pokemon_mode, team)
        elif config.bot_mode == constants.ACCEPT_CHALLENGE:
            await ps_websocket_client.accept_challenge(config.pokemon_mode, team)
        elif config.bot_mode == constants.SEARCH_LADDER:
            await ps_websocket_client.search_for_match(config.pokemon_mode, team)
        else:
            raise ValueError("Invalid Bot Mode")

        winner = await pokemon_battle(ps_websocket_client, config.pokemon_mode)

        if winner == config.username:
            wins += 1
        else:
            losses += 1

        logger.info("W: {}\tL: {}".format(wins, losses))

        check_dictionaries_are_unmodified(original_pokedex, original_move_json)

        battles_run += 1
        if battles_run >= config.run_count:
            break 
开发者ID:pmariglia,项目名称:showdown,代码行数:41,代码来源:run.py

示例6: check_inbox

# 需要导入模块: import config [as 别名]
# 或者: from config import username [as 别名]
def check_inbox(self):
        if self.config["accept_messages"].lower() not in ["false", "no", "n"]:
            streams = []
            inbox = self.r.get_inbox()
            print "Checking inbox for new messages"
            for message in inbox:
                if message.new \
                        and message.subject == "Twitch.tv request /r/{}".format(self.subreddit):
                    message_content = message.body.split()[0]
                    try:
                        re_pattern = 'twitch.tv/(\w+)'
                        # pattern matches twitch username in the first group
                        re_result = re.search(re_pattern, message_content)
                        if re_result:
                            stream_name = re_result.group(1).lower()
                        # extract the username stored in regex group 1
                        else:
                            print "Could not find stream name in message."
                            continue # skip to next message
                    except ValueError:
                        message.mark_as_read()
                        stream_name = "null"
                        print "Could not find stream name in message."

                    if "twitch.tv/" in message_content \
                            and len(stream_name) <=25 \
                            and stream_name not in self.banned \
                            and stream_name not in self.streams:
                        streams.append(stream_name)
                        message.reply(self.config["messages"]["success"].format(subreddit=self.subreddit))
                        message.mark_as_read()

                    elif stream_name in self.banned:
                        message.reply(self.config["messages"]["banned"].format(subreddit=self.subreddit))
                        message.mark_as_read()

                    elif stream_name in self.streams:
                        message.reply(self.config["messages"]["already_exists"].format(subreddit=self.subreddit))
                        message.mark_as_read()

            if streams:
                new_streams = list(set([stream for stream in streams if stream not in [self.streams, self.banned]]))
                self.streams.extend(new_streams)
                self.subreddit.edit_wiki_page(
                    self.config["wikipages"]["stream_list"],
                    "\n".join(self.streams),
                    reason="Adding stream(s): " + ", ".join(new_streams)
                )
        else:
            print "Skipping inbox check as accept_messages config is set to False."
            pass 
开发者ID:Andygmb,项目名称:twitchy_the_bot,代码行数:53,代码来源:twitchy.py


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