Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Do not try to cast NoneType to int #432

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,20 +874,20 @@ def GetConfig32(self):
self.local.add_log("start GetConfig32 function", "debug")
config32 = Dict()
result = self.liteClient.Run("getconfig 32")
config32["totalValidators"] = int(parse(result, "total:", ' '))
config32["mainValidators"] = int(parse(result, "main:", ' '))
config32["startWorkTime"] = int(parse(result, "utime_since:", ' '))
config32["endWorkTime"] = int(parse(result, "utime_until:", ' '))
config32["totalValidators"] = int(parse(result, "total:", ' ') or 0)
config32["mainValidators"] = int(parse(result, "main:", ' ') or 0)
config32["startWorkTime"] = int(parse(result, "utime_since:", ' ') or 0)
config32["endWorkTime"] = int(parse(result, "utime_until:", ' ') or 0)
lines = result.split('\n')
validators = list()
for line in lines:
if "public_key:" in line:
validatorAdnlAddr = parse(line, "adnl_addr:x", ')')
pubkey = parse(line, "pubkey:x", ')')
try:
validatorWeight = int(parse(line, "weight:", ' '))
validatorWeight = int(parse(line, "weight:", ' ') or 0)
except ValueError:
validatorWeight = int(parse(line, "weight:", ')'))
validatorWeight = int(parse(line, "weight:", ')') or 0)
buff = Dict()
buff["adnlAddr"] = validatorAdnlAddr
buff["pubkey"] = pubkey
Expand All @@ -911,21 +911,21 @@ def GetConfig34(self):
self.local.add_log("start GetConfig34 function", "debug")
config34 = Dict()
result = self.liteClient.Run("getconfig 34")
config34["totalValidators"] = int(parse(result, "total:", ' '))
config34["mainValidators"] = int(parse(result, "main:", ' '))
config34["startWorkTime"] = int(parse(result, "utime_since:", ' '))
config34["endWorkTime"] = int(parse(result, "utime_until:", ' '))
config34["totalWeight"] = int(parse(result, "total_weight:", ' '))
config34["totalValidators"] = int(parse(result, "total:", ' ') or 0)
config34["mainValidators"] = int(parse(result, "main:", ' ') or 0)
config34["startWorkTime"] = int(parse(result, "utime_since:", ' ') or 0)
config34["endWorkTime"] = int(parse(result, "utime_until:", ' ') or 0)
config34["totalWeight"] = int(parse(result, "total_weight:", ' ') or 0)
lines = result.split('\n')
validators = list()
for line in lines:
if "public_key:" in line:
validatorAdnlAddr = parse(line, "adnl_addr:x", ')')
pubkey = parse(line, "pubkey:x", ')')
try:
validatorWeight = int(parse(line, "weight:", ' '))
validatorWeight = int(parse(line, "weight:", ' ') or 0)
except ValueError:
validatorWeight = int(parse(line, "weight:", ')'))
validatorWeight = int(parse(line, "weight:", ')') or 0)
buff = Dict()
buff["adnlAddr"] = validatorAdnlAddr
buff["pubkey"] = pubkey
Expand All @@ -950,9 +950,9 @@ def GetConfig36(self):
config36 = dict()
try:
result = self.liteClient.Run("getconfig 36")
config36["totalValidators"] = int(parse(result, "total:", ' '))
config36["startWorkTime"] = int(parse(result, "utime_since:", ' '))
config36["endWorkTime"] = int(parse(result, "utime_until:", ' '))
config36["totalValidators"] = int(parse(result, "total:", ' ') or 0)
config36["startWorkTime"] = int(parse(result, "utime_since:", ' ') or 0)
config36["endWorkTime"] = int(parse(result, "utime_until:", ' ') or 0)
lines = result.split('\n')
validators = list()
for line in lines:
Expand Down