furion / config.py

from __future__ import with_statement

import time
import sys

from os.path import exists

from StringIO import StringIO
import ConfigParser

from simpleauth import SimpleAuth

class FurionConfig(object):

    def init(self, path):

        default_cfg = StringIO("""
local_ip =
local_port = 11080
local_ssl = off
pem_path = 
local_auth = off

upstream_ip =
upstream_port = 443
upstream_ssl = on
upstream_auth = on
upstream_username = 
upstream_password =

auth_plugin = 
        self.config = ConfigParser.ConfigParser()

        auth_plugin = self.config.get('plugin', 'auth_plugin')

        self.authority = None
        if auth_plugin == 'simpleauth':
            self.authority = SimpleAuth()

        self.local_ip = self.config.get('main', 'local_ip')
        self.local_port = self.config.getint('main', 'local_port')

        self.local_ssl = self.config.getboolean('main', 'local_ssl')
        self.local_auth = self.config.getboolean('main', 'local_auth')
        self.pem_path = self.config.get('main', 'pem_path')
        if self.pem_path and not exists(self.pem_path):
            print 'Fatal error: pem "%s" cannot be found.' % self.pem_path

        self.upstream_ip = self.config.get('upstream', 'upstream_ip')
        self.upstream_port = self.config.getint('upstream', 'upstream_port')
        self.upstream_ssl = self.config.getboolean('upstream', 'upstream_ssl')
        self.upstream_auth = self.config.getboolean('upstream', 'upstream_auth')
        self.upstream_username = self.config.get('upstream', 'upstream_username')
        self.upstream_password = self.config.get('upstream', 'upstream_password')

        self.local_addr = (self.local_ip, self.local_port)
        self.upstream_addr = (self.upstream_ip, self.upstream_port) if self.upstream_ip else None
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.