def extract(self): payloads=[] self.file=urlparse(self.url).path params=urlparse(self.url).query params=parse_url(params) for i in xrange(len(params)+1): data='' for k,v in params.items(): i-=1 vs=v=v[0] if i==0: vs='{payload}' data+='%s=%s&'%(k,vs) if '{payload}' in data: f=self.file+"?"+data payloads.append(self.file+"?"+data) self.get_payloads=payloads # url params payloads=[] if self.method=='POST': params=parse_url(self.postdata) for i in xrange(len(params)+1): data='' for k,v in params.items(): i-=1 vs=v=v[0] if i==0: vs='{payload}' data+='%s=%s&'%(k,vs) payloads.append(data) self.post_payload=payloads #post paramas
def _set_control_link_url(self, custom_address=None): """Set the address to use for the Control Connection in such cases where Lightstreamer is behind a Load Balancer. """ if custom_address is None: self._control_url = self._base_url else: parsed_custom_address = parse_url("//" + custom_address) self._control_url = parsed_custom_address._replace( scheme=self._base_url[0])
def __init__(self, base_url, adapter_set="", user="", password=""): self._base_url = parse_url(base_url) self._adapter_set = adapter_set self._user = user self._password = password self._session = {} self._subscriptions = {} self._current_subscription_key = 0 self._stream_connection = None self._stream_connection_thread = None self._bind_counter = 0
def main(): argvs = sys.argv argc = len(argvs) if argc < 3: print( 'Usage: python fcgi.py http://127.0.0.1:9000/path/to/some.php?queryString path/to/documentroot postData' ) print( 'Example: python fcgi.py http://127.0.0.1:9000/echo.php\?name\=john ' '/Users/baidu/php_workspace name=john&address=beijing') return argv = argvs[1] documentRoot = argvs[2] parseResult = parse_url(argv) host = parseResult.hostname port = parseResult.port uri = parseResult.path query = parseResult.query client = FastCGIClient(host, port, 3000, 0) if argc > 3: content = argvs[3] # content = "name=john&address=beijing" params = { 'GATEWAY_INTERFACE': 'FastCGI/1.0', 'REQUEST_METHOD': 'POST', 'SCRIPT_FILENAME': documentRoot + uri, 'SCRIPT_NAME': uri, 'QUERY_STRING': query, 'REQUEST_URI': uri, 'DOCUMENT_ROOT': documentRoot, 'SERVER_SOFTWARE': 'php/fcgiclient', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '9985', 'SERVER_ADDR': '127.0.0.1', 'SERVER_PORT': '80', 'SERVER_NAME': "localhost", 'SERVER_PROTOCOL': 'HTTP/1.1', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CONTENT_LENGTH': len(content) } print(client.request(params, content))
def main(): argvs = sys.argv argc = len(argvs) if argc < 3: print('Usage: python fcgi.py http://127.0.0.1:9000/path/to/some.php?queryString path/to/documentroot postData') print('Example: python fcgi.py http://127.0.0.1:9000/echo.php\?name\=john ' '/Users/baidu/php_workspace name=john&address=beijing') return argv = argvs[1] documentRoot = argvs[2] parseResult = parse_url(argv) host = parseResult.hostname port = parseResult.port uri = parseResult.path query = parseResult.query client = FastCGIClient(host, port, 3000, 0) content = '' if argc > 3: content = argvs[3] # content = "name=john&address=beijing" params = {'GATEWAY_INTERFACE': 'FastCGI/1.0', 'REQUEST_METHOD': 'POST', 'SCRIPT_FILENAME': documentRoot + uri, 'SCRIPT_NAME': uri, 'QUERY_STRING': query, 'REQUEST_URI': uri, 'DOCUMENT_ROOT': documentRoot, 'SERVER_SOFTWARE': 'php/fcgiclient', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '9985', 'SERVER_ADDR': '127.0.0.1', 'SERVER_PORT': '80', 'SERVER_NAME': "localhost", 'SERVER_PROTOCOL': 'HTTP/1.1', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CONTENT_LENGTH': len(content) } print(client.request(params, content))
def get_status(): """ get php_status """ parseResult = parse_url(URL) host = parseResult.hostname port = parseResult.port uri = parseResult.path query = parseResult.query client = FastCGIClient(host, port, 3000, 0) params = {'GATEWAY_INTERFACE': 'FastCGI/1.0', 'REQUEST_METHOD': 'POST', 'SCRIPT_FILENAME': uri, 'SCRIPT_NAME': uri, 'QUERY_STRING': query, 'REQUEST_URI': uri, 'SERVER_SOFTWARE': 'php/fcgiclient', 'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '9985', 'SERVER_ADDR': '127.0.0.1', 'SERVER_PORT': '80', 'SERVER_NAME': "localhost", 'SERVER_PROTOCOL': 'HTTP/1.1', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', } return client.request(params)
'postgres': 5432, 'postgresql': 5432, 'mysql': 3306, } if __name__ == '__main__': args = sys.argv[1:] with open(os.path.join("/run", "secrets", "postgres-passwd"), 'r') as pg_passwd_file: pg_passwd = pg_passwd_file.read() os.environ['DB'] = os.getenv('DB', '').replace("PASSWORD", pg_passwd) if not args or args[0].startswith('-'): db_url = parse_url( os.getenv('DB', "sqlite:///var/lib/pypi-server/pypi-server.sqlite3")) host = db_url.hostname if 'sqlite' in db_url.scheme.lower(): port = None else: port = int(db_url.port or DEFAULT_PORTS[db_url.scheme]) args.insert(0, '/usr/bin/pypi-server') while port and not check_port(db_url.hostname, port): log.info('Awaiting database...') sleep(1) continue
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) return sock.connect_ex((host, port)) == 0 DEFAULT_PORTS = { 'postgres': 5432, 'postgresql': 5432, 'mysql': 3306, } if __name__ == '__main__': args = sys.argv[1:] if not args or args[0].startswith('-'): db_url = parse_url(os.getenv('DB', '')) host = db_url.hostname if 'sqlite' in db_url.scheme.lower(): port = None else: port = int(db_url.port or DEFAULT_PORTS[db_url.scheme]) args.insert(0, '/usr/bin/pypi-server') while port and not check_port(db_url.hostname, port): log.info('Awaiting database...') sleep(1) continue # Ensure database engine is ready