Browse Source

Fixes long opt parsing as '--port' and '--bind-to' did not expect values.

Siminlar to the syntax for short options, for which a colon (':') indicates
that the option must be followed by an parameter, for long options the getopt
parser expects an equal-sign ('=') as a suffix in the specification of a para-
meter. Otherwise the value of 'arg' of a corresponding 'opt' is a zero-length
string. In this case, a call to 'int(arg)' will fail with an exception.

Appending '=' to the options 'port' and 'bind-to' resolves this issue.

Signed-off-by: Stefan Laudemann <thisco@zitmail.uni-paderborn.de>
Stefan Laudemann 9 years ago
parent
commit
ecb9adae12
1 changed files with 2 additions and 2 deletions
  1. 2 2
      server.py

+ 2 - 2
server.py

@@ -60,7 +60,7 @@ def server(port, bindTo):
 
 if __name__ == '__main__':
 	try: 
-		opts, args = getopt.getopt(sys.argv[1:], "dp:b:", ["do-not-daemonize", "port", "bind-to"])
+		opts, args = getopt.getopt(sys.argv[1:], "dp:b:", ["do-not-daemonize", "port=", "bind-to="])
 	except:
 		print ('Unrecognized option')
 		sys.exit(2)
@@ -79,7 +79,7 @@ if __name__ == '__main__':
 				socket.inet_aton(arg)
 				bindTo = str(arg)
 			except:
-				print('Invalid IPAdress. Using default ::')
+				print('Listening IP address is either invalid or unset. Using default ::')
 		else:
 			assert False