Changeset 123
- Timestamp:
- 04/29/06 11:44:31 (19 years ago)
- Location:
- pykoticon/trunk/bin
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykoticon/trunk/bin/pykoticon
r122 r123 41 41 import xmlrpclib 42 42 import SimpleXMLRPCServer 43 43 try : 44 import optparse 45 except ImportError : 46 sys.stderr.write("You need Python v2.3 or higher for PyKotIcon to work.\nAborted.\n") 47 sys.exit(-1) 44 48 45 49 if sys.platform == "win32" : … … 88 92 """My own server class.""" 89 93 allow_reuse_address = True 90 def __init__(self, frame, printserver, localport, debug=False) :94 def __init__(self, frame, options, arguments) : 91 95 SimpleXMLRPCServer.SimpleXMLRPCServer.__init__(self, \ 92 ('0.0.0.0', localport), \96 ('0.0.0.0', options.port), \ 93 97 SimpleXMLRPCServer.SimpleXMLRPCRequestHandler, \ 94 debug) 95 self.printServer = printserver 98 options.debug) 96 99 self.frame = frame 97 self.debug = debug 100 self.debug = options.debug 101 self.printServers = [ socket.gethostbyname(arg) for arg in arguments ] 98 102 loop = threading.Thread(target=self.mainloop) 99 103 loop.start() … … 145 149 """Ensures that requests which don't come from the print server are rejected.""" 146 150 (client, port) = client_address 147 if socket.gethostbyname(self.printServer) == client:151 if client in self.printServers : 148 152 self.logDebug("%s accepted." % client) 149 153 return True … … 329 333 pass 330 334 331 def postInit(self, charset, printserver, localport) :335 def postInit(self, charset, options, arguments) : 332 336 """Starts the XML-RPC server.""" 333 337 self.quitEvent = threading.Event() 334 338 self.charset = charset 335 self.port = localport336 self.server = MyXMLRPCServer(self, printserver, localport)339 self.port = options.port 340 self.server = MyXMLRPCServer(self, options, arguments) 337 341 338 342 def UTF8ToUserCharset(self, text) : … … 379 383 return True 380 384 381 def postInit(self, charset, printserver, localport) :385 def postInit(self, charset, options, arguments) : 382 386 """Continues processing.""" 383 self.frame.postInit(charset, printserver, localport)384 385 386 def main( printserver, localport):387 self.frame.postInit(charset, options, arguments) 388 389 390 def main() : 387 391 """Program's entry point.""" 388 392 try : … … 412 416 charset = os.environ.get("CHARSET") or localecharset or "ISO-8859-15" 413 417 414 app = PyKotIconApp() 415 try : 416 localport = int(localport) 417 except (TypeError, ValueError) : 418 raise ValueError, "Invalid TCP port parameter %s\n" % localport 419 app.postInit(charset, printserver, localport) 420 app.MainLoop() 418 parser = optparse.OptionParser(usage="usage : pykoticon [options] server1 [server2 ...]") 419 parser.add_option("-v", "--version", 420 action="store_true", 421 dest="version", 422 help=_("show PyKotIcon's version number and exit")) 423 parser.add_option("-d", "--debug", 424 action="store_true", 425 dest="debug", 426 help=_("activate debug mode")) 427 parser.add_option("-p", "--port", 428 type="int", 429 default=7654, 430 dest="port", 431 help=_("the TCP port PyKotIcon will listen to, default is %default")) 432 parser.add_option("-q", "--allowquit", 433 action="store_true", 434 dest="allowquit", 435 help=_("allow the end user to close the application")) 436 (options, arguments) = parser.parse_args() 437 if options.version : 438 print "PyKotIcon v%(__version__)s" % globals() 439 else : 440 app = PyKotIconApp() 441 app.postInit(charset, options, arguments) 442 app.MainLoop() 421 443 422 444 … … 433 455 434 456 if __name__ == '__main__': 435 if len(sys.argv) >= 2 : 436 arg = sys.argv[1] 437 if arg in ("-v", "--version") : 438 print __version__ 439 elif arg in ("-h", "--help") : 440 sys.stderr.write("usage : pykoticon pykota_server_hostname_or_ip_address localTCPPort\n") 441 else : 442 main(*sys.argv[1:3]) 443 else : 444 sys.stderr.write("usage : pykoticon pykota_server_hostname_or_ip_address localTCPPort\n") 457 main() 458 -
pykoticon/trunk/bin/pykoticon.vbs
r118 r123 19 19 ' 20 20 set Wshshell= WScript.createobject("wscript.shell") 21 retcode = Wshshell.run ("%comspec% /C pykoticon.exe nordine.ateur 7654", 0, FALSE)21 retcode = Wshshell.run ("%comspec% /C pykoticon.exe --port 7654 nordine.ateur", 0, FALSE)