GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — web-logging-example/fabfile.py at master · openxc/web-logging-example Expand file tree/ Copy pathfabfile.pyMore file actions 69 lines (58 loc) · 2.07 KB / Copy pathfabfile.pyFile metadata and controls69 lines (58 loc) · 2.07 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 from fabric.api import * def setup(): """Installs all Python package dependencies.""" local("pip install -r pip-requirements.txt") def runserver(): """Run the development web server.""" local("python recorder.py") def test(): """Run the test suite.""" clean() local('python -m tornado.autoreload tests/run_tests.py') def clean(): """Clean up all .pyc files.""" local("find . -name \"*.pyc\" -exec rm {} \;") local("rm -rf traces") def deploy(): local("git push") with cd("/var/www/recorder"): run("git pull") sudo("apachectl restart") def send_test_data(filename): """ Send the records from a trace value to a local visualization server """ import requests import time import json def send_records(records): data = {"records": records} print "Sending %s" % data headers = {'content-type': 'application/json'} r = requests.post('http://localhost:5000/records', data=json.dumps(data), headers=headers) print r def wait_for_next_record(starting_time, first_timestamp,timestamp): target_time = starting_time + (timestamp - first_timestamp) sleep_duration = target_time - time.time() if sleep_duration > 0: time.sleep(sleep_duration + 1) while True: starting_time = time.time() first_timestamp = None try: records = [] with open(filename, 'r') as trace_file: for line in trace_file: record = json.loads(line) if first_timestamp is None: first_timestamp = record['timestamp'] wait_for_next_record(starting_time, first_timestamp, record['timestamp']) records.append(record) if len(records) == 25: send_records(records) time.sleep(.5) records = [] except IOError: print("No active trace file found at %s" % filename) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |