wait for process to finish before next execution
This commit is contained in:
parent
e530925d9c
commit
e5ed224c72
23
parse.py
23
parse.py
@ -311,8 +311,8 @@ class Router:
|
|||||||
pi = Pipe(False)
|
pi = Pipe(False)
|
||||||
po = Process(target=self.__wrap, args=(cmd.i, fn, cmd,))
|
po = Process(target=self.__wrap, args=(cmd.i, fn, cmd,))
|
||||||
self.__r[cmd.i] = (po, pi,)
|
self.__r[cmd.i] = (po, pi,)
|
||||||
time.sleep(5)
|
|
||||||
po.start()
|
po.start()
|
||||||
|
po.join()
|
||||||
|
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
@ -385,6 +385,7 @@ def load_gas(address,nonce):
|
|||||||
message = f"Added some gas to {address}"
|
message = f"Added some gas to {address}"
|
||||||
printMessage(message)
|
printMessage(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def store_voucher(voucher_creator,voucher_symbol,voucher_address):
|
def store_voucher(voucher_creator,voucher_symbol,voucher_address):
|
||||||
vouchers = []
|
vouchers = []
|
||||||
@ -407,7 +408,6 @@ def store_voucher(voucher_creator,voucher_symbol,voucher_address):
|
|||||||
json.dump(vouchers, f)
|
json.dump(vouchers, f)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def key_create_handler(cmd):
|
def key_create_handler(cmd):
|
||||||
key_name = str(cmd.f).split(":")[1]
|
key_name = str(cmd.f).split(":")[1]
|
||||||
master_address = w3.eth.account.from_key(master_private_key)
|
master_address = w3.eth.account.from_key(master_private_key)
|
||||||
@ -421,10 +421,9 @@ def key_create_handler(cmd):
|
|||||||
else:
|
else:
|
||||||
private_key = cmd.k
|
private_key = cmd.k
|
||||||
address = w3.eth.account.from_key(private_key).address
|
address = w3.eth.account.from_key(private_key).address
|
||||||
time.sleep(5)
|
|
||||||
load_gas(address,nonce)
|
load_gas(address,nonce)
|
||||||
store_key_in_keystore(private_key, key_name, address)
|
store_key_in_keystore(private_key, key_name, address)
|
||||||
|
|
||||||
return address
|
return address
|
||||||
|
|
||||||
|
|
||||||
@ -438,6 +437,7 @@ def voucher_create_handler(cmd):
|
|||||||
existing_vouchers = json.load(f)
|
existing_vouchers = json.load(f)
|
||||||
except (FileNotFoundError):
|
except (FileNotFoundError):
|
||||||
existing_vouchers = []
|
existing_vouchers = []
|
||||||
|
|
||||||
voucher_symbols = list(map(lambda symbol: symbol['symbol'], existing_vouchers))
|
voucher_symbols = list(map(lambda symbol: symbol['symbol'], existing_vouchers))
|
||||||
|
|
||||||
if symbol in voucher_symbols:
|
if symbol in voucher_symbols:
|
||||||
@ -453,12 +453,13 @@ def voucher_create_handler(cmd):
|
|||||||
f'--rpc {rpc} --gas-fee-cap {gasCap} --chainid {chainId} ' \
|
f'--rpc {rpc} --gas-fee-cap {gasCap} --chainid {chainId} ' \
|
||||||
f'p erc20 --name "{name}" --symbol "{symbol}"'
|
f'p erc20 --name "{name}" --symbol "{symbol}"'
|
||||||
|
|
||||||
|
|
||||||
result = subprocess.run(publish_token, shell=True, capture_output=True, text=True)
|
result = subprocess.run(publish_token, shell=True, capture_output=True, text=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise subprocess.CalledProcessError(result.returncode, publish_token, output=result.stdout, stderr=result.stderr)
|
raise subprocess.CalledProcessError(result.returncode, publish_token, output=result.stdout, stderr=result.stderr)
|
||||||
|
|
||||||
output_lines = result.stderr.strip().split("\n")
|
output_lines = result.stderr.strip().split("\n")
|
||||||
deployment_result = output_lines[1]
|
deployment_result = output_lines[1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = json.loads(deployment_result)
|
data = json.loads(deployment_result)
|
||||||
contract_address = data.get('contract_address', None)
|
contract_address = data.get('contract_address', None)
|
||||||
@ -545,6 +546,7 @@ def voucher_transfer_handler(cmd):
|
|||||||
raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr)
|
raise subprocess.CalledProcessError(result.returncode, command, output=result.stdout, stderr=result.stderr)
|
||||||
if result.stderr:
|
if result.stderr:
|
||||||
raise ValueError(f"Command failed with error: {result.stderr}")
|
raise ValueError(f"Command failed with error: {result.stderr}")
|
||||||
|
|
||||||
data = json.loads(result.stdout)
|
data = json.loads(result.stdout)
|
||||||
message = f"Transfered {value} {voucher_name} to {to} "
|
message = f"Transfered {value} {voucher_name} to {to} "
|
||||||
printMessage(message)
|
printMessage(message)
|
||||||
@ -608,9 +610,6 @@ def voucher_mint_handler(cmd):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def foo_handler(cmd):
|
|
||||||
return os.popen('eth-info -p https://celo.grassecon.net').read()
|
|
||||||
|
|
||||||
|
|
||||||
parser = yacc.yacc()
|
parser = yacc.yacc()
|
||||||
|
|
||||||
@ -675,10 +674,10 @@ class WaitGet:
|
|||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ifc = None
|
ifc = None
|
||||||
o = Router()
|
o = Router()
|
||||||
o.register(CmdId.KEY_CREATE,foo_handler)
|
o.register(CmdId.KEY_CREATE,key_create_handler)
|
||||||
o.register(CmdId.VOUCHER_CREATE,foo_handler)
|
o.register(CmdId.VOUCHER_CREATE,voucher_create_handler)
|
||||||
o.register(CmdId.VOUCHER_MINT, foo_handler)
|
o.register(CmdId.VOUCHER_MINT, voucher_mint_handler)
|
||||||
o.register(CmdId.VOUCHER_TRANSFER,foo_handler)
|
o.register(CmdId.VOUCHER_TRANSFER,voucher_transfer_handler)
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
ifc = FileGet(o, sys.argv[1])
|
ifc = FileGet(o, sys.argv[1])
|
||||||
|
Loading…
Reference in New Issue
Block a user