Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Handle delay in keosd startup and fix bad error statement. GH #5199
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjohnson5972 committed Sep 13, 2018
1 parent 982d0b0 commit b9a0b93
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions tests/WalletMgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def launch(self):
self.__walletPid=popen.pid

# Give keosd time to warm up
time.sleep(1)
time.sleep(2)
return True

def create(self, name, accounts=None, exitOnError=True):
Expand All @@ -53,20 +53,31 @@ def create(self, name, accounts=None, exitOnError=True):
if Utils.Debug: Utils.Print("Wallet \"%s\" already exists. Returning same." % name)
return wallet
p = re.compile(r'\n\"(\w+)\"\n', re.MULTILINE)
cmd="%s %s wallet create --name %s --to-console" % (Utils.EosClientPath, self.endpointArgs, name)
cmdDesc="wallet create"
cmd="%s %s %s --name %s --to-console" % (Utils.EosClientPath, self.endpointArgs, cmdDesc, name)
if Utils.Debug: Utils.Print("cmd: %s" % (cmd))
retStr=None
try:
retStr=Utils.checkOutput(cmd.split())
except subprocess.CalledProcessError as ex:
msg=ex.output.decode("utf-8")
msg="ERROR: Failed to import account owner key %s. %s" % (account.ownerPrivateKey, msg)
if exitOnError:
Utils.errorExit("%s" % (msg))
Utils.Print("%s" % (msg))
return None
maxRetryCount=4
retryCount=0
while True:
try:
retStr=Utils.checkOutput(cmd.split())
break
except subprocess.CalledProcessError as ex:
retryCount+=1
if retryCount<maxRetryCount:
delay=10
if Utils.Debug: Utils.Print("%s was not accepted, delaying for %d seconds and trying again" % (cmdDesc, delay))
time.sleep(delay)
continue

msg=ex.output.decode("utf-8")
msg="ERROR: Failed to create wallet - %s. %s" % (name, msg)
if exitOnError:
Utils.errorExit("%s" % (msg))
Utils.Print("%s" % (msg))
return None

#Utils.Print("create: %s" % (retStr))
m=p.search(retStr)
if m is None:
if exitOnError:
Expand Down

0 comments on commit b9a0b93

Please sign in to comment.