def make_connection(self, url): uses_netloc.append('unix') scheme, netloc, path, query, frag = urlparse.urlsplit(url) host, port = urllib.splitport(netloc) if netloc: addrinfo = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM) sock = socket.socket(*addrinfo[0][:3]) sock.connect(addrinfo[0][4]) else: sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(path) return sock
# -*- coding: utf-8 -*- # straight from http://pydenji.franzoni.eu . Didn't want to enlarge dependencies right now. from urlparse import urlparse, uses_netloc from pkg_resources import resource_filename, Requirement #TODO: remove this sort of "static initializer" if "pkg" not in uses_netloc: uses_netloc.append("pkg") def file_uri_resolver(parsed_uri): if not parsed_uri.path.startswith("/"): raise ValueError, "Relative paths are not supported." if parsed_uri.netloc: raise ValueError, "Netloc in file scheme is unsupported." return parsed_uri.path def package_uri_resolver(parsed_uri): return resource_filename(parsed_uri.netloc, parsed_uri.path) def requirement_uri_resolver(parsed_uri): return resource_filename(Requirement.parse(parsed_uri.netloc), parsed_uri.path) supported_schemes = { "file" : file_uri_resolver, "" : file_uri_resolver, "pkg": package_uri_resolver, "req": requirement_uri_resolver, } def resource_filename_resolver(resource_uri):
import os from urlparse import urlparse, uses_netloc from django.conf import settings as django_settings uses_netloc.append('redis') PROCFILE = os.environ.get('PROCFILE', './Procfile') IRON_MQ_PROJECT_ID = getattr(django_settings, 'IRON_MQ_PROJECT_ID', None) IRON_MQ_TOKEN = getattr(django_settings, 'IRON_MQ_TOKEN', None) IRON_MQ_HOST = getattr(django_settings, 'IRON_MQ_HOST', None) HEROKU_API_KEY = os.environ.get('HEROKU_API_KEY', False) HEROKU_APPNAME = os.environ.get('HEROKU_APPNAME', False) HEROKU_SCALAR_SHUTDOWN_RETRY = int( os.environ.get('HEROKU_SCALAR_SHUTDOWN_RETRY', 10)) proc_scalar_lock_url = urlparse( os.environ.get( 'PROC_SCALAR_LOCK_DB', 'redis://PLEASE_SET_YOUR_PROC_SCALAR_LOCL_DB-ENV:999/please')) redis_queue_url = urlparse( getattr(django_settings, 'BROKER_URL', 'redis://PLEASE_SET_YOUR_BROKER_URL:999//please')) assert redis_queue_url, "no redis_queue_url configured in your django settings"
def extension(args, console): """Build the browser extensions. Accepts one (optional) argument which is the base URL of an h server.""" if len(args) == 0: console.error('You must supply a paste configuration file.') return 2 if len(args) < 2: console.error('You must supply a url to the hosted backend.') return 2 from codecs import open from os import makedirs from os.path import abspath, exists, join from shutil import copyfile, copytree, rmtree from urlparse import ( urljoin, urlparse, urlunparse, uses_netloc, uses_relative, ) from chameleon.zpt.template import PageTextTemplateFile from pyramid.path import AssetResolver from pyramid.renderers import get_renderer, render from pyramid.settings import asbool from pyramid_webassets import IWebAssetsEnvironment from h import bootstrap, layouts resolve = AssetResolver().resolve def make_relative(request, url): assets_url = request.webassets_env.url if url.startswith(assets_url): return url[len(assets_url):].strip('/') return url def app(env, base_url=None): asset_env = env['registry'].queryUtility(IWebAssetsEnvironment) request = env['request'] context = request.context base_template = get_renderer('h:templates/base.pt').implementation() api_url = request.registry.settings.get('api.url', None) api_url = api_url or urljoin(request.host_url, '/api') app_layout = layouts.SidebarLayout(context, request) app_page = render( 'h:templates/app.pt', { 'base_url': base_url, 'layout': { 'css_links': app_layout.css_links, 'js_links': app_layout.js_links, 'csp': '', 'inline_webfont': False, }, 'main_template': base_template, 'request': request, 'service_url': api_url, } ) app_html_file = join(asset_env.directory, 'app.html') with open(app_html_file, 'w', 'utf-8-sig') as f: f.write(app_page) def chrome(env): registry = env['registry'] request = env['request'] asset_env = registry.queryUtility(IWebAssetsEnvironment) settings = registry.settings develop = asbool(settings.get('webassets.debug', False)) # Root the request at the app url app_url = urlparse(args[1]) request.host = app_url.netloc request.scheme = app_url.scheme app_url = urlunparse(app_url) # Fully-qualify the static asset url asset_url = urlparse(asset_env.url) if not asset_url.netloc: asset_url = ( request.scheme, request.host, asset_url.path, asset_url.params, asset_url.query, asset_url.fragment, ) asset_url = urlunparse(asset_url) # Configure the load path and output url asset_env.append_path(resolve('h:').abspath(), asset_url) asset_env.url = asset_url def getUrl(url): if not develop: rel = make_relative(request, url) if rel != url: return "chrome.extension.getURL('public/%s')" % rel return '"%s"' % url if develop: # Load the app from the development server. app_expr = "'%s'" % app_url else: # Load the app from the extension bundle. app_expr = "chrome.extension.getURL('public/app.html')" # Build the app html app(env, base_url=app_url) embed = render( 'h:templates/embed.txt', { 'app': app_expr, 'inject': '[%s]' % ', '.join([ getUrl(url) for url in asset_env['inject'].urls() ]), 'jquery': getUrl(asset_env['jquery'].urls()[0]), 'raf': getUrl(asset_env['raf'].urls()[0]), }, request=request, ) embed_js_file = join(asset_env.directory, 'js/embed.js') with open(embed_js_file, 'w', 'utf-8-sig') as f: f.write(embed) # Chrome is strict about the format of the version string ext_version = '.'.join(version.replace('-', '.').split('.')[:4]) manifest_file = resolve('h:browser/chrome/manifest.json').abspath() manifest_renderer = PageTextTemplateFile(manifest_file) manifest = manifest_renderer(src=asset_url, version=ext_version) manifest_json_file = join('./build/chrome', 'manifest.json') with open(manifest_json_file, 'w', 'utf-8-sig') as f: f.write(manifest) # Due to Content Security Policy, the web font script cannot be inline. webfont = resolve('h:templates/webfont.js').abspath() copyfile(webfont, join(asset_env.directory, 'webfont.js')) # Make sure the common build dir exists if not exists('./build'): makedirs('./build') # Build the chrome extension if exists('./build/chrome'): rmtree('./build/chrome') copytree(resolve('h:browser/chrome').abspath(), './build/chrome') copytree(resolve('h:images').abspath(), './build/chrome/public/images') copytree(resolve('h:lib').abspath(), './build/chrome/public/lib') settings = {'webassets.base_dir': abspath('./build/chrome/public')} # Override static asset route generation with the STATIC_URL argument if len(args) > 2: settings.update({ 'webassets.base_url': args[2], }) # Make sure urlparse understands chrome-extension:// URLs uses_netloc.append('chrome-extension') uses_relative.append('chrome-extension') bootstrap(args[0], options=settings, config_fn=chrome)
version = __version__ description = """\ The Hypothesis Project Annotation System """ command = App( 'hypothesis', version=version, description=description, args_callback=get_config, ) # Teach urlparse about extension schemes uses_netloc.append('chrome-extension') uses_relative.append('chrome-extension') uses_netloc.append('resource') uses_relative.append('resource') # Fetch an asset spec resolver resolve = AssetResolver().resolve def add_base_url(event): request = event['request'] assets_env = request.webassets_env view_name = getattr(request, 'view_name', None) if (view_name == 'embed.js'
version = __version__ description = """\ The Hypothes.is Project Annotation System """ command = App( 'hypothesis', version=version, description=description, opts=pserve.PServeCommand.parser.option_list[1:], args_callback=get_config, ) # Teach urlparse about extension schemes uses_netloc.append('chrome-extension') uses_relative.append('chrome-extension') # Fetch an asset spec resolver resolve = AssetResolver().resolve def add_base_url(event): request = event['request'] assets_env = request.webassets_env view_name = getattr(request, 'view_name', None) if view_name == 'embed.js' and not assets_env.debug: base_url = join(request.webassets_env.url, 'app.html') else:
# You must obey the GNU General Public License in all respects for # all of the code used other than OpenSSL. If you modify file(s) # with this exception, you may extend this exception to your version # of the file(s), but you are not obligated to do so. If you do not # wish to do so, delete this exception statement from your version. # If you delete this exception statement from all source files in the # program, then also delete it here. # # Contact: Glenn Washburn <*****@*****.**> import sys, cStringIO as StringIO import xmlrpclib, urllib, urlparse, socket # this allows us to parse scgi urls just like http ones from urlparse import uses_netloc uses_netloc.append('scgi') def do_scgi_xmlrpc_request(host, methodname, params=()): """ Send an xmlrpc request over scgi to host. host: scgi://host:port/path methodname: xmlrpc method name params: tuple of simple python objects returns: xmlrpc response """ xmlreq = xmlrpclib.dumps(params, methodname) xmlresp = SCGIRequest(host).send(xmlreq) #~ print xmlresp return xmlresp
return dict(settings=settings) version = __version__ description = """\ The Hypothesis Project Annotation System """ command = App( 'hypothesis', version=version, description=description, args_callback=get_config, ) # Teach urlparse about extension schemes uses_netloc.append('chrome-extension') uses_relative.append('chrome-extension') uses_netloc.append('resource') uses_relative.append('resource') # Fetch an asset spec resolver resolve = AssetResolver().resolve def add_base_url(event): request = event['request'] assets_env = request.webassets_env view_name = getattr(request, 'view_name', None) if (view_name == 'embed.js' and
import sys if sys.version_info[0] == 2: from urlparse import urlparse # workaround for http://bugs.python.org/issue7904 - Python < 2.7 if urlparse('s3://bucket/key').netloc != 'bucket': from urlparse import uses_netloc uses_netloc.append('s3') # workaround for http://bugs.python.org/issue9374 - Python < 2.7.4 if urlparse('s3://bucket/key?key=value').query != 'key=value': from urlparse import uses_query uses_query.append('s3')
from os import environ from urlparse import uses_netloc, urlparse from peewee import Model, MySQLDatabase, CharField, TextField, \ CompositeKey, PostgresqlDatabase __author__ = "Jeffrey Chan" """The database type is defined here. For development, I have used a MySQL DB, but the production version of this app uses a Heroku Postgres DB. If you need to change the DB for whatever reason, just change the line defining "db", providing the neccesary information to connect to that database. """ if "HEROKU" in environ: uses_netloc.append("postgres") url = urlparse(environ["DATABASE_URL"]) DATABASE = { "name": url.path[1:], "user": url.username, "password": url.password, "host": url.hostname, "port": url.port, } db = PostgresqlDatabase(DATABASE["name"], user=DATABASE["user"], password=DATABASE["password"], host=DATABASE["host"], port=DATABASE["port"]) db.get_conn().set_client_encoding('UTF8') else: db = MySQLDatabase("fbCalDB", user="******")
# -*- coding: utf-8 -*- # straight from http://pydenji.franzoni.eu . Didn't want to enlarge dependencies right now. from urlparse import urlparse, uses_netloc from pkg_resources import resource_filename, Requirement #TODO: remove this sort of "static initializer" if "pkg" not in uses_netloc: uses_netloc.append("pkg") def file_uri_resolver(parsed_uri): if not parsed_uri.path.startswith("/"): raise ValueError, "Relative paths are not supported." if parsed_uri.netloc: raise ValueError, "Netloc in file scheme is unsupported." return parsed_uri.path def package_uri_resolver(parsed_uri): return resource_filename(parsed_uri.netloc, parsed_uri.path) def requirement_uri_resolver(parsed_uri): return resource_filename(Requirement.parse(parsed_uri.netloc), parsed_uri.path) supported_schemes = { "file": file_uri_resolver, "": file_uri_resolver,
def extension(args, console): """Build the browser extensions. Accepts one (optional) argument which is the base URL of an h server.""" if len(args) == 0: console.error('You must supply a paste configuration file.') return 2 if len(args) < 2: console.error('You must supply a url to the hosted backend.') return 2 from codecs import open from os import makedirs from os.path import abspath, exists, join from shutil import copyfile, copytree, rmtree from urlparse import ( urljoin, urlparse, urlunparse, uses_netloc, uses_relative, ) from chameleon.zpt.template import PageTextTemplateFile from pyramid.path import AssetResolver from pyramid.renderers import get_renderer, render from pyramid.settings import asbool from pyramid_webassets import IWebAssetsEnvironment from h import bootstrap, layouts resolve = AssetResolver().resolve def make_relative(request, url): assets_url = request.webassets_env.url if url.startswith(assets_url): return url[len(assets_url):].strip('/') return url def app(env, base_url=None): asset_env = env['registry'].queryUtility(IWebAssetsEnvironment) request = env['request'] context = request.context base_template = get_renderer('h:templates/base.pt').implementation() api_url = request.registry.settings.get('api.url', None) api_url = api_url or urljoin(request.host_url, '/api/') app_layout = layouts.SidebarLayout(context, request) app_page = render( 'h:templates/app.pt', { 'base_url': base_url, 'layout': { 'css_links': app_layout.css_links, 'js_links': app_layout.js_links, 'csp': '', 'inline_webfont': False, }, 'main_template': base_template, 'request': request, 'service_url': api_url, }) app_html_file = join(asset_env.directory, 'app.html') with open(app_html_file, 'w', 'utf-8-sig') as f: f.write(app_page) def chrome(env): registry = env['registry'] request = env['request'] asset_env = registry.queryUtility(IWebAssetsEnvironment) settings = registry.settings develop = asbool(settings.get('webassets.debug', False)) # Root the request at the app url app_url = urlparse(args[1]) request.host = app_url.netloc request.scheme = app_url.scheme app_url = urlunparse(app_url) # Fully-qualify the static asset url asset_url = urlparse(asset_env.url) if not asset_url.netloc: asset_url = ( request.scheme, request.host, asset_url.path, asset_url.params, asset_url.query, asset_url.fragment, ) asset_url = urlunparse(asset_url) # Configure the load path and output url asset_env.append_path(resolve('h:').abspath(), asset_url) asset_env.url = asset_url def getUrl(url): if not develop: rel = make_relative(request, url) if rel != url: return "chrome.extension.getURL('public/%s')" % rel return '"%s"' % url if develop: # Load the app from the development server. app_expr = json.dumps(app_url) else: # Load the app from the extension bundle. app_expr = "chrome.extension.getURL('public/app.html')" # Build the app html app(env, base_url=app_url) embed = render( 'h:templates/embed.txt', { 'app': app_expr, 'options': json.dumps({ 'Heatmap': { "container": '.annotator-frame', }, 'Toolbar': { 'container': '.annotator-frame', }, }), 'role': json.dumps('host'), 'inject': '[%s]' % ', '.join([getUrl(url) for url in asset_env['inject'].urls()]), 'jquery': getUrl(asset_env['jquery'].urls()[0]), 'raf': getUrl(asset_env['raf'].urls()[0]), }, request=request, ) embed_js_file = join(asset_env.directory, 'js/embed.js') with open(embed_js_file, 'w', 'utf-8-sig') as f: f.write(embed) # Chrome is strict about the format of the version string ext_version = '.'.join(version.replace('-', '.').split('.')[:4]) manifest_file = resolve('h:browser/chrome/manifest.json').abspath() manifest_renderer = PageTextTemplateFile(manifest_file) manifest = manifest_renderer(src=asset_url, version=ext_version) manifest_json_file = join('./build/chrome', 'manifest.json') with open(manifest_json_file, 'w', 'utf-8-sig') as f: f.write(manifest) # Due to Content Security Policy, the web font script cannot be inline. webfont = resolve('h:templates/webfont.js').abspath() copyfile(webfont, join(asset_env.directory, 'webfont.js')) # Make sure the common build dir exists if not exists('./build'): makedirs('./build') # Build the chrome extension if exists('./build/chrome'): rmtree('./build/chrome') copytree(resolve('h:browser/chrome').abspath(), './build/chrome') copytree(resolve('h:images').abspath(), './build/chrome/public/images') copytree(resolve('h:lib').abspath(), './build/chrome/public/lib') settings = {'webassets.base_dir': abspath('./build/chrome/public')} # Override static asset route generation with the STATIC_URL argument if len(args) > 2: settings.update({ 'webassets.base_url': args[2], }) # Make sure urlparse understands chrome-extension:// URLs uses_netloc.append('chrome-extension') uses_relative.append('chrome-extension') bootstrap(args[0], options=settings, config_fn=chrome)
import socket import select import ssl import os # from pprint import pprint from urlparse import urlparse, uses_netloc uses_netloc.append("rendezvous") class InvalidResponseFromRendezVous(Exception): pass class Rendezvous: def __init__(self, url, printout=False): self.url = url urlp = urlparse(url) self.hostname = urlp.hostname self.port = urlp.port self.secret = urlp.path[1:] path = os.path.dirname(os.path.realpath(__file__)) self.cert = os.path.abspath("{0}/data/cacert.pem".format(path)) self.data = "" self.printout = printout def start(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
import sys from urlparse import urlparse, uses_netloc import redis import os uses_netloc.append('redis') CELERY_HOSTNAME = os.environ.get('CELERY_HOSTNAME', False) PROC_SCALAR_LOCK_DB = os.environ.get('PROC_SCALAR_LOCK_DB', False) if not PROC_SCALAR_LOCK_DB: raise ValueError('env var PROC_SCALAR_LOCK_DB not set') assert(CELERY_HOSTNAME) proc_scalar_lock_db = urlparse(PROC_SCALAR_LOCK_DB) lock = redis.StrictRedis( host=proc_scalar_lock_db.hostname, port=int(proc_scalar_lock_db.port), db=int(proc_scalar_lock_db.path[1:]), password=proc_scalar_lock_db.password ) print "Using LOCKDB of %s" % PROC_SCALAR_LOCK_DB DISABLE_CELERY = lock.get('DISABLE_CELERY_%s' % CELERY_HOSTNAME) if DISABLE_CELERY and DISABLE_CELERY != '0': print "Celery disabled for %s exiting..." % DISABLE_CELERY sys.exit(0) else: print "Celery enabled(%s) running..." % DISABLE_CELERY
LOCAL_SERVE = False TEMPLATE_DEBUG = True # Temporarily overriding admins for error mailing ADMINS = MANAGERS = (("Damon Jablons", '*****@*****.**'), ) # Email Settings EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_PORT = 587 EMAIL_HOST_USER = env('SENDGRID_USERNAME', '') EMAIL_HOST_PASSWORD = env('SENDGRID_PASSWORD', '') EMAIL_SUBJECT_PREFIX = "[ pxlpng.com ] " EMAIL_USE_TLS = True SERVER_EMAIL = env('SENDGRID_USERNAME', '') uses_netloc.append('postgres') uses_netloc.append('mysql') try: if 'DATABASE_URL' in environ: url = urlparse(environ['DATABASE_URL']) DATABASES['default'] = { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': url.path[1:], 'USER': url.username, 'PASSWORD': url.password, 'HOST': url.hostname, 'PORT': url.port, } except:
import dj_database_url ####################################################################################################################### # MISCELLANEOUS SETTINGS # ####################################################################################################################### # Provide a dummy translation function without importing it from # django.utils.translation, because that module is depending on # settings itself possibly resulting in a circular import gettext_noop = lambda s: s # Don't share this with anybody SECRET_KEY = os.environ.get('SECRET_KEY', 'my-secret-key') # Register database scheme and redis caching in URLs uses_netloc.append('postgres') uses_netloc.append('redis') # Turn 0 or 1 into False/True respectively boolean = lambda value: bool(int(value)) # Get local path for any given folder/path local_path = lambda path: os.path.join(os.path.dirname(__file__), os.pardir, path) ####################################################################################################################### # DJANGO CONFIG # ####################################################################################################################### # Try to read as much configuration from ENV DEBUG = boolean(os.environ.get('DEBUG', 0)) TEMPLATE_DEBUG = boolean(os.environ.get('DEBUG', DEBUG))
# all of the code used other than OpenSSL. If you modify file(s) # with this exception, you may extend this exception to your version # of the file(s), but you are not obligated to do so. If you do not # wish to do so, delete this exception statement from your version. # If you delete this exception statement from all source files in the # program, then also delete it here. # # Contact: Glenn Washburn <*****@*****.**> import sys, cStringIO as StringIO import xmlrpclib, urllib, urlparse, socket # this allows us to parse scgi urls just like http ones from urlparse import uses_netloc uses_netloc.append("scgi") def do_scgi_xmlrpc_request(host, methodname, params=()): """ Send an xmlrpc request over scgi to host. host: scgi://host:port/path methodname: xmlrpc method name params: tuple of simple python objects returns: xmlrpc response """ xmlreq = xmlrpclib.dumps(params, methodname) xmlresp = SCGIRequest(host).send(xmlreq) # ~ print xmlresp return xmlresp
UNSUPPORTED_CONTENT_FORMAT, INTERNAL_SERVER_ERROR, BAD_GATEWAY, GATEWAY_TIMEOUT, VALID, CHANGED) from openmtc_etsi import exc as e_exc from openmtc_onem2m import exc as o_exc from openmtc_server.Plugin import Plugin from openmtc_server.configuration import (Configuration, ListOption, SimpleOption, BooleanOption) from openmtc_server.exc import ConfigurationError from openmtc_server.platform.gevent.ServerRack import GEventServerRack from openmtc_server.transportdomain import (RequestMethod, Response, ErrorResponse, Connector) from .server import CoapServer uses_relative.append('coap') uses_netloc.append('coap') class ConnectorConfiguration(Configuration): __name__ = "Connector configuration" __options__ = {"interface": SimpleOption(default=""), "host": SimpleOption(default=None), "port": SimpleOption(int), "is_wan": BooleanOption(default=None)} class CoAPTransportPluginGatewayConfiguration(Configuration): __name__ = "CoAPTransportPluginGatewayConfiguration configuration" __options__ = { "connectors": ListOption(ConnectorConfiguration, default=(
# You must obey the GNU General Public License in all respects for # all of the code used other than OpenSSL. If you modify file(s) # with this exception, you may extend this exception to your version # of the file(s), but you are not obligated to do so. If you do not # wish to do so, delete this exception statement from your version. # If you delete this exception statement from all source files in the # program, then also delete it here. # # Contact: Glenn Washburn <*****@*****.**> import sys, cStringIO as StringIO import xmlrpclib, urllib, urlparse, socket # this allows us to parse scgi urls just like http ones from urlparse import uses_netloc uses_netloc.append('scgi') def encode_netstring(string): "Encode string as netstring" return '%d:%s,'%(len(string), string) def make_headers(headers): "Make scgi header list" return '\x00'.join(headers)+'\x00' def convert_xmlrpc2sgi_req(xmlreq): "Wrap xmlrpc request in an scgi request,\nsee spec at: http://python.ca/scgi/protocol.txt" # See spec at: http://python.ca/scgi/protocol.txt headers = make_headers([ 'CONTENT_LENGTH', str(len(xmlreq)), 'SCGI', '1',
import sys from six.moves import copyreg if sys.version_info[0] == 2: from urlparse import urlparse # workaround for http://bugs.python.org/issue7904 - Python < 2.7 if urlparse('s3://bucket/key').netloc != 'bucket': from urlparse import uses_netloc uses_netloc.append('s3') # workaround for http://bugs.python.org/issue9374 - Python < 2.7.4 if urlparse('s3://bucket/key?key=value').query != 'key=value': from urlparse import uses_query uses_query.append('s3') # Undo what Twisted's perspective broker adds to pickle register # to prevent bugs like Twisted#7989 while serializing requests import twisted.persisted.styles # NOQA # Remove only entries with twisted serializers for non-twisted types. for k, v in frozenset(copyreg.dispatch_table.items()): if not str(getattr(k, '__module__', '')).startswith('twisted') \ and str(getattr(v, '__module__', '')).startswith('twisted'): copyreg.dispatch_table.pop(k)
import sys import os # assume we are ./apps/mainsite/settings.py from urlparse import urlparse, uses_netloc uses_netloc.append('postgres') APPS_DIR = os.path.dirname(__file__) if APPS_DIR not in sys.path: sys.path.insert(0, APPS_DIR) from mainsite import TOP_DIR def boolcheck(s): if isinstance(s, basestring): return s.lower() in ("yes", "true", "t", "1") else: return bool(s) DEBUG = boolcheck(os.environ.get('DEBUG', 'False')) TEMPLATE_DEBUG = DEBUG # Whether or not django should serve static files through its wsgi server. Suggested against in the docs, but makes deployment to heroku easier. DJANGO_SERVE_STATIC = boolcheck(os.environ.get('DJANGO_SERVE_STATIC', 'True')) USER_EMAIL = '*****@*****.**' WUFOO_FORM_URL = 'http://jbrinkerhoff.wufoo.com/forms/z7x3x5/#public' WUFOO_FORM_KEY = 'HrerzDGytGaNAgJjXXF+X1uV+ZkGIl9rM78Wled6lBs=' FLICKR_KEY = '32a3ec8e88ca294bc1363c374e9cf922' FLICKR_SECRET = os.environ['FLICKR_SECRET']
import socket import select import ssl import os #from pprint import pprint from urlparse import urlparse, uses_netloc uses_netloc.append('rendezvous') class InvalidResponseFromRendezVous(Exception): pass class Rendezvous(): def __init__(self, url, printout=False): self.url = url urlp = urlparse(url) self.hostname = urlp.hostname self.port = urlp.port self.secret = urlp.path[1:] path = os.path.dirname(os.path.realpath(__file__)) self.cert = os.path.abspath("{0}/data/cacert.pem".format(path)) self.data = "" self.printout = printout def start(self): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Require a certificate from the server. We used a self-signed certificate # so here ca_certs must be the server certificate itself.