This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Create a page in the current dir | |
echo "My Test Page" > test.html | |
# Start server | |
python -m SimpleHTTPServer 8000 &> /dev/null & | |
pid=$! | |
# Give server time to start up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python 2.7.6 | |
# stomp.py v4.1.5 (https://pypi.python.org/pypi/stomp.py) | |
import time | |
import stomp | |
class MyListener(stomp.ConnectionListener): | |
def on_message(self, headers, message): | |
print('MyListener:\nreceived a message "{}"\n'.format(message)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def log_method_call(func): | |
def inner(*args, **kwargs): | |
try: | |
frame = inspect.currentframe() | |
stack_trace = inspect.getouterframes(frame) | |
stack_trace_relevant_parts = [ | |
" ".join((f[1], str(f[2]), f[4][0].strip())) | |
for f in stack_trace | |
] | |
pretty_stack_trace = "\n".join(stack_trace_relevant_parts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Demo of how to start up a simple http server on a free port in a given range. | |
I find that this can be useful in tests. | |
>$ python run_stub_server_example.py | |
*** Server 1 *** | |
Server 1: is_running=True, port=60000 | |
*** Server 2 *** | |
Port 60000 in use. | |
Server 2: is_running=True, port=60001 |