code
stringlengths
1
1.72M
language
stringclasses
1 value
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2008-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # ...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2008-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007-2011 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists...
Python
# -*- coding: utf-8 -*- # # Copyright (C) 2007 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists of v...
Python
import os import re from webob import Request, Response from webob import exc from tempita import HTMLTemplate VIEW_TEMPLATE = HTMLTemplate("""\ <html> <head> <title>{{page.title}}</title> </head> <body> <h1>{{page.title}}</h1> {{if message}} <div style="background-color: #99f">{{message}}</div> {{endif}} <div>{...
Python
import os import urllib import time import re from cPickle import load, dump from webob import Request, Response, html_escape from webob import exc class Commenter(object): def __init__(self, app, storage_dir): self.app = app self.storage_dir = storage_dir if not os.path.exists(storage...
Python
# A reaction to: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/552751 from webob import Request, Response from webob import exc from simplejson import loads, dumps import traceback import sys class JsonRpcApp(object): """ Serve the given object via json-rpc (http://json-rpc.org/) """ def __i...
Python
import unittest import doctest def test_suite(): flags = doctest.ELLIPSIS|doctest.NORMALIZE_WHITESPACE return unittest.TestSuite(( doctest.DocFileSuite('test_request.txt', optionflags=flags), doctest.DocFileSuite('test_response.txt', optionflags=flags), doctest.DocFileSuite('test_dec.tx...
Python
# -*- coding: utf-8 -*- # # Paste documentation build configuration file, created by # sphinx-quickstart on Tue Apr 22 22:08:49 2008. # # This file is execfile()d with the current directory set to its containing dir. # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleabl...
Python
from webob.multidict import MultiDict from UserDict import DictMixin __all__ = ['ResponseHeaders', 'EnvironHeaders'] class ResponseHeaders(MultiDict): """ Dictionary view on the response headerlist. Keys are normalized for case and whitespace. """ def __getitem__(self, key): key = ...
Python
import re, time, string from datetime import datetime, date, timedelta __all__ = ['Cookie'] class Cookie(dict): def __init__(self, input=None): if input: self.load(input) def load(self, data): ckey = None for key, val in _rx_cookie.findall(data): if key.lower()...
Python
""" Decorators to wrap functions to make them WSGI applications. The main decorator :class:`wsgify` turns a function into a WSGI application (while also allowing normal calling of the method with an instantiated request). """ import webob import webob.exc from types import ClassType __all__ = ['wsgify'] class wsgif...
Python
# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php """ Gives a multi-value dictionary object (MultiDict) plus several wrappers """ import cgi, copy, sys, warnings, urllib from UserDict import DictMixin ...
Python
import sys, tempfile, warnings import urllib, urlparse, cgi if sys.version >= '2.7': from io import BytesIO as StringIO # pragma nocover else: from cStringIO import StringIO # pragma nocover from webob.headers import EnvironHeaders from webob.acceptparse import accept_property, Accept, MIMEAccept, NilAccept, M...
Python
import re, urlparse, zlib, struct from datetime import datetime, date, timedelta from webob.headers import ResponseHeaders from webob.cachecontrol import CacheControl, serialize_cache_control from webob.descriptors import * from webob.datetime_utils import * from webob.cookies import Cookie, Morsel from webob.util im...
Python
""" Represents the Cache-Control header """ import re class UpdateDict(dict): """ Dict that has a callback on all updates """ # these are declared as class attributes so that # we don't need to override constructor just to # set some defaults updated = None updated_args = None def ...
Python
def rfc_reference(header, section): if not section: return '' major_section = section.split('.')[0] link = 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec%s.html#sec%s' % (major_section, section) if header.startswith('HTTP_'): header = header[5:].title().replace('_', '-') return " F...
Python
import warnings import re from datetime import datetime, date from webob.byterange import Range, ContentRange from webob.etag import IfRange, NoIfRange from webob.datetime_utils import parse_date, serialize_date from webob.util import rfc_reference CHARSET_RE = re.compile(r';\s*charset=([^;]*)', re.I) QUOTES_RE = re...
Python
""" Parses a variety of ``Accept-*`` headers. These headers generally take the form of:: value1; q=0.5, value2; q=0 Where the ``q`` parameter is optional. In theory other parameters exists, but this ignores them. """ import re from webob.util import rfc_reference from webob.headers import _trans_name as header...
Python
import time import calendar from datetime import datetime, date, timedelta, tzinfo from rfc822 import parsedate_tz, mktime_tz, formatdate __all__ = [ 'UTC', 'timedelta_to_seconds', 'year', 'month', 'week', 'day', 'hour', 'minute', 'second', 'parse_date', 'serialize_date', 'parse_date_delta', 'serialize...
Python
""" Does parsing of ETag-related headers: If-None-Matches, If-Matches Also If-Range parsing """ from webob.datetime_utils import * from webob.util import rfc_reference __all__ = ['AnyETag', 'NoETag', 'ETagMatcher', 'IfRange', 'NoIfRange', 'etag_property'] def etag_property(key, default, rfc_section): doc = "Ge...
Python
import cgi from webob.datetime_utils import * from webob.request import * from webob.response import * # Pylons has imported UnicodeMultiDict directly from this location; so # we're putting it here just to help them out (though it has also been # fixed in Pylons tip on 17 Dec 2009) from webob.multidict import UnicodeMu...
Python
""" HTTP Exception -------------- This module processes Python exceptions that relate to HTTP exceptions by defining a set of exceptions, all subclasses of HTTPException. Each exception, in addition to being a Python exception that can be raised and caught, is also a WSGI application and ``webob.Response`` object. Thi...
Python
class Range(object): """ Represents the Range header. This only represents ``bytes`` ranges, which are the only kind specified in HTTP. This can represent multiple sets of ranges, but no place else is this multi-range facility supported. """ def __init__(self, ranges): # e...
Python
from setuptools import setup version = '1.0.8' setup( name='WebOb', version=version, description="WSGI request and response object", long_description="""\ WebOb provides wrappers around the WSGI request environment, and an object to help create WSGI responses. The objects map much of the specified be...
Python
import os, sys sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) import pkg_resources pkg_resources.require('WebOb')
Python
#!/usr/bin/env python import webob def make_middleware(app): from repoze.profile.profiler import AccumulatingProfileMiddleware return AccumulatingProfileMiddleware( app, log_filename='/tmp/profile.log', discard_first_request=True, flush_at_shutdown=True, path='/__profile...
Python
#
Python
""" gae-pytz ======== pytz has a severe performance problem that impedes its usage on Google App Engine. This is caused because pytz.__init__ builds a list of available zoneinfos checking the entire zoneinfo database (which means: it tries to open hundreds of files). This is done in the module globals, so it is not eas...
Python
'''Base classes and helpers for building zone specific tzinfo classes''' from datetime import datetime, timedelta, tzinfo from bisect import bisect_right try: set except NameError: from sets import Set as set import pytz __all__ = [] _timedelta_cache = {} def memorized_timedelta(seconds): '''Create only...
Python
#!/usr/bin/env python ''' $Id: tzfile.py,v 1.8 2004/06/03 00:15:24 zenzen Exp $ ''' from cStringIO import StringIO from datetime import datetime, timedelta from struct import unpack, calcsize from pytz.tzinfo import StaticTzInfo, DstTzInfo, memorized_ttinfo from pytz.tzinfo import memorized_datetime, memorized_timede...
Python
""" A pytz version that runs smoothly on Google App Engine. Based on http://appengine-cookbook.appspot.com/recipe/caching-pytz-helper/ To use, add pytz to your path normally, but import it from the gae module: from pytz.gae import pytz Applied patches: - The zoneinfo dir is removed fr...
Python
''' Reference tzinfo implementations from the Python docs. Used for testing against as they are only correct for the years 1987 to 2006. Do not use these for real code. ''' from datetime import tzinfo, timedelta, datetime from pytz import utc, UTC, HOUR, ZERO # A class building tzinfo objects for fixed-offset time zo...
Python
''' datetime.tzinfo timezone definitions generated from the Olson timezone database: ftp://elsie.nci.nih.gov/pub/tz*.tar.gz See the datetime section of the Python Library Reference for information on how to use these modules. ''' # The Olson database is updated several times a year. OLSON_VERSION = '2010h' VERSI...
Python
import webapp2 class LazyHandler(webapp2.RequestHandler): def get(self, **kwargs): self.response.out.write('I am a laaazy view.')
Python
import webapp2 class HomeHandler(webapp2.RequestHandler): def get(self, **kwargs): html = '<a href="%s">test item</a>' % self.url_for('view', item='test') self.response.out.write(html) class ViewHandler(webapp2.RequestHandler): def get(self, **kwargs): item = kwargs.get('item') ...
Python
# -*- coding: utf-8 -*- """ webapp2 ======= Taking Google App Engine's webapp to the next level! :copyright: 2011 by tipfy.org. :license: Apache Sotware License, see LICENSE for details. """ from __future__ import with_statement import cgi import inspect import logging import os import re import ...
Python
import re from SCons.Script import * # the usual scons stuff you get in a SConscript def generate(env): """ Add builders and construction variables for the SubstInFile tool. Adds SubstInFile builder, which substitutes the keys->values of SUBST_DICT from the source to the target. The values of...
Python
import fnmatch import os def generate( env ): def Glob( env, includes = None, excludes = None, dir = '.' ): """Adds Glob( includes = Split( '*' ), excludes = None, dir = '.') helper function to environment. Glob both the file-system files. includes: list of file name pattern included i...
Python
"""tarball Tool-specific initialization for tarball. """ ## Commands to tackle a command based implementation: ##to unpack on the fly... ##gunzip < FILE.tar.gz | tar xvf - ##to pack on the fly... ##tar cvf - FILE-LIST | gzip -c > FILE.tar.gz import os.path import SCons.Builder import SCons.Node.FS import SCons.Ut...
Python
import os import os.path from fnmatch import fnmatch import targz ##def DoxyfileParse(file_contents): ## """ ## Parse a Doxygen source file and return a dictionary of all the values. ## Values will be strings and lists of strings. ## """ ## data = {} ## ## import shlex ## lex = shlex.shlex(instream = fil...
Python
""" Notes: - shared library support is buggy: it assumes that a static and dynamic library can be build from the same object files. This is not true on many platforms. For this reason it is only enabled on linux-gcc at the current time. To add a platform: - add its name in options allowed_values below - add too...
Python
import os.path def fix_source_eol( path, is_dry_run = True, verbose = True, eol = '\n' ): """Makes sure that all sources have the specified eol sequence (default: unix).""" if not os.path.isfile( path ): raise ValueError( 'Path "%s" is not a file' % path ) try: f = open(path, 'rb') exce...
Python
#!/usr/bin/env python # encoding: utf-8 # Baptiste Lepilleur, 2009 from dircache import listdir import re import fnmatch import os.path # These fnmatch expressions are used by default to prune the directory tree # while doing the recursive traversal in the glob_impl method of glob function. prune_dirs = '.git .bzr ....
Python
#!/usr/bin/env python # encoding: utf-8 # Baptiste Lepilleur, 2009 from dircache import listdir import re import fnmatch import os.path # These fnmatch expressions are used by default to prune the directory tree # while doing the recursive traversal in the glob_impl method of glob function. prune_dirs = '.git .bzr ....
Python
# module
Python
import os.path import gzip import tarfile TARGZ_DEFAULT_COMPRESSION_LEVEL = 9 def make_tarball(tarball_path, sources, base_dir, prefix_dir=''): """Parameters: tarball_path: output path of the .tar.gz file sources: list of sources to include in the tarball, relative to the current directory base_dir: i...
Python
"""Tag the sandbox for release, make source and doc tarballs. Requires Python 2.6 Example of invocation (use to test the script): python makerelease.py --force --retag --platform=msvc6,msvc71,msvc80,mingw -ublep 0.5.0 0.6.0-dev Example of invocation when doing a release: python makerelease.py 0.5.0 0.6.0-dev """ imp...
Python
"""Script to generate doxygen documentation. """ import re import os import os.path import sys import shutil from devtools import tarball def find_program(*filenames): """find a program in folders path_lst, and sets env[var] @param filenames: a list of possible names of the program to search for @return: ...
Python
import sys import os import os.path import subprocess from glob import glob import optparse VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes' class TestProxy(object): def __init__( self, test_exe_path, use_valgrind=False ): self.test_exe_path = os.path.normpath( os.path.a...
Python
# removes all files created during testing import glob import os paths = [] for pattern in [ '*.actual', '*.actual-rewrite', '*.rewrite', '*.process-output' ]: paths += glob.glob( 'data/' + pattern ) for path in paths: os.unlink( path )
Python
import glob import os.path for path in glob.glob( '*.json' ): text = file(path,'rt').read() target = os.path.splitext(path)[0] + '.expected' if os.path.exists( target ): print 'skipping:', target else: print 'creating:', target file(target,'wt').write(text)
Python
# Simple implementation of a json test runner to run the test against json-py. import sys import os.path import json import types if len(sys.argv) != 2: print "Usage: %s input-json-file", sys.argv[0] sys.exit(3) input_path = sys.argv[1] base_path = os.path.splitext(input_path)[0] actual_path = base_path ...
Python
import sys import os import os.path from glob import glob import optparse VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes ' def compareOutputs( expected, actual, message ): expected = expected.strip().replace('\r','').split('\n') actual = actual.strip().replace('\r','').spli...
Python
# -*- coding:utf8 -*- import pymongo import hashlib import sys class pagedbLogic(object): def __init__(self, mongodb_config): self.connection = pymongo.MongoClient(mongodb_config['host'], mongodb_config['port']) self.database = self.connection[mongodb_config['database']] self.collection ...
Python
# -*- coding:utf-8 -*- import MySQLdb, json import os, hashlib, time import logging import sys from constants import * class linkdbLogic(object): def __init__(self, mysql_config): self.__nessary_list = [ \ (type(''), "url"), \ (type(10), "url_type"), \ (type(...
Python
# -*- coding:utf-8 -*- import MySQLdb, json import os, hashlib, time import logging import sys import linkdbLogic from constants import * if __name__ == '__main__': url = sys.argv[1] head = 'http://' if not url.startswith(head): print 'url:%s must start with %s' % (url, head) sys.exit(1) ...
Python
# error code # GENERAL E_VALUE_NONE = 1 E_KEY_NOT_EXIST = 2 E_VALUE_TYPE_ERROR = 3 E_VALUE_IS_EMPTY = 4 E_MYSQL_FAIL = 5 E_DUP_OPERATION = 6 E_DUP_CONTENT = 7 E_METHOD_NOT_EXIST = 8 # USER E_REGISTER_BASE64_DECODE_FAIL = 10000 E_REGISTER_BASE64_STRING_INVALID = 10001 E_REGISTER_ALREADY_EXIS...
Python
#!/home/xurui/opensource/python2.7/bin/python2.7 # -*- coding:utf8 -*- # -1- 向evcrawler查询当前的抓取状态 # -2- 根据各个host的抓取队列情况,开始选取1个小时左右的url列表(根据配额进行计算) # -3- 发送url列表 import socket, struct, sys, json, time import utils, linkdbLogic import logging, copy FMT_XHEAD = "I16sIIHHI" def is_valid_url(url): d = {} d['url'] =...
Python
#!/home/xurui/opensource/python2.7/bin/python2.7 # -*- coding:utf8 -*- # -1- 向evcrawler查询当前的抓取状态 # -2- 根据各个host的抓取队列情况,开始选取1个小时左右的url列表(根据配额进行计算) # -3- 发送url列表 import socket, struct, sys, json, time import utils, linkdbLogic import logging FMT_XHEAD = "I16sIIHHI" def xRequest(sock, log_id, status, dd = []): jsons...
Python
# -*- coding:utf8 -*- from tornado.tcpserver import TCPServer from tornado.ioloop import IOLoop import struct, sys import json import time import logging import hashlib import utils, linkdbLogic import os os.sys.path.append('../utils/diskset/') import diskset class Connection(object): def __init__(self, stream, a...
Python
# -*- coding:utf8 -*- from tornado.tcpserver import TCPServer from tornado.ioloop import IOLoop import struct, sys import json import time import bson import pymongo import logging import utils, pagedbLogic class Connection(object): def __init__(self, stream, address, mongo_handler): self.FMT_XHEAD = "I16...
Python
#!/home/xurui/opensource/python2.7/bin/python2.7 # -*- coding:utf8 -*- # -1- 向evcrawler查询当前的抓取状态 # -2- 根据各个host的抓取队列情况,开始选取1个小时左右的url列表(根据配额进行计算) # -3- 发送url列表 import socket, struct, sys, json, time import utils, linkdbLogic import logging, copy FMT_XHEAD = "I16sIIHHI" def is_valid_url(url): d = {} d['url'] =...
Python
# -*- coding:utf8 -*- import gzip import json import re, sys, time def get_links(page_content, host = None, inhost = True, base_url = None): # 将正则表达式编译成Pattern对象 filter_head = None if host: filter_head = 'http://%s' % host pattern = re.compile(r'<a.+?href=(.+?)>\s*(.+?)\s*</a>') #follow_url_list =...
Python
# -*- coding:utf8 -*- import sys # 只能在python3下才能执行 class chinese_number_convertor(object): def __init__(self,): self.__key_map_list = {'万':10000, \ '千':1000, \ '百':100, \ '十':10, \ '一...
Python
#!/home/xurui/opensource/python2.7/bin/python2.7 # -*- coding:utf8 -*- # -1- 向evcrawler查询当前的抓取状态 # -2- 根据各个host的抓取队列情况,开始选取1个小时左右的url列表(根据配额进行计算) # -3- 发送url列表 import socket, struct, sys, json, time import utils, linkdbLogic import logging FMT_XHEAD = "I16sIIHHI" def xRequest(sock, log_id, status, dd = []): jsons...
Python
from pydiskset import * class diskset(object): def __init__(self, data_dir, clear_flag): self._base = pydiskset(data_dir, clear_flag) def select_key(self, sign1, sign2): return select_key(self._base, sign1, sign2) def insert_key(self, sign1, sign2): return insert_key(self._base, sig...
Python
import socket, struct, sys, json, time #if len(sys.argv) != 2: # print "python test.py query" # sys.exit(1) def send_all(sock, log_id, jsonstr): sbuf = struct.pack(FMT_XHEAD, log_id, "selector", 0, 0, 0, len(jsonstr)) sbuf += jsonstr ret = sock.send(sbuf) print "send %d bytes" % ret rbuf = s...
Python
import socket, struct, sys, json, time #if len(sys.argv) != 2: # print "python test.py query" # sys.exit(1) def send_all(sock, log_id, dd): jsonstr = json.dumps(dd) sbuf = struct.pack(FMT_XHEAD, log_id, "selector", 0, 0, 0, len(jsonstr)) sbuf += jsonstr ret = sock.send(sbuf) print "send %d b...
Python
#!/usr/bin/env python # # Copyright 2007 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law o...
Python
#!/usr/bin/python2.6 # # Simple http server to emulate api.playfoursquare.com import logging import shutil import sys import urlparse import SimpleHTTPServer import BaseHTTPServer class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): """Handle playfoursquare.com requests, for testing.""" def do_GET(self...
Python
#!/usr/bin/python import datetime import sys import textwrap import common from xml.dom import pulldom PARSER = """\ /** * Copyright 2009 Joe LaPenna */ package com.joelapenna.foursquare.parsers; import com.joelapenna.foursquare.Foursquare; import com.joelapenna.foursquare.error.FoursquareError; import com.joel...
Python
#!/usr/bin/python """ Pull a oAuth protected page from foursquare. Expects ~/.oget to contain (one on each line): CONSUMER_KEY CONSUMER_KEY_SECRET USERNAME PASSWORD Don't forget to chmod 600 the file! """ import httplib import os import re import sys import urllib import urllib2 import urlparse import user from xml....
Python
#!/usr/bin/python import os import subprocess import sys BASEDIR = '../main/src/com/joelapenna/foursquare' TYPESDIR = '../captures/types/v1' captures = sys.argv[1:] if not captures: captures = os.listdir(TYPESDIR) for f in captures: basename = f.split('.')[0] javaname = ''.join([c.capitalize() for c in basena...
Python
#!/usr/bin/python import logging from xml.dom import minidom from xml.dom import pulldom BOOLEAN = "boolean" STRING = "String" GROUP = "Group" # Interfaces that all FoursquareTypes implement. DEFAULT_INTERFACES = ['FoursquareType'] # Interfaces that specific FoursqureTypes implement. INTERFACES = { } DEFAULT_CLA...
Python
from distutils.core import setup import os from psshlib import version long_description = """PSSH (Parallel SSH) provides parallel versions of OpenSSH and related tools, including pssh, pscp, prsync, pnuke, and pslurp. The project includes psshlib which can be used within custom applications.""" setup( name = "p...
Python
# Copyright (c) 2009-2012, Andrew McNabb from errno import EINTR from subprocess import Popen, PIPE import os import signal import sys import time import traceback from psshlib import askpass_client from psshlib import color BUFFER_SIZE = 1 << 16 try: bytes except NameError: bytes = str class Task(object)...
Python
#!/usr/bin/env python # -*- Mode: python -*- # Copyright (c) 2009-2012, Andrew McNabb """Sends the password over a socket to askpass. """ import errno import getpass import os import socket import sys import tempfile import textwrap from psshlib import psshutil class PasswordServer(object): """Listens on a UN...
Python
# Copyright (c) 2009-2012, Andrew McNabb # Copyright (c) 2003-2008, Brent N. Chun import fcntl import string import sys HOST_FORMAT = 'Host format is [user@]host[:port] [user]' def read_host_files(paths, default_user=None, default_port=None): """Reads the given host files. Returns a list of (host, port, us...
Python
# Copyright (c) 2009-2012, Andrew McNabb # Copyright (c) 2003-2008, Brent N. Chun def with_color(string, fg, bg=49): '''Given foreground/background ANSI color codes, return a string that, when printed, will format the supplied string using the supplied colors. ''' return "\x1b[%dm\x1b[%dm%s\x1b[39m\x1b...
Python
VERSION = '2.3.1'
Python
#!/usr/bin/env python # -*- Mode: python -*- # Copyright (c) 2009-2012, Andrew McNabb """Implementation of SSH_ASKPASS to get a password to ssh from pssh. The password is read from the socket specified by the environment variable PSSH_ASKPASS_SOCKET. The other end of this socket is pssh. The ssh man page discusses...
Python
# Copyright (c) 2009-2012, Andrew McNabb from errno import EINTR import os import select import signal import sys import threading try: import queue except ImportError: import Queue as queue from psshlib.askpass_server import PasswordServer from psshlib import psshutil READ_SIZE = 1 << 16 class FatalError...
Python