def main(): parser = optparse.OptionParser() parser.add_option( '-p', '--port', dest='port', help='VSIS TCP port.', default=DEFAULT_VSIS_PORT) parser.add_option( '-H', '--host', dest='host', help='VSIS host.', default=DEFAULT_VSIS_HOST) parser.add_option( '-l', '--log_level', dest='log_level', help='Log level(0,..4).', default=DEFAULT_LOG_LEVEL) (o, a) = parser.parse_args() set_log_level(o.log_level) logging.info("Starting server") # TODO # CONFIGURATION_FILE='dimino6.xml' # logging.info("%s"%get_pypath_resource(CONFIGURATION_FILE)) try: vsi_server = Server.Server( (o.host, o.port), TCPRequestHandler.TCPRequestHandler) vsi_thread = threading.Thread(target=vsi_server.serve_forever) vsi_thread.setDaemon(True) vsi_thread.start() vsi_thread.join() except Exception, e: logging.error('Server error: %s'%e)
def main(): parser = optparse.OptionParser() parser.add_option( '-p', '--port', dest='port', help='VSIS TCP port.', default=DEFAULT_VSIS_PORT) parser.add_option( '-H', '--host', dest='host', help='VSIS host address.', default=DEFAULT_VSIS_HOST) parser.add_option( '-l', '--log_level', dest='log_level', help='Log level(0,..,4).', default=DEFAULT_LOG_LEVEL) parser.add_option( '-f', '--input_file', dest='input_file', help='Input command file (for batch mode).') parser.add_option( '-t', '--test', action='store_true', dest='test', help='Run tests.', default=False) (o, a) = parser.parse_args() set_log_level(o.log_level) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: sock.connect((o.host, o.port)) Client( cmd_source=sys.stdin, cmd_sink=sock, rsp_source=sock, rsp_sink=sys.stdout).run() except Exception, e: logging.error('DRS client error: %s'%e)