Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 9 additions & 2 deletions mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ def __init__(self):
class MyTonCore():
def __init__(self):
self.walletsDir = None
self.dbFile = None
self.adnlAddr = None
self.tempDir = None
self.validatorWalletName = None
Expand All @@ -146,7 +147,6 @@ def __init__(self):
self.validatorConsole = ValidatorConsole()
self.fift = Fift()

local.dbLoad()
self.Refresh()
self.Init()
#end define
Expand All @@ -157,7 +157,14 @@ def Init(self):
#end define

def Refresh(self):
self.walletsDir = dir(local.buffer.get("myWorkDir") + "wallets")
if self.dbFile:
local.dbLoad(self.dbFile)
else:
local.dbLoad()

if not self.walletsDir:
self.walletsDir = dir(local.buffer.get("myWorkDir") + "wallets")

self.tempDir = local.buffer.get("myTempDir")

self.adnlAddr = local.db.get("adnlAddr")
Expand Down
30 changes: 28 additions & 2 deletions mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
from mypyconsole.mypyconsole import MyPyConsole
from mytoncore import *
import platform
import sys, getopt, os



local = MyPyClass(__file__)
console = MyPyConsole()
ton = MyTonCore()
# Must control: /var/ton-work/db/keyring/

def Init():
def Init(argv):
# Create user console
console.name = "MyTonCtrl"
console.AddItem("upgrade", RunUpdater, "Check and install MyTonCtrl updates")
Expand Down Expand Up @@ -54,6 +57,29 @@ def Init():

console.AddItem("test", Test, "")

# Process input parameters
opts, args = getopt.getopt(argv,"hc:w:",["config=","wallets="])
for opt, arg in opts:
if opt == '-h':
print ('mytonctrl.py -c <configfile> -w <wallets>')
sys.exit()
elif opt in ("-c", "--config"):
configfile = arg
if not os.access(configfile, os.R_OK):
print ("Configuration file " + configfile + " could not be opened")
sys.exit()

ton.dbFile = configfile
ton.Refresh()
elif opt in ("-w", "--wallets"):
wallets = arg
if not os.access(wallets, os.R_OK):
print ("Wallets path " + wallets + " could not be opened")
sys.exit()
elif not os.path.isdir(wallets):
print ("Wallets path " + wallets + " is not a directory")
sys.exit()
ton.walletsDir = wallets

local.db["config"]["logLevel"] = "debug"
local.db["config"]["isLocaldbSaving"] = True
Expand Down Expand Up @@ -702,6 +728,6 @@ def secondsToText(secs):
###

if __name__ == "__main__":
Init()
Init(sys.argv[1:])
console.Run()
#end if