Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit 86e04ea9eaf7b0f96f6fc8c3d4b5d526d26208ce Eric Gaumer committed Feb 10, 2010
Showing 548 changed files with 287,250 additions and 0 deletions.
@@ -0,0 +1,14 @@
+syntax: glob
+*.o
+*.pyc
+*.pyo
+.project
+.pydevproject
+develop-eggs
+eggs
+parts
+.installed.cfg
+*.ini
+plugins
+pypesvds.log
+data
@@ -0,0 +1,43 @@
+Requirements:
+
+ pypesvds requires stackless Python >= 2.6
+
+ Downloads:
+
+ - OS X: http://www.stackless.com/binaries/stackless-2.6.2-macosx2009-06-09.dmg
+ - Win32: http://www.stackless.com/binaries/python-2.6.2-stackless.msi
+ - Linux: http://www.stackless.com/binaries/stackless-262-export.tar.bz2
+
+ If you have Python already installed, the stackless installer will replace
+ the current version if they match (you can also have multiple versions).
+
+ Stackless Python is an extension of the regular Python interpreter. Any
+ existing Python code will run with any modifications. Stackless simply
+ adds some extra capabilities to regaulr Python.
+
+To install pypesvds buildout:
+
+ $ python bootstrap.py # run bootstrap
+ $ bin/buildout # run buildout
+ $ bin/paster make-config pypesvds production.ini # create distudio ini config
+ $ bin/paster setup-app production.ini # setup app/custom plugin env
+ $ bin/paster serve production.ini # start pypesvds
+
+To install pypesvds source buildout:
+
+ $ tar xzf pypesvds.tar.gz # unpack the download
+ $ cd pypesvds # change directories
+ $ python install.py (need stackless >= 2.6) # run the installer
+ $ bin/paster make-config pypesvds production.ini # create distudio ini config
+ $ bin/paster setup-app production.ini # setup app/custom plugin env
+ $ bin/paster serve production.ini # start pypesvds
+
+To create a custom component (project):
+
+ $ bin/paster create --list-templates # shows templates available
+ $ bin/paster create -t studio_plugin myplugin # creates "myplugin" component project
+ $ cd myplugin # change directories
+ $ vim myplugin/myplugin.py # write your component logic
+ $ ../bin/python setup.py bdist_egg # build the project
+ $ cp dist/myplugin-0.1-py2.6.egg ../plugins # place the built component in your plugins directory
+
@@ -0,0 +1,153 @@
+#!/usr/bin/env python
+
+import urllib
+import urllib2
+import mimetools, mimetypes
+import os, stat
+from os.path import join
+import sys
+import getopt
+from cStringIO import StringIO
+import zlib
+
+class Callable:
+ def __init__(self, anycallable):
+ self.__call__ = anycallable
+
+# Controls how sequences are uncoded. If true, elements
+# may be given multiple values by assigning a sequence.
+doseq = 1
+
+class MultipartPostHandler(urllib2.BaseHandler):
+ handler_order = urllib2.HTTPHandler.handler_order - 10 # needs to run first
+
+ def http_request(self, request):
+ data = request.get_data()
+ if data is not None and type(data) != str:
+ v_files = []
+ v_vars = []
+ try:
+ for(key, value) in data.items():
+ if type(value) == file:
+ v_files.append((key, value))
+ else:
+ v_vars.append((key, value))
+ except TypeError:
+ systype, value, traceback = sys.exc_info()
+ raise TypeError, "not a valid non-string sequence or mapping object", traceback
+
+ if len(v_files) == 0:
+ data = urllib.urlencode(v_vars, doseq)
+ else:
+ boundary, data = self.multipart_encode(v_vars, v_files)
+
+ contenttype = 'multipart/form-data; boundary=%s' % boundary
+ if(request.has_header('Content-Type')
+ and request.get_header('Content-Type').find('multipart/form-data') != 0):
+ print "Replacing %s with %s" % (request.get_header('content-type'), 'multipart/form-data')
+ request.add_unredirected_header('Content-Type', contenttype)
+
+ if compress:
+ request.add_unredirected_header('Content-Encoding', 'gzip')
+
+ request.add_data(data)
+
+ return request
+
+ def multipart_encode(vars, files, boundary = None, buf = None):
+ if boundary is None:
+ boundary = mimetools.choose_boundary()
+ if buf is None:
+ buf = StringIO()
+ for(key, value) in vars:
+ buf.write('--%s\r\n' % boundary)
+ buf.write('Content-Disposition: form-data; name="%s"' % key)
+ buf.write('\r\n\r\n' + value + '\r\n')
+ for(key, fd) in files:
+ file_size = os.fstat(fd.fileno())[stat.ST_SIZE]
+ filename = fd.name.split('/')[-1:][0]
+ contenttype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
+ buf.write('--%s\r\n' % boundary)
+ buf.write('Content-Disposition: form-data; name="%s"; filename="%s"\r\n' % (key, filename))
+ buf.write('Content-Type: %s\r\n' % contenttype)
+
+ fd.seek(0)
+ if compress:
+ buf.write('\r\n' + zlib.compress(fd.read()) + '\r\n')
+ else:
+ buf.write('\r\n' + fd.read() + '\r\n')
+
+ buf.write('--' + boundary + '--\r\n\r\n')
+ buf = buf.getvalue()
+ return boundary, buf
+ multipart_encode = Callable(multipart_encode)
+
+ https_request = http_request
+
+if __name__=="__main__":
+ usage = """Usage: FileCrawler [options] root_dir
+
+Options:
+ -h HOST Set the hostname
+ -p PORT Set the port
+ -u PATH Set the path
+ -e EXTENSIONS Comma separated list of extensions to crawl
+ -r Recursively crawl
+ -c Compress data
+"""
+
+ try:
+ count = 1
+ opts, args = getopt.getopt(sys.argv[1:], "h:p:u:e:rcv")
+ except:
+ print usage
+ else:
+ host = 'localhost'
+ port = 5000
+ path = '/docs'
+ extensions = []
+ recursive = False
+ compress = False
+ verbose = False
+ for option, arg in opts:
+ if option == '-h':
+ host = arg
+ elif option == '-p':
+ port = arg
+ elif option == '-u':
+ path = arg
+ elif option == '-e':
+ try:
+ extensions = ['.%s' % x.strip() for x in arg.split(',') if x]
+ except:
+ assert False, 'Invalid extensions: %s' % arg
+ elif option == '-r':
+ recursive = True
+ elif option == '-c':
+ compress = True
+ elif option == '-v':
+ verbose = True
+ else:
+ assert False, 'Invalid option: %s' % o
+
+ if len(args) != 1:
+ print usage
+ else:
+ dir = args[0]
+ url = 'http://%s:%s%s' % (host, port, path)
+
+ for root, dirs, files in os.walk(dir):
+
+ if recursive == False and root != dir:
+ continue
+
+ for name in files:
+ if not extensions or name[name.rfind('.'):] in extensions:
+ fpath = join(root, name)
+ if verbose:
+ print '%s%s' % (('%s:' % count).ljust(15), fpath)
+
+ params = { "document" : open(fpath, 'rb') }
+ poster = urllib2.build_opener(MultipartPostHandler)
+ poster.open(url, params)
+ count += 1
@@ -0,0 +1,121 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id: bootstrap.py 105417 2009-11-01 15:15:20Z tarek $
+"""
+
+import os, shutil, sys, tempfile, urllib2
+from optparse import OptionParser
+
+tmpeggs = tempfile.mkdtemp()
+
+is_jython = sys.platform.startswith('java')
+
+# parsing arguments
+parser = OptionParser()
+parser.add_option("-v", "--version", dest="version",
+ help="use a specific zc.buildout version")
+parser.add_option("-d", "--distribute",
+ action="store_true", dest="distribute", default=False,
+ help="Use Disribute rather than Setuptools.")
+
+parser.add_option("-c", None, action="store", dest="config_file",
+ help=("Specify the path to the buildout configuration "
+ "file to be used."))
+
+options, args = parser.parse_args()
+
+# if -c was provided, we push it back into args for buildout' main function
+if options.config_file is not None:
+ args += ['-c', options.config_file]
+
+if options.version is not None:
+ VERSION = '==%s' % options.version
+else:
+ VERSION = ''
+
+USE_DISTRIBUTE = options.distribute
+args = args + ['bootstrap']
+
+to_reload = False
+try:
+ import pkg_resources
+ if not hasattr(pkg_resources, '_distribute'):
+ to_reload = True
+ raise ImportError
+except ImportError:
+ ez = {}
+ if USE_DISTRIBUTE:
+ exec urllib2.urlopen('http://python-distribute.org/distribute_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0, no_fake=True)
+ else:
+ exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+ if to_reload:
+ reload(pkg_resources)
+ else:
+ import pkg_resources
+
+if sys.platform == 'win32':
+ def quote(c):
+ if ' ' in c:
+ return '"%s"' % c # work around spawn lamosity on windows
+ else:
+ return c
+else:
+ def quote (c):
+ return c
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+ws = pkg_resources.working_set
+
+if USE_DISTRIBUTE:
+ requirement = 'distribute'
+else:
+ requirement = 'setuptools'
+
+if is_jython:
+ import subprocess
+
+ assert subprocess.Popen([sys.executable] + ['-c', quote(cmd), '-mqNxd',
+ quote(tmpeggs), 'zc.buildout' + VERSION],
+ env=dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse(requirement)).location
+ ),
+ ).wait() == 0
+
+else:
+ assert os.spawnle(
+ os.P_WAIT, sys.executable, quote (sys.executable),
+ '-c', quote (cmd), '-mqNxd', quote (tmpeggs), 'zc.buildout' + VERSION,
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse(requirement)).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout' + VERSION)
+import zc.buildout.buildout
+zc.buildout.buildout.main(args)
+shutil.rmtree(tmpeggs)
@@ -0,0 +1,14 @@
+[buildout]
+develop = core ui
+parts = eggs
+
+[eggs]
+recipe = zc.recipe.egg:scripts
+interpreter = python
+eggs = pypesvds
+ pastescript
+
+[release]
+recipe = zc.recipe.egg:script
+eggs = zc.sourcerelease
+
@@ -0,0 +1,2 @@
+recursive-include examples *
+recursive-include api-docs *
Oops, something went wrong.

0 comments on commit 86e04ea

Please sign in to comment.