work on cliui

This commit is contained in:
Kevin Froman 2018-09-01 21:59:03 -05:00
parent 9fd985ea49
commit c142ab770a
2 changed files with 28 additions and 9 deletions

View File

@ -377,18 +377,21 @@ class Core:
'''
Add a command to the daemon queue, used by the communication daemon (communicator.py)
'''
retData = True
# Intended to be used by the web server
date = self._utils.getEpoch()
conn = sqlite3.connect(self.queueDB)
c = conn.cursor()
t = (command, data, date)
try:
c.execute('INSERT INTO commands (command, data, date) VALUES(?, ?, ?)', t)
conn.commit()
conn.close()
except sqlite3.OperationalError:
retData = False
events.event('queue_push', data = {'command': command, 'data': data}, onionr = None)
return
return retData
def clearDaemonQueue(self):
'''

View File

@ -47,6 +47,9 @@ class OnionrCLIUI:
isOnline = "No"
firstRun = True
if self.myCore._utils.localCommand('ping') == 'pong':
firstRun = False
while showMenu:
if firstRun:
print("please wait while Onionr starts...")
@ -56,14 +59,18 @@ class OnionrCLIUI:
if self.myCore._utils.localCommand('ping') == 'pong':
isOnline = "Yes"
print('''Online Status: ''' + isOnline + '''
else:
isOnline = "No"
print('''
Daemon Running: ''' + isOnline + '''
1. Flow (Anonymous public chat, use at your own risk)
2. Mail (Secure email-like service)
3. File Sharing
4. User Settings
5. Start/Stop Daemon
6. Quit
6. Quit (Does not shutdown daemon)
''')
try:
choice = input(">").strip().lower()
@ -74,6 +81,8 @@ class OnionrCLIUI:
self.subCommand("flow")
elif choice in ("2", "mail"):
self.subCommand("mail")
elif choice in ("3", "file sharing", "file"):
print("Not supported yet")
elif choice in ("4", "user settings", "settings"):
try:
self.setName()
@ -84,6 +93,9 @@ class OnionrCLIUI:
print("Onionr daemon will shutdown...")
#self.myCore._utils.localCommand("shutdown")
self.myCore.daemonQueueAdd('shutdown')
while self.myCore._utils.localCommand('ping') == 'pong':
self.myCore.daemonQueueAdd('shutdown')
time.sleep(8)
else:
print("Starting Daemon...")
subprocess.Popen(["./onionr.py", "start"], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
@ -96,8 +108,12 @@ class OnionrCLIUI:
return
def setName(self):
try:
name = input("Enter your name: ")
if name != "":
self.myCore.insertBlock("userInfo-" + str(uuid.uuid1()), sign=True, header='userInfo', meta={'name': name})
except KeyboardInterrupt:
pass
return
def on_init(api, data = None):