Best Python code snippet using localstack_python
qcloud_deploy.py
Source:qcloud_deploy.py
...78 __ = lambda x: sudo("pip install %s" %x)79 __("redis")80 __("hiredis")81 __("msgpack-python") 82def start_tcp_proxy():83 run("cd work; python spider/tcp_proxy.py promo client", pty=False) 84 run("cd work; python spider/tcp_proxy.py offshelf client", pty=False)85def stop_tcp_proxy():86 run("cd work; python spider/kill_worker.py tcp_proxy")87def run_all():88 run("cd work; python spider all") 89def single_command(command, site=None, worker=False, response=False): 90 packet = {91 "id": 1235,92 "cmd": command,93 } 94 if site:95 packet["site"] = site96 if worker:...
proxy_server.py
Source:proxy_server.py
...3import socket4from localstack.constants import BIND_HOST, LOCALHOST_IP5from localstack.utils.common import is_number, run_safe, start_worker_thread6BUFFER_SIZE = 2 ** 10 # 10247def start_tcp_proxy(src, dst, handler, **kwargs):8 """Run a simple TCP proxy (tunneling raw connections from src to dst), using a message handler9 that can be used to intercept messages and return predefined responses for certain requests.10 Arguments:11 src -- Source IP address and port string. I.e.: '127.0.0.1:8000'12 dst -- Destination IP address and port. I.e.: '127.0.0.1:8888'13 handler -- a handler function to intercept requests (returns tuple (forward_value, response_value))14 """15 src = "%s:%s" % (BIND_HOST, src) if is_number(src) else src16 dst = "%s:%s" % (LOCALHOST_IP, dst) if is_number(dst) else dst17 thread = kwargs.get("_thread")18 def ip_to_tuple(ip):19 ip, port = ip.split(":")20 return ip, int(port)21 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!