Browse Source

Changes negated parameter logic of '--do-not-daemonize'.

For humans it is typically easier to think in "positive logic", meaning that
in case someone wants include a feature, it is easier to think of it as add-
ing something (e.g. to a command line). Inverting this principle causes users
to either make mistakes or at least would require higher amount of thinking.

As positive logic appears to be more natural, the parameter "--do-not-daemon-
ize" is changed to "--daemonize". Moreover, this is consistent with a lot of
other tools around in the wild, and is thus easier to use.

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

+ 8 - 8
server.py

@@ -61,18 +61,18 @@ def serve(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:", ["daemonize", "port=", "bind-to="])
 	except:
 		print ('Unrecognized option')
 		sys.exit(2)
 
-	daemonize = True
+	daemonize = False
 	port = 1337
 	bindTo = None
 
 	for opt, arg in opts:
-		if opt in ("-d", "--do-not-daemonize"):
-			daemonize = False
+		if opt in ("-d", "--daemonize"):
+			daemonize = True
 		elif opt in ("-p", "--port"):
 			port = int(arg)
 		elif opt in ("-b", "--bind-to"):
@@ -89,9 +89,9 @@ if __name__ == '__main__':
 		print("Listening IP address is unset. Using default ::")
 		bindTo = "::"
 
-	if daemonize == False:
-		serve(port, bindTo)
-	else:
+	if daemonize == True:
 		daemonContext = daemon.DaemonContext(pidfile = daemon.pidlockfile.PIDLockFile("/var/run/ffpb-debugserver.pid"))
 		with daemonContext:
-			serve(port, bindTo)
+			serve(port, bindTo)		
+	else:
+		serve(port, bindTo)