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


Python commands.Commands类代码示例

本文整理汇总了Python中commands.Commands的典型用法代码示例。如果您正苦于以下问题:Python Commands类的具体用法?Python Commands怎么用?Python Commands使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: updatemd5

def updatemd5(conffile, force):
    try:
        commands = Commands(conffile)

        if (commands.checkmd5s(CLIENT) or commands.checkmd5s(SERVER)) and not force:
            print 'WARNING:'
            print 'The updatemd5 script is unsupported and should only be run in special'
            print 'cases, such as if there were compile errors in the last decompile which'
            print 'have now been corrected. It will reset the changed status of all classes'
            print 'for reobfuscation, and only classes modified afterwards will end up in'
            print 'the reobf directory.'
            print 'Only use this script if you absolutely know what you are doing, or when a'
            print 'MCP team member asks you to do so.'
            answer = raw_input('If you really want to update all classes, enter "Yes" ')
            if answer.lower() not in ['yes']:
                print 'You have not entered "Yes", aborting the update process'
                sys.exit(1)

        try:
            updatemd5_side(commands, CLIENT)
        except CalledProcessError:
            commands.logger.error('Client recompile failed, correct source then rerun updatemd5')
        try:
            updatemd5_side(commands, SERVER)
        except CalledProcessError:
            commands.logger.error('Server recompile failed, correct source then rerun updatemd5')
    except Exception:  # pylint: disable-msg=W0703
        logging.exception('FATAL ERROR')
        sys.exit(1)
开发者ID:CatRabbit499,项目名称:MCTC,代码行数:29,代码来源:updatemd5.py

示例2: parse_cmd

def parse_cmd(inp, key):
    """
    This function validates the data we received from the API
    and delegates the appropriate responses to that data.
    """

    # First check if inp can be parsed as an integer
    try:
        int(inp)
        print(inp)
    except:
        print('Input was not an integer :)')
        return

    commands = Commands()

    if inp == '1':
        print('input 1')
        message = communication.getdata(cfg.P_BASE, cfg.P_COMMAND, key)
        commands.system_cmd(message)
    elif inp == '2':
        url_to_open = communication.getdata(cfg.P_BASE, cfg.P_COMMAND, key)
        commands.open_webbrowser(url_to_open)
    elif inp == '3':
        url_to_open = communication.getdata(cfg.P_BASE, cfg.P_COMMAND, key)

        screenshot = Screenshot()
        screenshot.snap()
开发者ID:Evert-Arends,项目名称:myRemote-client,代码行数:28,代码来源:myRemote.py

示例3: status

    def status(self, env):
        from params import status_params

        env.set_params(status_params)
        commands = Commands(status_params)
        if not commands.topologies_running():
            raise ComponentIsNotRunning()
开发者ID:charlesporter,项目名称:incubator-metron,代码行数:7,代码来源:parser_master.py

示例4: install

 def install(self, env):
     import params
     env.set_params(params)
     commands = Commands(params)
     commands.setup_repo()
     Logger.info('Install RPM packages')
     self.install_packages(env)
开发者ID:charlesporter,项目名称:incubator-metron,代码行数:7,代码来源:indexing_master.py

示例5: status

    def status(self, env):
        import status_params
        env.set_params(status_params)
        commands = Commands(status_params)

        if not commands.is_topology_active():
            raise ComponentIsNotRunning()
开发者ID:charlesporter,项目名称:incubator-metron,代码行数:7,代码来源:indexing_master.py

示例6: reobfuscate

def reobfuscate(conffile, reobf_all, keep_lvt, keep_generics, only_client, only_server, srg_names, force_rg):
    try:
        commands = Commands(conffile, verify=True)

        if keep_generics:
            keep_lvt = True

        # client or server
        process_client = True
        process_server = True
        if only_client and not only_server:
            process_server = False
        if only_server and not only_client:
            process_client = False
            
        commands.logger.info('> Creating Retroguard config files')
        commands.creatergcfg(reobf=True, keep_lvt=keep_lvt, keep_generics=keep_generics, srg_names=srg_names)
        
        if process_client:
            reobfuscate_side(commands, CLIENT, reobf_all=reobf_all, srg_names=srg_names, force_rg=force_rg)
        if process_server:
            reobfuscate_side(commands, SERVER, reobf_all=reobf_all, srg_names=srg_names, force_rg=force_rg)
    except Exception:  # pylint: disable-msg=W0703
        logging.exception('FATAL ERROR')
        sys.exit(1)
