Esempio n. 1
0
 def run_agent(cls, agent: Agent, looper=None, bootstrap=None, with_cli=False):
     try:
         config = getConfig()
         if with_cli:
             runAgentCli(agent, config, looper=looper, bootstrap=bootstrap)
         else:
             runAgent(agent, looper, bootstrap)
         return agent
     except Exception as exc:
         error = "Agent startup failed: [cause : {}]".format(str(exc))
         logger.error(getFormattedErrorMsg(error))
Esempio n. 2
0
 def run_agent(cls,
               agent: Agent,
               looper=None,
               bootstrap=None,
               with_cli=False):
     try:
         config = getConfig()
         if with_cli:
             runAgentCli(agent, config, looper=looper, bootstrap=bootstrap)
         else:
             runAgent(agent, looper, bootstrap)
         return agent
     except Exception as exc:
         error = "Agent startup failed: [cause : {}]".format(str(exc))
         logger.error(getFormattedErrorMsg(error))
Esempio n. 3
0
    def createAndRunAgent(name: str,
                          agentClass=None,
                          wallet=None,
                          basedirpath=None,
                          port=None,
                          looper=None,
                          clientClass=Client,
                          bootstrap=True,
                          cliAgentCreator=None):

        loop = looper.loop if looper else None
        _, with_cli = TestWalletedAgent.getPassedArgs()
        try:
            if cliAgentCreator and with_cli:
                runAgentCli(name=name, agentCreator=cliAgentCreator)
            else:
                assert agentClass
                agent = createAgent(agentClass, name, wallet, basedirpath,
                                    port, loop, clientClass)
                runAgent(agent, looper, bootstrap)

        except Exception as exc:
            error = "Agent startup failed: [cause : {}]".format(str(exc))
            logger.error(getFormattedErrorMsg(error))