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
class Tracker(Base): | |
__tablename__ = 'tracker' | |
id = Column(Integer, primary_key=True) | |
state = Column(String, nullable=False) | |
def __repr__(self): | |
return 'Tracker<{.id}>'.format(self) | |
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
from tornado import web | |
from tornado import ioloop | |
from sqlalchemy.engine | |
from sqlalchemy import create_engine | |
from sqlalchemy.orm import sessionmaker | |
import os |
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
from sqlalchemy import * | |
from sqlalchemy.orm import * | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.ext.associationproxy import association_proxy | |
Base = declarative_base() | |
class Machine(Base): | |
__tablename__ = 'machines' | |
__table_args__ = {'sqlite_autoincrement': True} |
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
from sqlalchemy import * | |
from sqlalchemy.orm import * | |
from sqlalchemy.ext.declarative import * | |
Base = declarative_base() | |
class Access(Base): | |
__tablename__ = 'accesses' | |
access_id = Column(Integer, primary_key=True) |
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
'''This script grabs the currently registered IANA link relations from | |
iana.org''' | |
from __future__ import print_function | |
from __future__ import unicode_literals | |
import requests | |
from lxml import objectify | |
import datetime |
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
import requests | |
def test_multiple_rels_per_link(): | |
r = requests.get('http://www.httpbin.org/response-headers?link=' | |
'</two-rel>;rel="alternate self";title="The Title"') | |
assert r.links == {'alternate': [{'href' : '/two-rel', | |
'rel': 'alternate', | |
'title': 'The Title'}], | |
'self' : [{'href' : '/two-rel', | |
'rel': 'self', |
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
# Contributor: dschauer, Dwight Schauer <[email protected]> | |
pkgname=openconnect-git | |
pkgver=20120907 | |
pkgrel=1 | |
pkgdesc="VPN client (intended to be) compatible with Cisco AnyConnect" | |
arch=(i686 x86_64) | |
url="http://git.infradead.org/users/dwmw2/openconnect.git" | |
license=('LGPL') | |
groups=() | |
depends=() |
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 reltime(date, compare_to=None, at='@'): | |
r'''Takes a datetime and returns a relative representation of the | |
time. | |
:param date: The date to render relatively | |
:param compare_to: what to compare the date to. Defaults to datetime.now() | |
:param at: date/time separator. defaults to "@". "at" is also reasonable. | |
>>> from datetime import datetime, timedelta | |
>>> today = datetime(2050, 9, 2, 15, 00) | |
>>> earlier = datetime(2050, 9, 2, 12) |
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 dispatch_hook(key, hooks, hook_data): | |
"""Dispatches a hook dictionary on a given piece of data.""" | |
hooks = hooks or dict() | |
if key in hooks: | |
hooks = hooks.get(key) | |
if hasattr(hooks, '__call__'): | |
hooks = [hooks] |
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
import re | |
import string as s | |
def tagify(*args, **kwargs): | |
r'''Turns the argument strings into tags. so 'my tag' becomes '#MyTag' | |
Any keyword arguments become tags with values. | |
>>> tagify('hi there') | |
['#HiThere'] |