--- a/Beremiz_service.py Wed Aug 20 10:10:34 2008 +0200
+++ b/Beremiz_service.py Thu Aug 21 10:35:12 2008 +0200
@@ -25,31 +25,45 @@
import os, sys, getopt, socket
- print "\nUsage of Beremiz PLC execution service :"
- print "\n %s [PLC path]\n"%sys.argv[0]
+Usage of Beremiz PLC execution service :\n +%s {[-a ip] [-d path] [-p port]|-h|--help} + -a, --address - authorized ip to connect (x.x.x.x) + -d, --directory path - set the working directory + -p, --port port number - set the port number + -h, --help - print this help text and quit - opts, args = getopt.getopt(sys.argv[1:], "h", ["help"])
-except getopt.GetoptError:
+ opts, args = getopt.getopt(sys.argv[1:], "a:d:p:h", ["directory=", "port=", "help"]) +except getopt.GetoptError, err: # print help information and exit:
+ print str(err) # will print something like "option -a not recognized" +WorkingDir = os.getcwd() if o in ("-h", "--help"):
- WorkingDir = os.getcwd()
+ elif o in ("-a", "--address"): + #ip = socket.inet_aton(a) + if len(a.split(".")) == 4 or a == "localhost": + elif o in ("-d", "--directory"): + # overwrite default working directory + elif o in ("-p", "--port"): + # port: port that the service runs on from runtime import PLCObject, ServicePublisher
@@ -75,9 +89,6 @@
return socket.gethostbyname(socket.gethostname())
-# port: port that the service runs on
# properties: dictionary of properties (or a string holding the bytes for the text field)
serviceproperties = {'description':'Remote control for PLC'}