Sped up + fixed statistics table command using psutil, removed checkcommunicator as a result
parent
a5b6805b5f
commit
196d02a751
|
@ -25,8 +25,6 @@ site_cache = home + 'onionr-sites.txt'
|
||||||
tor_hs_loc = home + 'hs/'
|
tor_hs_loc = home + 'hs/'
|
||||||
tor_hs_address_file = home + 'hs/hostname'
|
tor_hs_address_file = home + 'hs/hostname'
|
||||||
|
|
||||||
run_check_file = home + '.runcheck'
|
|
||||||
|
|
||||||
data_nonce_file = home + 'block-nonces.dat'
|
data_nonce_file = home + 'block-nonces.dat'
|
||||||
|
|
||||||
keys_file = home + 'keys.txt'
|
keys_file = home + 'keys.txt'
|
||||||
|
|
|
@ -134,11 +134,6 @@ def daemon():
|
||||||
logger.error("Tor is not present in system path or Onionr directory",
|
logger.error("Tor is not present in system path or Onionr directory",
|
||||||
terminal=True)
|
terminal=True)
|
||||||
|
|
||||||
# remove runcheck if it exists
|
|
||||||
if os.path.isfile(filepaths.run_check_file):
|
|
||||||
logger.debug('Runcheck file found on daemon start, deleting.')
|
|
||||||
os.remove(filepaths.run_check_file)
|
|
||||||
|
|
||||||
# Create shared objects
|
# Create shared objects
|
||||||
|
|
||||||
shared_state = toomanyobjs.TooMany()
|
shared_state = toomanyobjs.TooMany()
|
||||||
|
|
|
@ -4,17 +4,16 @@ This module defines commands to show stats/details about the local node
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
import logger
|
import logger
|
||||||
from onionrblocks import onionrblockapi
|
|
||||||
from onionrblocks import onionrblacklist
|
from onionrblocks import onionrblacklist
|
||||||
from onionrutils import checkcommunicator, mnemonickeys
|
from onionrutils import mnemonickeys
|
||||||
from utils import sizeutils, gethostname, getconsolewidth, identifyhome
|
from utils import sizeutils, gethostname, getconsolewidth, identifyhome
|
||||||
from coredb import blockmetadb, keydb
|
from coredb import blockmetadb, keydb
|
||||||
import onionrcrypto
|
import onionrcrypto
|
||||||
import config
|
import config
|
||||||
from etc import onionrvalues
|
from etc import onionrvalues
|
||||||
|
from filepaths import lock_file
|
||||||
|
|
||||||
check_communicator = checkcommunicator.is_communicator_running
|
import psutil
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -31,6 +30,15 @@ check_communicator = checkcommunicator.is_communicator_running
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def _is_running():
|
||||||
|
script = onionrvalues.SCRIPT_NAME
|
||||||
|
if os.path.isfile(lock_file):
|
||||||
|
for process in psutil.process_iter():
|
||||||
|
if process.name() == script:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def show_stats():
|
def show_stats():
|
||||||
"""Print/log statistic info about our Onionr install."""
|
"""Print/log statistic info about our Onionr install."""
|
||||||
try:
|
try:
|
||||||
|
@ -41,10 +49,12 @@ def show_stats():
|
||||||
|
|
||||||
messages = {
|
messages = {
|
||||||
# info about local client
|
# info about local client
|
||||||
|
|
||||||
|
# This line is inaccurate if dev mode is enabled
|
||||||
'Onionr Daemon Status':
|
'Onionr Daemon Status':
|
||||||
((logger.colors.fg.green + 'Online')
|
((logger.colors.fg.green + 'Online') \
|
||||||
if check_communicator(timeout=9)
|
if _is_running() \
|
||||||
else logger.colors.fg.red + 'Offline'),
|
else logger.colors.fg.red + 'Offline'),
|
||||||
|
|
||||||
# file and folder size stats
|
# file and folder size stats
|
||||||
'div1': True, # this creates a solid line across the screen, a div
|
'div1': True, # this creates a solid line across the screen, a div
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
'''
|
|
||||||
Onionr - Private P2P Communication
|
|
||||||
|
|
||||||
Check if the communicator is running
|
|
||||||
'''
|
|
||||||
'''
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
'''
|
|
||||||
import time, os
|
|
||||||
import filepaths
|
|
||||||
def is_communicator_running(timeout = 5, interval = 0.1):
|
|
||||||
try:
|
|
||||||
runcheck_file = filepaths.run_check_file
|
|
||||||
|
|
||||||
if not os.path.isfile(runcheck_file):
|
|
||||||
open(runcheck_file, 'w+').close()
|
|
||||||
|
|
||||||
starttime = time.time()
|
|
||||||
|
|
||||||
while True:
|
|
||||||
time.sleep(interval)
|
|
||||||
|
|
||||||
if not os.path.isfile(runcheck_file):
|
|
||||||
return True
|
|
||||||
elif time.time() - starttime >= timeout:
|
|
||||||
return False
|
|
||||||
except:
|
|
||||||
return False
|
|
Loading…
Reference in New Issue