Add status check function

master
Arinerron 2018-05-01 23:22:40 -07:00
parent 7b7c4e01cb
commit c144bc40b3
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
3 changed files with 30 additions and 7 deletions

View File

@ -111,6 +111,10 @@ class OnionrCommunicate:
if announceAttemptCount >= announceAttempts:
logger.warn('Unable to announce to ' + command[1])
break
elif command[0] == 'runCheck':
logger.info('Status check; looks good.')
open('data/.runcheck', 'w+').close()
break
apiRunningCheckCount += 1
# check if local API is up
if apiRunningCheckCount > apiRunningCheckRate:

View File

@ -99,17 +99,17 @@ def commandInstallPlugin():
return True
elif valid_hash and real_block:
blockhash = str(pkobh)
logger.debug('Using block ' + blockhash + '...')
logger.debug('Using block %s...' % blockhash)
elif valid_key and not real_key:
logger.error('Public key not found. Try adding the node by address manually, if possible.')
logger.debug('Is valid key, but the key is not a known one.')
elif valid_key and real_key:
publickey = str(pkobh)
logger.debug('Using public key ' + publickey + '...')
logger.debug('Using public key %s...' % publickey)
saveKey(pluginname, pkobh)
else:
logger.error('Unknown data \"' + str(pkobh) + '\"; must be public key or block hash.')
logger.error('Unknown data "%s"; must be public key or block hash.' % str(pkobh))
return
else:
help()

View File

@ -399,3 +399,22 @@ class OnionrUtils:
if row[0] != '':
retData = row[0]
return retData
def isCommunicatorRunning(timeout = 5, interval = 0.1):
runcheck_file = 'data/.runcheck'
if os.path.isfile(runcheck_file):
os.remove(runcheck_file)
logger.debug('%s file appears to have existed before the run check.' % runcheck_file, timestamp = False)
self._core.daemonQueueAdd('runCheck')
starttime = time.time()
while True:
time.sleep(interval)
if os.path.isfile(runcheck_file):
os.remove(runcheck_file)
return True
elif starttime - time.time() >= timeout:
return False