예제 #1
0
파일: DB.py 프로젝트: exedre/e4t
    def __init__(self,config):
        """
        Initialize a DB

        @param config: configuration dictionary
        @type config: dictionary
        """
        self.conn = None
        self.curs = None
        self.config = config
        dbusr = None
        if not config.has_key('password'):
            from e4t.utils import get_credentials
            (dbusr,self.password) = get_credentials()
        else:
            self.password = config['password']

        if config.has_key('user'):
            self.dbusr = config['user']
        elif dbusr is not None:
            self.dbusr = dbusr
        else:
            self.dbusr = getenv('TSOUSER')
            if not self.dbusr:
                self.dbusr = getenv('LOGNAME')

        self.dbname  = "DB"
        if config.has_key('db'):
            self.dbname  = config['db']
            
        self.host = 'localhost'
        if config.has_key('host'):
            self.host = config['host']
예제 #2
0
파일: net.py 프로젝트: exedre/e4t.new
def get_proxy(config_file=None):
    """
    Setup proxy     
    """
    proxy_info = {}

    if config_file is None:
        BASE_PATH=expanduser("~")
        config_file = join(BASE_PATH,'.proxies')
        if not exists(config_file):
            config_file = None
    
    if config_file is None:
        BITS_PATH="/home/group/public/bits"
        BITS_ETC=join(BITS_PATH,"etc")
        config_file = join(BITS_ETC,'proxies.conf')
        if not exists(config_file):
            config_file = None
    
    if config_file and exists(config_file):
        logger.debug('Getting proxy from file %s',config_file)
        socket.setdefaulttimeout(120)
        domain = '.'.join(socket.getfqdn().split('.')[1:])
        session="PROXY-%s" % domain
        http_proxy = getenv('http_proxy')
        proxy_info = get_session(config_file,session,
                                 secure=False,
                                 host='itaca-prod.utenze.bankit.it',
                                 port=8079,
                                 user="******" % getenv('LOGNAME'),
                                 password=None
                                 )
        if not proxy_info.has_key('password') or proxy_info['password'] is None:
            try:
                user,passwd = get_credentials()
                proxy_info['password']=passwd
            except TypeError:
                raise NoProxyInfoInConfigFileError("No Proxy Info in configurations file (password key)")
        else:
            passwd = proxy_info['password']
        proxy_info['proxy'] = "http://%(user)s:%(password)s@%(host)s:%(port)s" % proxy_info
        log_proxy=','.join(["%s=%s" %(k,v) for k,v in proxy_info.items()])
        npwd=passwd[0]+'*'*(len(passwd)-2)+passwd[-1]
        log_proxy=log_proxy.replace(passwd,npwd)
        logger.debug("Proxy Info are %s",log_proxy)

    return proxy_info
예제 #3
0
파일: __init__.py 프로젝트: exedre/e4t.new
    def __init__(self, config):
        """
        Initialize a DB

        @param config: configuration dictionary
        @type config: dictionary


        Environment Variables:
        TSOUSER
        LOGNAME
        """
        self.conn = None
        self.curs = None
        self.config = config
        dbusr = None
        if 'password' in config:
            self.password = config['password']
        else:
            from e4t.utils import get_credentials
            (dbusr, self.password) = get_credentials()

        if 'user' in config:
            self.dbusr = config['user']
        elif dbusr is not None:
            self.dbusr = dbusr
        else:
            self.dbusr = getenv('TSOUSER')
            if not self.dbusr:
                self.dbusr = getenv('LOGNAME')

        self.dbname = "DB"
        if 'db' in config:
            self.dbname = config['db']

        self.host = 'localhost'
        if 'host' in config:
            self.host = config['host']
예제 #4
0
파일: pipeline.py 프로젝트: exedre/e4t
def get_login( realm, username, may_save ):
    username,password = get_credentials()
    return True, username, password, may_save