# HG changeset patch # User etisserant # Date 1219331924 -7200 # Node ID ca3bfcf611927cb9ca34a9731c32ac04f79d0004 # Parent 08dc3d064cb56238be1efb88a2f9ab1cb7c63529 Fixed oddities in arguments/options parsing and passing to plugins initialization... diff -r 08dc3d064cb5 -r ca3bfcf61192 Beremiz_service.py --- a/Beremiz_service.py Thu Aug 21 17:17:36 2008 +0200 +++ b/Beremiz_service.py Thu Aug 21 17:18:44 2008 +0200 @@ -35,7 +35,7 @@ """%sys.argv[0] try: - opts, args = getopt.getopt(sys.argv[1:], "a:d:p:h", ["directory=", "port=", "help"]) + opts, args = getopt.getopt(sys.argv[1:], "a:p:h", ["help"]) except getopt.GetoptError, err: # print help information and exit: print str(err) # will print something like "option -a not recognized" @@ -43,10 +43,9 @@ sys.exit(2) # default values -WorkingDir = os.getcwd() ip = "" port = 3000 - +print opts for o, a in opts: if o in ("-h", "--help"): usage() @@ -54,9 +53,6 @@ elif o in ("-a", "--address"): if len(a.split(".")) == 4 or a == "localhost": ip = a - elif o in ("-d", "--directory"): - # overwrite default working directory - WorkingDir = a elif o in ("-p", "--port"): # port: port that the service runs on port = int(a) @@ -64,6 +60,17 @@ usage() sys.exit() +if len(args) > 1: + usage() + sys.exit() +elif len(args) == 1: + WorkingDir = args[0] +elif len(args) == 0: + WorkingDir = os.getcwd() +else: + usage() + sys.exit() + from runtime import PLCObject, ServicePublisher import Pyro.core as pyro @@ -93,7 +100,7 @@ pyro.initServer() daemon=pyro.Daemon(host=ip, port=port) -uri = daemon.connect(PLCObject(WorkingDir, daemon),"PLCObject") +uri = daemon.connect(PLCObject(WorkingDir, daemon, args),"PLCObject") print "The daemon runs on port :",daemon.port print "The object's uri is :",uri