Commit 154e7563 authored by Fabio Vitello's avatar Fabio Vitello
Browse files

#595 raise an exception if arguments are not numeric

parent 163f0a7f
Loading
Loading
Loading
Loading
+48 −36
Original line number Diff line number Diff line
@@ -77,6 +77,8 @@ def main(argv):
	
	commandstr=[]
	
	
	try:
		if int(argv[0]) not in range (1,3):
			sys.stderr.write(str('error Enter a valid input channel number'))
			userLogger.logError("Enter a valid input channel number")
@@ -101,6 +103,12 @@ def main(argv):
	
		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 int(selectedPol) == -1 and float(selectedAtt)==-1:
		commandstr=[selectedInput,"att"+argv[0]]
@@ -115,11 +123,13 @@ def main(argv):
		commandstr=[selectedInput+","+selectedPol, "att"+argv[0]+","+selectedAtt]

	answerstr = ""
	
	for i in range(0,len(commandstr)):
		userLogger.logNotice("IFDist setup according to %s command"%(commandstr[i]))

		answer=send_command(ip,port, commandstr[i])
		answerstr+= str(answer)
        
		if answer=="Fail":
			newEx = ComponentErrorsImpl.SocketErrorExImpl()
			add_user_message(newEx,"Unable to communicate to IFDist")
@@ -138,7 +148,9 @@ def main(argv):
		else:
			userLogger.logNotice( "Answer: %s"%(answer))
	
	sys.stderr.write(str(answerstr))
	
	print >> sys.stderr, answerstr.replace(","," ")


if __name__=="__main__":
   main(sys.argv[1:])