work on cliui
This commit is contained in:
parent
9fd985ea49
commit
c142ab770a
@ -377,18 +377,21 @@ class Core:
|
|||||||
'''
|
'''
|
||||||
Add a command to the daemon queue, used by the communication daemon (communicator.py)
|
Add a command to the daemon queue, used by the communication daemon (communicator.py)
|
||||||
'''
|
'''
|
||||||
|
retData = True
|
||||||
# Intended to be used by the web server
|
# Intended to be used by the web server
|
||||||
date = self._utils.getEpoch()
|
date = self._utils.getEpoch()
|
||||||
conn = sqlite3.connect(self.queueDB)
|
conn = sqlite3.connect(self.queueDB)
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
t = (command, data, date)
|
t = (command, data, date)
|
||||||
|
try:
|
||||||
c.execute('INSERT INTO commands (command, data, date) VALUES(?, ?, ?)', t)
|
c.execute('INSERT INTO commands (command, data, date) VALUES(?, ?, ?)', t)
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
retData = False
|
||||||
events.event('queue_push', data = {'command': command, 'data': data}, onionr = None)
|
events.event('queue_push', data = {'command': command, 'data': data}, onionr = None)
|
||||||
|
|
||||||
return
|
return retData
|
||||||
|
|
||||||
def clearDaemonQueue(self):
|
def clearDaemonQueue(self):
|
||||||
'''
|
'''
|
||||||
|
@ -47,6 +47,9 @@ class OnionrCLIUI:
|
|||||||
isOnline = "No"
|
isOnline = "No"
|
||||||
firstRun = True
|
firstRun = True
|
||||||
|
|
||||||
|
if self.myCore._utils.localCommand('ping') == 'pong':
|
||||||
|
firstRun = False
|
||||||
|
|
||||||
while showMenu:
|
while showMenu:
|
||||||
if firstRun:
|
if firstRun:
|
||||||
print("please wait while Onionr starts...")
|
print("please wait while Onionr starts...")
|
||||||
@ -56,14 +59,18 @@ class OnionrCLIUI:
|
|||||||
|
|
||||||
if self.myCore._utils.localCommand('ping') == 'pong':
|
if self.myCore._utils.localCommand('ping') == 'pong':
|
||||||
isOnline = "Yes"
|
isOnline = "Yes"
|
||||||
print('''Online Status: ''' + isOnline + '''
|
else:
|
||||||
|
isOnline = "No"
|
||||||
|
|
||||||
|
print('''
|
||||||
|
Daemon Running: ''' + isOnline + '''
|
||||||
|
|
||||||
1. Flow (Anonymous public chat, use at your own risk)
|
1. Flow (Anonymous public chat, use at your own risk)
|
||||||
2. Mail (Secure email-like service)
|
2. Mail (Secure email-like service)
|
||||||
3. File Sharing
|
3. File Sharing
|
||||||
4. User Settings
|
4. User Settings
|
||||||
5. Start/Stop Daemon
|
5. Start/Stop Daemon
|
||||||
6. Quit
|
6. Quit (Does not shutdown daemon)
|
||||||
''')
|
''')
|
||||||
try:
|
try:
|
||||||
choice = input(">").strip().lower()
|
choice = input(">").strip().lower()
|
||||||
@ -74,6 +81,8 @@ class OnionrCLIUI:
|
|||||||
self.subCommand("flow")
|
self.subCommand("flow")
|
||||||
elif choice in ("2", "mail"):
|
elif choice in ("2", "mail"):
|
||||||
self.subCommand("mail")
|
self.subCommand("mail")
|
||||||
|
elif choice in ("3", "file sharing", "file"):
|
||||||
|
print("Not supported yet")
|
||||||
elif choice in ("4", "user settings", "settings"):
|
elif choice in ("4", "user settings", "settings"):
|
||||||
try:
|
try:
|
||||||
self.setName()
|
self.setName()
|
||||||
@ -84,6 +93,9 @@ class OnionrCLIUI:
|
|||||||
print("Onionr daemon will shutdown...")
|
print("Onionr daemon will shutdown...")
|
||||||
#self.myCore._utils.localCommand("shutdown")
|
#self.myCore._utils.localCommand("shutdown")
|
||||||
self.myCore.daemonQueueAdd('shutdown')
|
self.myCore.daemonQueueAdd('shutdown')
|
||||||
|
while self.myCore._utils.localCommand('ping') == 'pong':
|
||||||
|
self.myCore.daemonQueueAdd('shutdown')
|
||||||
|
time.sleep(8)
|
||||||
else:
|
else:
|
||||||
print("Starting Daemon...")
|
print("Starting Daemon...")
|
||||||
subprocess.Popen(["./onionr.py", "start"], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
subprocess.Popen(["./onionr.py", "start"], stdin=subprocess.PIPE, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
|
||||||
@ -96,8 +108,12 @@ class OnionrCLIUI:
|
|||||||
return
|
return
|
||||||
|
|
||||||
def setName(self):
|
def setName(self):
|
||||||
|
try:
|
||||||
name = input("Enter your name: ")
|
name = input("Enter your name: ")
|
||||||
|
if name != "":
|
||||||
self.myCore.insertBlock("userInfo-" + str(uuid.uuid1()), sign=True, header='userInfo', meta={'name': name})
|
self.myCore.insertBlock("userInfo-" + str(uuid.uuid1()), sign=True, header='userInfo', meta={'name': name})
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
return
|
return
|
||||||
|
|
||||||
def on_init(api, data = None):
|
def on_init(api, data = None):
|
||||||
|
Loading…
Reference in New Issue
Block a user