开发者ID:435886030,项目名称:MineCraft_Warden,代码行数:25,代码来源:reobfuscate.py

示例7: on_publicmsg

  def on_publicmsg(self, connection, event):
    if connection != self.connection:
      self.log.info("IRC: Incorrect connection in on_publicmsg")
      return

    incoming_message = event.arguments()[0].lstrip()

    if len(incoming_message) < 1:
        return

    cmd = incoming_message.partition(" ")[0][1:]
    args = incoming_message.partition(" ")[2]
    src = event.source()

    if incoming_message[0] == "!":
        self.log.info("Command: \"%s\" Args: \"%s\" From: \"%s\"" % (cmd, args, src))
        command = Commands(event.target(), self.command_info, self.command_callback)
        command.parse(cmd, args, src)
    else:
        inc_msg = incoming_message.strip(" \t\n\r").lower()
        origin = src.partition("!")[0]
        if (not inc_msg.find("morning") == -1) and (not inc_msg.find(self.config.nick) == -1):
            self.command_callback("Morning %s" % origin, event.target())
        elif (not inc_msg.find("afternoon") == -1) and (not inc_msg.find(self.config.nick) == -1):
            self.command_callback("Afternoon %s" % origin, event.target())
        elif (not inc_msg.find("evening") == -1) and (not inc_msg.find(self.config.nick) == -1):
            self.command_callback("Evening %s" % origin, event.target())
        elif (not inc_msg.find("night") == -1) and (not inc_msg.find(self.config.nick) == -1):
            self.command_callback("Good night %s" % origin, event.target())
开发者ID:fone4u,项目名称:apexbot,代码行数:29,代码来源:bot.py

示例8: cleanup

def cleanup(conffile, force, distclean):
    try:
        commands = Commands(conffile, shortstart=True)

        if not force:
            print 'WARNING:'
            print 'The cleanup script will delete all folders created by MCP, including the'
            print 'src folder which may contain changes you made to the code, along with any'
            print 'saved worlds from the client or server.'
            answer = raw_input('If you really want to clean up, enter "Yes" ')
            if answer.lower() not in ['yes']:
                print 'You have not entered "Yes", aborting the clean up process'
                sys.exit(1)

        commands.checkupdates()

        try:
            commands.logger.info('> Cleaning temp')
            reallyrmtree(commands.dirtemp)

            commands.logger.info('> Cleaning src')
            reallyrmtree(commands.dirsrc)

            commands.logger.info('> Cleaning bin')
            reallyrmtree(commands.dirbin)

            commands.logger.info('> Cleaning reobf')
            reallyrmtree(commands.dirreobf)

            if distclean:
                commands.logger.info('> Cleaning lib')
                reallyrmtree(commands.dirlib)

            commands.logger.info('> Cleaning jars')
            reallyrmtree(os.path.join(commands.dirjars, 'stats'))
            reallyrmtree(os.path.join(commands.dirjars, 'texturepacks'))
            reallyrmtree(os.path.join(commands.dirjars, 'texturepacks-mp-cache'))            
            if distclean:
                reallyrmtree(os.path.join(commands.dirjars, 'saves'))
                reallyrmtree(os.path.join(commands.dirjars, 'mcpworld'))
                reallyrmtree(os.path.join(commands.dirjars, 'versions'))                
                reallyrmtree(os.path.join(commands.dirjars, 'assets'))                                
                reallyrmtree(os.path.join(commands.dirjars, 'libraries'))                
            if os.path.exists(os.path.join(commands.dirjars, 'server.log')):
                os.remove(os.path.join(commands.dirjars, 'server.log'))
            for txt_file in glob.glob(os.path.join(commands.dirjars, '*.txt')):
                os.remove(txt_file)

            commands.logger.info('> Cleaning logs')
            logging.shutdown()
            reallyrmtree(commands.dirlogs)
        except OSError as ex:
            print >> sys.stderr, 'Cleanup FAILED'
            if hasattr(ex, 'filename'):
                print >> sys.stderr, 'Failed to remove ' + ex.filename
            sys.exit(1)
    except Exception:  # pylint: disable-msg=W0703
        logging.exception('FATAL ERROR')
        sys.exit(1)
开发者ID:CircuitLord,项目名称:Minecraft-1.9-MCP,代码行数:59,代码来源:cleanup.py

示例9: startserver

