Commit 64ded3a6 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Fix scripts for python3

parent 55306b72
Pipeline #1601 passed with stages
in 2 minutes and 50 seconds
......@@ -93,11 +93,11 @@ if __name__ == "__main__":
sys.exit(0)
if len(sys.argv) < 3:
print 'Usage:', sys.argv[0], '"--device=alarm_device --load=alarm_rule | --file=filename"'
print
print 'Examples:'
print '\check one alarm_rule in alarm/test/1:', sys.argv[0], '--device=alarm/test/1 --load=\"al/al/al/al (ev/ev/ev/ev != FAULT) gr_ps fault \\\"PS Fault\\\"\"'
print '\tcheck all alarm rules from filename in alarm/test/1:', sys.argv[0], '--device=alarm/test/1 --file=alarms.txt'
print ('Usage:', sys.argv[0], ' --device=alarm_device --conf=alarm_rule | --file=filename')
print ()
print ('Examples:')
print ('\tcheck one alarm_rule in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --conf=\"tag=test0;formula=(alarm/test/01/condition == 1);on_delay=0;off_delay=0;priority=high;shlvd_time=0;group=gr_test;message=Test alarm;url=;on_command=;off_command=;enabled=1\"')
print ('\tcheck alarm rules from filename in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --file=alarms.txt')
sys.exit(-1)
# EOF
......@@ -18,7 +18,6 @@ if __name__ == "__main__":
wordpath = '([a-z0-9._\-\*/]*)'
m = re.compile("--device=" + word + "/{0,1}" + word + "/{0,1}" + word).match(arg.lower())
if m is not None:
#print m.groups()
domain = m.groups()[0]
family = m.groups()[1]
member = m.groups()[2]
......@@ -32,8 +31,7 @@ if __name__ == "__main__":
#formula = '([a-z0-9._,\*,\-,\|,\/,\",\s,\t]*)'
formula = '(.*)'
m = re.compile("--conf=" + formula).match(arg)
if m is not None:
#print m.groups()
if m is not None:
alarm_rule = m.groups()[0]
Conf = True
#m = re.compile("--prepare_state").match(arg.lower())
......@@ -41,7 +39,6 @@ if __name__ == "__main__":
# PrepareState = True
m = re.compile("--file=" + wordpath).match(arg)
if m is not None:
#print m.groups()
file_name = m.groups()[0]
File = True
......@@ -66,13 +63,10 @@ if __name__ == "__main__":
elif File:
for line in open(file_name):
line = line[0:-1]
#print ('Loading: ', line)
try:
dev.command_inout('Load',line)
#print '.............OK!'
time.sleep(0.1)
except (DevFailed,ConnectionFailed,EventSystemFailed) as e:
#print ('...........ERROR!')
print (' ---> ERROR: ', e[0].desc)
time.sleep(2)
sys.exit(1)
......@@ -81,11 +75,11 @@ if __name__ == "__main__":
#dev.command_inout('Load', sys.argv[1])
if len(sys.argv) < 3:
print 'Usage:', sys.argv[0], '"--device=alarm_device --load=alarm_rule | --file=filename"'
print
print 'Examples:'
print '\tload one alarm_rule in alarm/test/1:', sys.argv[0], '--device=alarm/test/1 --load=\"al/al/al/al (ev/ev/ev/ev != FAULT) gr_ps fault \\\"PS Fault\\\"\"'
print '\tload alarm rules from filename in alarm/test/1:', sys.argv[0], '--device=alarm/test/1 --file=alarms.txt'
print ('Usage:', sys.argv[0], ' --device=alarm_device --conf=alarm_rule | --file=filename')
print ()
print ('Examples:')
print ('\tload one alarm_rule in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --conf=\"tag=test0;formula=(alarm/test/01/condition == 1);on_delay=0;off_delay=0;priority=high;shlvd_time=0;group=gr_test;message=Test alarm;url=;on_command=;off_command=;enabled=1\"')
print ('\tload alarm rules from filename in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --file=alarms.txt')
sys.exit(-1)
# EOF
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment