Skip to content
Snippets Groups Projects
Commit 64ded3a6 authored by Graziano Scalamera's avatar Graziano Scalamera
Browse files

Fix scripts for python3

parent 55306b72
No related branches found
No related tags found
1 merge request!1Test ci
Pipeline #1601 passed with stages
in 2 minutes and 50 seconds
...@@ -93,11 +93,11 @@ if __name__ == "__main__": ...@@ -93,11 +93,11 @@ if __name__ == "__main__":
sys.exit(0) sys.exit(0)
if len(sys.argv) < 3: if len(sys.argv) < 3:
print 'Usage:', sys.argv[0], '"--device=alarm_device --load=alarm_rule | --file=filename"' print ('Usage:', sys.argv[0], ' --device=alarm_device --conf=alarm_rule | --file=filename')
print print ()
print 'Examples:' 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 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 all alarm rules from filename in alarm/test/1:', sys.argv[0], '--device=alarm/test/1 --file=alarms.txt' print ('\tcheck alarm rules from filename in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --file=alarms.txt')
sys.exit(-1) sys.exit(-1)
# EOF # EOF
...@@ -18,7 +18,6 @@ if __name__ == "__main__": ...@@ -18,7 +18,6 @@ if __name__ == "__main__":
wordpath = '([a-z0-9._\-\*/]*)' wordpath = '([a-z0-9._\-\*/]*)'
m = re.compile("--device=" + word + "/{0,1}" + word + "/{0,1}" + word).match(arg.lower()) m = re.compile("--device=" + word + "/{0,1}" + word + "/{0,1}" + word).match(arg.lower())
if m is not None: if m is not None:
#print m.groups()
domain = m.groups()[0] domain = m.groups()[0]
family = m.groups()[1] family = m.groups()[1]
member = m.groups()[2] member = m.groups()[2]
...@@ -32,8 +31,7 @@ if __name__ == "__main__": ...@@ -32,8 +31,7 @@ if __name__ == "__main__":
#formula = '([a-z0-9._,\*,\-,\|,\/,\",\s,\t]*)' #formula = '([a-z0-9._,\*,\-,\|,\/,\",\s,\t]*)'
formula = '(.*)' formula = '(.*)'
m = re.compile("--conf=" + formula).match(arg) m = re.compile("--conf=" + formula).match(arg)
if m is not None: if m is not None:
#print m.groups()
alarm_rule = m.groups()[0] alarm_rule = m.groups()[0]
Conf = True Conf = True
#m = re.compile("--prepare_state").match(arg.lower()) #m = re.compile("--prepare_state").match(arg.lower())
...@@ -41,7 +39,6 @@ if __name__ == "__main__": ...@@ -41,7 +39,6 @@ if __name__ == "__main__":
# PrepareState = True # PrepareState = True
m = re.compile("--file=" + wordpath).match(arg) m = re.compile("--file=" + wordpath).match(arg)
if m is not None: if m is not None:
#print m.groups()
file_name = m.groups()[0] file_name = m.groups()[0]
File = True File = True
...@@ -66,13 +63,10 @@ if __name__ == "__main__": ...@@ -66,13 +63,10 @@ if __name__ == "__main__":
elif File: elif File:
for line in open(file_name): for line in open(file_name):
line = line[0:-1] line = line[0:-1]
#print ('Loading: ', line)
try: try:
dev.command_inout('Load',line) dev.command_inout('Load',line)
#print '.............OK!'
time.sleep(0.1) time.sleep(0.1)
except (DevFailed,ConnectionFailed,EventSystemFailed) as e: except (DevFailed,ConnectionFailed,EventSystemFailed) as e:
#print ('...........ERROR!')
print (' ---> ERROR: ', e[0].desc) print (' ---> ERROR: ', e[0].desc)
time.sleep(2) time.sleep(2)
sys.exit(1) sys.exit(1)
...@@ -81,11 +75,11 @@ if __name__ == "__main__": ...@@ -81,11 +75,11 @@ if __name__ == "__main__":
#dev.command_inout('Load', sys.argv[1]) #dev.command_inout('Load', sys.argv[1])
if len(sys.argv) < 3: if len(sys.argv) < 3:
print 'Usage:', sys.argv[0], '"--device=alarm_device --load=alarm_rule | --file=filename"' print ('Usage:', sys.argv[0], ' --device=alarm_device --conf=alarm_rule | --file=filename')
print print ()
print 'Examples:' 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 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/test/1:', sys.argv[0], '--device=alarm/test/1 --file=alarms.txt' print ('\tload alarm rules from filename in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --file=alarms.txt')
sys.exit(-1) sys.exit(-1)
# EOF # EOF
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