def startserver(conffile=None):
    commands = Commands(conffile)

    try:
        commands.startserver()
    except Exception:  # pylint: disable-msg=W0703
        commands.logger.exception('FATAL ERROR')
        sys.exit(1)
开发者ID:Orazur66,项目名称:Minecraft-Client,代码行数:8,代码来源:startserver.py

示例10: test_run_retcodes

 def test_run_retcodes(self):
     p = Commands(CommandsBase("opengrok-master",
                  [["/bin/echo"], ["/bin/true"], ["/bin/false"]]))
     p.run()
     # print(p.retcodes)
     self.assertEqual({'/bin/echo opengrok-master': 0,
                       '/bin/true opengrok-master': 0,
                       '/bin/false opengrok-master': 1}, p.retcodes)
开发者ID:kahatlen,项目名称:OpenGrok,代码行数:8,代码来源:test_commands.py

示例11: cleanup

def cleanup(conffile=None, force=False):
    if not force:
        print "WARNING:"
        print "The cleanup script will delete all folders created by MCP, including the"
        print "src folder which may contain changes you made to the code."
        answer = raw_input('If you really want to clean up, enter "Yes" ')
        if answer.lower() not in ["yes"]:
            print 'You have not entered "Yes", aborting the clean up process'
            sys.exit(1)

    commands = Commands(conffile)
    commands.checkupdates()

    commands.logger.info("> Cleaning temp")
    try:
        reallyrmtree(commands.dirtemp)
    except OSError:
        commands.logger.error("failed cleaning temp")

    commands.logger.info("> Cleaning src")
    try:
        reallyrmtree(commands.dirsrc)
    except OSError:
        commands.logger.error("failed cleaning src")

    commands.logger.info("> Cleaning bin")
    try:
        reallyrmtree(commands.dirbin)
    except OSError:
        commands.logger.error("failed cleaning bin")

    commands.logger.info("> Cleaning reobf")
    try:
        reallyrmtree(commands.dirreobf)
    except OSError:
        commands.logger.error("failed cleaning reobf")

    commands.logger.info("> Cleaning jars")
    try:
        reallyrmtree(os.path.join(commands.dirjars, "saves"))
    except OSError:
        commands.logger.error("failed cleaning saves")
    try:
        reallyrmtree(os.path.join(commands.dirjars, "texturepacks"))
    except OSError:
        commands.logger.error("failed cleaning texturepacks")
    try:
        reallyrmtree(os.path.join(commands.dirjars, "world"))
    except OSError:
        commands.logger.error("failed cleaning world")
    if os.path.exists(os.path.join(commands.dirjars, "server.log")):
        os.remove(os.path.join(commands.dirjars, "server.log"))
    for txt_file in glob.glob(os.path.join(commands.dirjars, "*.txt")):
        os.remove(txt_file)

    commands.logger.info("> Cleaning logs")
    logging.shutdown()
    reallyrmtree(commands.dirlogs)
开发者ID:Tado87,项目名称:FarmCraft-Crafbukkit,代码行数:58,代码来源:cleanup.py

示例12: updatemcp

def updatemcp(conffile=None, force=False):
    commands = Commands(conffile)

    try:
        commands.logger.info('== Updating MCP ==')
        commands.downloadupdates(force)
    except Exception:  # pylint: disable-msg=W0703
        commands.logger.exception('FATAL ERROR')
        sys.exit(1)
开发者ID:Orazur66,项目名称:Minecraft-Client,代码行数:9,代码来源:updatemcp.py

示例13: service_check

    def service_check(self, env):
        import params
        env.set_params(params)

        commands = Commands(params)
        if commands.is_topology_active():
            exit(0)
        else:
            exit(1)
开发者ID:charlesporter,项目名称:incubator-metron,代码行数:9,代码来源:service_check.py

示例14: service_check

 def service_check(self, env):
     from params import params
     env.set_params(params)
     commands = Commands(params)
     all_found = commands.topologies_running()
     if all_found:
         exit(0)
     else:
         exit(1)
开发者ID:charlesporter,项目名称:incubator-metron,代码行数:9,代码来源:service_check.py

示例15: main

def main(conffile=None):
    commands = Commands(conffile)

    commands.logger.info ('> Recompiling')
    recompile.main(conffile)
    commands.logger.info ('> Generating the md5 (client)')
    commands.gathermd5s(0)
    commands.logger.info ('> Generating the md5 (server)')
    commands.gathermd5s(1)
开发者ID:Cap123,项目名称:minecraft,代码行数:9,代码来源:updatemd5.py


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