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 twisted.internet import reactor, protocol | |
from twisted.protocols import policies | |
from twisted.protocols import basic | |
import queue | |
WAITING = 'waiting' | |
COLLECTING = 'collecting' | |
IDLE = 'idle' |
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/python | |
import urllib2 | |
from datetime import datetime, timedelta | |
import simplejson as JSON | |
from pprint import pprint | |
import re | |
when = datetime.now() #- timedelta(days=1) | |
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
""" | |
Twisted Sports FTP server, simple auth and post upload hook. | |
NOTE: In the spirit of doing it the hard way first, it now feels like I should have used | |
reactor.addWriter to install the HookFileWriter instead of these acrobatics. | |
Does the reactor really hold the filewriter for these tasks? | |
""" | |
from twisted.protocols.ftp import FTPFactory, FTPRealm, errnoToFailure | |
from twisted.cred.portal import Portal |
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
$ curl https://api.spark.io/v1/devices/...DEVICE_TOKEN.../digitalwrite -d access_token=...ACCESS_TOKEN... -d params=D7,HIGH | |
{ | |
"id": "48ff6f065067555023342387", | |
"name": "gerbils", | |
"last_app": null, | |
"connected": true, | |
"return_value": 1 | |
} |
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
*.pyc |
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 functools import wraps | |
import logging | |
def arglist( *args, **kwargs ): | |
s = "" | |
for a in args: | |
s += repr(a) + "," | |
for k,v in kwargs.items(): | |
s += "{k}={v}, ".format( k= k, v=repr(v) ) |
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 django.conf import settings | |
settings.CELERY_APP.conf | |
settings.CELERY_APP.tasks | |
settings.CELERY_APP.conf['CELERYBEAT_SCHEDULE'] | |
for k in settings.CELERY_APP.conf['CELERYBEAT_SCHEDULE']: | |
t = settings.CELERY_APP.conf['CELERYBEAT_SCHEDULE'][k] | |
print t['schedule'], t['task'] | |
... | |
<crontab: 0 */12 * * * (m/h/d/dM/MY)> proxypages.tasks.refresh_twice_daily | |
<crontab: 0 */4 * * * (m/h/d/dM/MY)> proxypages.tasks.refresh_four_hour |
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
# source this code in a Bash shell | |
# and run like django-post-payload '{"a": "b"}' | |
# you can set the credentials by exporting DJANGO_USER and DJANGO_PASSWORD | |
django-post-payload() { | |
local TARGET=http://ws.somesite.com/some/service/endpoint/ | |
local PAYLOAD=$1 | |
#"{\"asd\": \"asd\"}" | |
local LOGIN=http://ws.somesite.com/login/ | |
# |
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 inspect | |
class ReprFromInit( object ): | |
def __repr__( self ): | |
args = inspect.getargspec( self.__class__.__init__ ).args | |
path = "{modulename}.{classname}".format( modulename=self.__class__.__module__, classname=self.__class__.__name__ ) | |
argstrs = [] | |
for arg in args[1:]: # skip self | |
for argname in [ arg, "_"+arg, '' ]: | |
if hasattr( self, argname ): | |
break |
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
# build | |
python setup.py sdist | |
python setup.py bdist_wheel | |
read | |
#register with test system | |
# python setup.py register -r pypitest | |
# read | |
# upload to test system |
OlderNewer