Steps with explanations to set up a server using:
- Virtualenv
- Virtualenvwrapper
- Django
- Gunicorn
import os | |
import sys | |
import re | |
import pdb | |
class EmailParser: | |
warnings = [] | |
def __init__(self, filename): |
from re import compile | |
from django.conf import settings | |
from django.http import HttpResponseRedirect | |
from django.utils.http import is_safe_url | |
EXEMPT_URLS = [compile(settings.LOGIN_URL.lstrip('/'))] | |
if hasattr(settings, 'LOGIN_EXEMPT_URLS'): | |
EXEMPT_URLS += [compile(expr) for expr in settings.LOGIN_EXEMPT_URLS] | |
class LoginRequiredMiddleware: |
import requests | |
from lxml import html | |
USERNAME = "<USERNAME>" | |
PASSWORD = "<PASSWORD>" | |
LOGIN_URL = "https://bitbucket.org/account/signin/?next=/" | |
URL = "https://bitbucket.org/dashboard/overview" | |
def main(): |
# coding=utf-8 | |
""" | |
LICENSE http://www.apache.org/licenses/LICENSE-2.0 | |
""" | |
import datetime | |
import sys | |
import time | |
import threading | |
import traceback | |
import SocketServer |
#!/usr/bin/env python | |
"""Functions to convert IPv4 address to integer and vice-versa. | |
Written by Christian Stigen Larsen, http://csl.sublevel3.org | |
Placed in the public domain by the author, 2012-01-11 | |
Example usage: | |
$ ./ipv4 192.168.0.1 3232235521 | |
192.168.0.1 ==> 3232235521 |
"""UDP proxy server.""" | |
import asyncio | |
class ProxyDatagramProtocol(asyncio.DatagramProtocol): | |
def __init__(self, remote_address): | |
self.remote_address = remote_address | |
self.remotes = {} |
py.test test_sample.py --collect-only # collects information test suite | |
py.test test_sample.py -v # outputs verbose messages | |
py.test -q test_sample.py # omit filename output | |
python -m pytest -q test_sample.py # calling pytest through python | |
py.test --markers # show available markers |
# -*- coding: utf-8 -*- | |
import gevent.monkey | |
gevent.monkey.patch_all() | |
import collections | |
import threading | |
import time | |
import random | |
import sys |
import sys | |
def get_size(obj, seen=None): | |
"""Recursively finds size of objects""" | |
size = sys.getsizeof(obj) | |
if seen is None: | |
seen = set() | |
obj_id = id(obj) | |
if obj_id in seen: | |
return 0 |