Skip to content
Snippets Groups Projects
Commit 9ce17de7 authored by Andrea Orlati's avatar Andrea Orlati Committed by GitHub
Browse files

fix issue 334: (#335)

* fix issue 334: changed the python script that automatically reads the receivers status. The script is now suited to run
on top of master workstation. The target file is /service/receivers/receivers.log

* fix issue 334: modified according to the PR review.
parent 8fe80af5
No related branches found
No related tags found
No related merge requests found
...@@ -11,26 +11,32 @@ from Acspy.Util.ACSCorba import getManager ...@@ -11,26 +11,32 @@ from Acspy.Util.ACSCorba import getManager
process = os.path.basename(__file__) process = os.path.basename(__file__)
# Exit in case the user try to run the script on nuraghe-mng # Exit in case the user try to run the script on nuraghe-mng
if 'nuraghe-mng' in os.getenv('HOST'): #if 'nuraghe-mng' in os.getenv('HOST'):
print 'ERROR: you can not execute %s on this machine.' % process # print 'ERROR: you can not execute %s on this machine.' % process
print 'Please, read the SD manual!' # print 'Please, read the SD manual!'
sys.exit(0) # sys.exit(0)
# Exit in case the process is already running # Exit in case the process is already running
running_processes = os.popen("ps aux").read() running_processes = os.popen("ps aux").read()
counter = 0 counter = 0
for line in running_processes.split('\n'): for line in running_processes.split('\n'):
if 'python' in line and process in line: if 'python' in line and process in line:
if str(os.getpid()) in line.split(): # if str(os.getpid()) in line.split():
continue # continue
else: # else:
counter += 1 counter += 1
if counter > 1: if counter > 1:
print '%s already running, everything is OK' % process print '%s already running, everything is OK' % process
sys.exit(0) sys.exit(0)
LOGDIR = os.path.join(os.getenv('HOME'), 'logs', 'receivers') #LOGDIR = os.path.join('service','receivers')
LOGDIR ='/service/receivers'
FILENAME = os.path.join(LOGDIR,'receivers.log') FILENAME = os.path.join(LOGDIR,'receivers.log')
dirname=os.path.dirname(LOGDIR)
if not os.path.exists(dirname):
print 'ERROR: target folder does not exists, check %s' % LOGDIR
sys.exit(-1)
logging.basicConfig( logging.basicConfig(
filename=FILENAME, filename=FILENAME,
format='%(asctime)s\t%(message)s') format='%(asctime)s\t%(message)s')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment