Skip to content
Snippets Groups Projects
Commit 154e7563 authored by Fabio Vitello's avatar Fabio Vitello
Browse files

#595 raise an exception if arguments are not numeric

parent 163f0a7f
Branches
Tags
No related merge requests found
...@@ -77,6 +77,8 @@ def main(argv): ...@@ -77,6 +77,8 @@ def main(argv):
commandstr=[] commandstr=[]
try:
if int(argv[0]) not in range (1,3): if int(argv[0]) not in range (1,3):
sys.stderr.write(str('error Enter a valid input channel number')) sys.stderr.write(str('error Enter a valid input channel number'))
userLogger.logError("Enter a valid input channel number") userLogger.logError("Enter a valid input channel number")
...@@ -101,6 +103,12 @@ def main(argv): ...@@ -101,6 +103,12 @@ def main(argv):
selectedAtt=argv[2] selectedAtt=argv[2]
except ValueError:
sys.stderr.write(str('error Enter a numeric value'))
userLogger.logError("Enter a numeric value")
simpleClient.disconnect()
sys.exit(1)
#if selectedPol and selectedAtt are -1 print information on current pol and att #if selectedPol and selectedAtt are -1 print information on current pol and att
if int(selectedPol) == -1 and float(selectedAtt)==-1: if int(selectedPol) == -1 and float(selectedAtt)==-1:
commandstr=[selectedInput,"att"+argv[0]] commandstr=[selectedInput,"att"+argv[0]]
...@@ -115,11 +123,13 @@ def main(argv): ...@@ -115,11 +123,13 @@ def main(argv):
commandstr=[selectedInput+","+selectedPol, "att"+argv[0]+","+selectedAtt] commandstr=[selectedInput+","+selectedPol, "att"+argv[0]+","+selectedAtt]
answerstr = "" answerstr = ""
for i in range(0,len(commandstr)): for i in range(0,len(commandstr)):
userLogger.logNotice("IFDist setup according to %s command"%(commandstr[i])) userLogger.logNotice("IFDist setup according to %s command"%(commandstr[i]))
answer=send_command(ip,port, commandstr[i]) answer=send_command(ip,port, commandstr[i])
answerstr+= str(answer) answerstr+= str(answer)
if answer=="Fail": if answer=="Fail":
newEx = ComponentErrorsImpl.SocketErrorExImpl() newEx = ComponentErrorsImpl.SocketErrorExImpl()
add_user_message(newEx,"Unable to communicate to IFDist") add_user_message(newEx,"Unable to communicate to IFDist")
...@@ -138,7 +148,9 @@ def main(argv): ...@@ -138,7 +148,9 @@ def main(argv):
else: else:
userLogger.logNotice( "Answer: %s"%(answer)) userLogger.logNotice( "Answer: %s"%(answer))
sys.stderr.write(str(answerstr))
print >> sys.stderr, answerstr.replace(","," ")
if __name__=="__main__": if __name__=="__main__":
main(sys.argv[1:]) main(sys.argv[1:])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment