def main(): """ REST-JSON API main function """ # Set default logging level to debug logger.setLevel(logging.DEBUG) # Initialize paths setPaths(modulePath()) # Parse command line options apiparser = optparse.OptionParser() apiparser.add_option("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server (default \"%s\")" % RESTAPI_DEFAULT_ADDRESS, default=RESTAPI_DEFAULT_ADDRESS, action="store") apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server (default %d)" % RESTAPI_DEFAULT_PORT, default=RESTAPI_DEFAULT_PORT, type="int", action="store") apiparser.add_option("--adapter", help="Server (bottle) adapter to use (default \"%s\")" % RESTAPI_DEFAULT_ADAPTER, default=RESTAPI_DEFAULT_ADAPTER, action="store") (args, _) = apiparser.parse_args() # Start the client or the server if args.server is True: server(args.host, args.port, adapter=args.adapter) elif args.client is True: client(args.host, args.port) else: apiparser.print_help()
def main(): """ REST-JSON API main function """ # Set default logging level to debug logger.setLevel(logging.DEBUG) # Initialize path variable paths.SQLMAP_ROOT_PATH = modulePath() setPaths() # Parse command line options apiparser = optparse.OptionParser() apiparser.add_option("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_DEFAULT_ADDRESS, action="store") apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_DEFAULT_PORT, type="int", action="store") apiparser.add_option("--adapter", help="Server (bottle) adapter to use (default %s)" % RESTAPI_DEFAULT_ADAPTER, default=RESTAPI_DEFAULT_ADAPTER, action="store") (args, _) = apiparser.parse_args() # Start the client or the server if args.server is True: server(args.host, args.port, adapter=args.adapter) elif args.client is True: client(args.host, args.port) else: apiparser.print_help()
def main(): """ REST-JSON API main function """ # Set default logging level to debug logger.setLevel(logging.DEBUG) # Initialize paths setPaths(modulePath()) # Parse command line options apiparser = optparse.OptionParser() apiparser.add_option("-s", "--server", help="Run as a REST-JSON API server", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-c", "--client", help="Run as a REST-JSON API client", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server (default \"%s\")" % RESTAPI_DEFAULT_ADDRESS, default=RESTAPI_DEFAULT_ADDRESS, action="store") apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server (default %d)" % RESTAPI_DEFAULT_PORT, default=RESTAPI_DEFAULT_PORT, type="int", action="store") apiparser.add_option("--adapter", help="Server (bottle) adapter to use (default \"%s\")" % RESTAPI_DEFAULT_ADAPTER, default=RESTAPI_DEFAULT_ADAPTER, action="store") apiparser.add_option("--username", help="Basic authentication username (optional)", action="store") apiparser.add_option("--password", help="Basic authentication password (optional)", action="store") (args, _) = apiparser.parse_args() # Start the client or the server if args.server is True: server(args.host, args.port, adapter=args.adapter, username=args.username, password=args.password) elif args.client is True: client(args.host, args.port, username=args.username, password=args.password) else: apiparser.print_help()
def main(): """ REST-JSON API main function """ # Set default logging level to debug logger.setLevel(logging.DEBUG) # Initialize path variable paths.SQLMAP_ROOT_PATH = modulePath() setPaths() # Parse command line options apiparser = optparse.OptionParser() apiparser.add_option("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_DEFAULT_ADDRESS, action="store") apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_DEFAULT_PORT, type="int", action="store") (args, _) = apiparser.parse_args() # Start the client or the server if args.server is True: server(args.host, args.port) elif args.client is True: client(args.host, args.port) else: apiparser.print_help()
def main(): """ REST-JSON API 主函数 """ # 将默认日志记录级别设置为debug logger.setLevel(logging.DEBUG) # 初始化路径 setPaths(modulePath()) # 解析命令行选项 apiparser = optparse.OptionParser() apiparser.add_option("-s", "--server", help=u"作为REST-JSON API服务器", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-c", "--client", help=u"作为REST-JSON API客户端", default=RESTAPI_DEFAULT_PORT, action="store_true") apiparser.add_option("-H", "--host", help="REST-JSON API服务器主机地址(默认为 \"%s\")" % RESTAPI_DEFAULT_ADDRESS, default=RESTAPI_DEFAULT_ADDRESS, action="store") apiparser.add_option("-p", "--port", help="REST-JSON服务器端口(默认为 %d)" % RESTAPI_DEFAULT_PORT, default=RESTAPI_DEFAULT_PORT, type="int", action="store") apiparser.add_option("--adapter", help="要使用的服务器适配器(默认为 \"%s\")" % RESTAPI_DEFAULT_ADAPTER, default=RESTAPI_DEFAULT_ADAPTER, action="store") (args, _) = apiparser.parse_args() """ adapter(适配器)定义为将一个类的接口变换成客户端所期待的一种接口, 从而使原本因接口不匹配而无法在一起工作的两个类能够在一起工作。 """ # 启动客户端或服务器 if args.server is True: server(args.host, args.port, adapter=args.adapter) elif args.client is True: client(args.host, args.port) else: apiparser.print_help()
def run(self): try: api.server(self.host, self.port) except socket.error, e: error = str(e) msg = error[error.index(']') + 1:] title = error[:error.index(']') + 1] if 'Errno 98' in error: msg = 'The Server is already running\n\nmessage: ' + msg else: msg = 'message: ' + msg wx.CallAfter(self.parent.OnServer, msg, title)
def main(): """ REST-JSON API main function """ # Set default logging level to debug logger.setLevel(logging.DEBUG) # Initialize paths setPaths(modulePath()) server(RESTAPI_DEFAULT_ADDRESS, RESTAPI_DEFAULT_PORT, adapter=RESTAPI_DEFAULT_ADAPTER)
def run(self): try: api.server(self.host, self.port) except socket.error, e: error = str(e) msg = error[error.index(']')+1:] title = error[:error.index(']')+1] if 'Errno 98' in error: msg = 'The Server is already running\n\nmessage: ' + msg else: msg = 'message: ' + msg wx.CallAfter(self.parent.OnServer, msg, title)
# Parse command line options apiparser = optparse.OptionParser() apiparser.add_option("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_SERVER_PORT, action="store_true") apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_SERVER_PORT, action="store_true") apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_SERVER_HOST, action="store") apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_SERVER_PORT, type="int", action="store") (args, _) = apiparser.parse_args() # Start the client or the server if args.server is True: server(args.host, args.port) elif args.client is True: client(args.host, args.port)
RESTAPI_SERVER_HOST = "127.0.0.1" RESTAPI_SERVER_PORT = 8775 if __name__ == "__main__": """ REST-JSON API main function """ # Set default logging level to debug logger.setLevel(logging.DEBUG) # Initialize path variable paths.SQLMAP_ROOT_PATH = modulePath() setPaths() # Parse command line options apiparser = optparse.OptionParser() apiparser.add_option("-s", "--server", help="Act as a REST-JSON API server", default=RESTAPI_SERVER_PORT, action="store_true") apiparser.add_option("-c", "--client", help="Act as a REST-JSON API client", default=RESTAPI_SERVER_PORT, action="store_true") apiparser.add_option("-H", "--host", help="Host of the REST-JSON API server", default=RESTAPI_SERVER_HOST, action="store") apiparser.add_option("-p", "--port", help="Port of the the REST-JSON API server", default=RESTAPI_SERVER_PORT, type="int", action="store") (args, _) = apiparser.parse_args() # Start the client or the server if args.server is True: server(args.host, args.port) elif args.client is True: client(args.host, args.port) else: apiparser.print_help()