def loadData(self, zip_code,):
        self.zip_code = zip_code
        OAUTH_CONSUMER_KEY = config.get("yahoo_boss", "yahoo_consumer_key")
        OAUTH_CONSUMER_SECRET = config.get("yahoo_boss", "yahoo_consumer_secret")
        URL = config.get("yahoo_boss", "yahoo_boss_service_url")
        APP_ID = config.get("yahoo_boss", "yahoo_boss_app_id")

        # Construct parameters
        data = {'appId': APP_ID, 
                'postal': self.zip_code, 
                'flags': 'TJ', 
                'gflags': 'Q'} 
 
        #Create oAuth Consumer 
        consumer = oauth.OAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET)
        
        #OAuth_signature_method=HMAC-SHA1 Ð (specific algorithm used for BOSS API OAuth calls).
        signature_method_hmac_sha1 = oauth.OAuthSignatureMethod_HMAC_SHA1()
        
        #Set/SIGN the OAuthRequest   
        oauth_request = oauth.OAuthRequest.from_consumer_and_token(consumer, token=None, http_method='GET', http_url=URL, parameters=data)
        oauth_request.sign_request(signature_method_hmac_sha1, consumer, "")
        complete_url = oauth_request.to_url()
        
        #Response
        result = urllib.urlopen(complete_url)
        self.response = result.read();
 
        print self.response
        return True
Пример #2
0
 def render(self):
     retval = {}
     retval['errors'] = []
     exception={'msg':"Internal Server Error"}
     exception['msg'] = config.get("error_codes",str(self.errorCode))
     exception['code'] = self.errorCode
     retval['errors'].append(exception)
     return retval
Пример #3
0
 def render(self):
     retval = {}
     retval['errors'] = []
     exception = {'msg': "Internal Server Error"}
     exception['msg'] = config.get("error_codes", str(self.errorCode))
     exception['code'] = self.errorCode
     retval['errors'].append(exception)
     return retval
Пример #4
0
    def loadData(
        self,
        zip_code,
    ):
        self.zip_code = zip_code
        OAUTH_CONSUMER_KEY = config.get("yahoo_boss", "yahoo_consumer_key")
        OAUTH_CONSUMER_SECRET = config.get("yahoo_boss",
                                           "yahoo_consumer_secret")
        URL = config.get("yahoo_boss", "yahoo_boss_service_url")
        APP_ID = config.get("yahoo_boss", "yahoo_boss_app_id")

        # Construct parameters
        data = {
            'appId': APP_ID,
            'postal': self.zip_code,
            'flags': 'TJ',
            'gflags': 'Q'
        }

        #Create oAuth Consumer
        consumer = oauth.OAuthConsumer(OAUTH_CONSUMER_KEY,
                                       OAUTH_CONSUMER_SECRET)

        #OAuth_signature_method=HMAC-SHA1 Ð (specific algorithm used for BOSS API OAuth calls).
        signature_method_hmac_sha1 = oauth.OAuthSignatureMethod_HMAC_SHA1()

        #Set/SIGN the OAuthRequest
        oauth_request = oauth.OAuthRequest.from_consumer_and_token(
            consumer,
            token=None,
            http_method='GET',
            http_url=URL,
            parameters=data)
        oauth_request.sign_request(signature_method_hmac_sha1, consumer, "")
        complete_url = oauth_request.to_url()

        #Response
        result = urllib.urlopen(complete_url)
        self.response = result.read()

        print self.response
        return True
Пример #5
0
from common.configuration import config as ef_config

class ContextFilter(logging.Filter):
    """
    This is a filter which injects contextual information into the log.
     
    """
 
    def filter(self, record):
        if request is not None and 'guid' in request.environ and request.environ['guid'] is not None:
            record.id = request.environ['guid']
        else:
            record.id = thread.get_ident()
        return True
    
env = ef_config.get('log_env','env')
path = ef_config.get('conf_path','path')
logging.config.fileConfig('%s/default.conf' %(path))
if env == 'dev':
    logging.config.fileConfig('%s/default.conf' %(path))
else:
    logging.config.fileConfig('%s/environment.conf' %(path))

def getLogger(name="apps"):
    if name != "apps" and not name.startswith("apps."):
        name = ("apps.%s" %(name))
    logger = logging.getLogger(name)
    f = ContextFilter()
    logger.addFilter(f)
    logger.info('Inside getLogger')
    return logger
from common.configuration import config
import mysql.connector as dbconnector
import eflogging

logger = eflogging.getLogger('ConnectionManager')

ef_host = config.get("database_master", "host")
ef_user = config.get("database_master", "user")
ef_password = config.get("database_master", "password")
ef_database = config.get("database_master", "database")
ef_port = config.get("database_master", "port")

ef_host_ro = config.get("database_readonly", "host")
ef_user_ro = config.get("database_readonly", "user")
ef_password_ro = config.get("database_readonly", "password")
ef_database_ro = config.get("database_readonly", "database")
ef_port_ro = config.get("database_readonly", "port")


def get_connection():
    try:
        connection = dbconnector.connect(user=ef_user_ro,
                                         password=ef_password_ro,
                                         host=ef_host_ro,
                                         port=ef_port_ro,
                                         database=ef_database_ro)
    except Exception as e:
        logger.error("Cannot get a database connection %s" % (e))
        raise Exception("Cannot get a database conneciton")
    return connection
from common.configuration import config
import mysql.connector as dbconnector
import eflogging

logger = eflogging.getLogger('ConnectionManager')

ef_host = config.get("database_master", "host")
ef_user = config.get("database_master", "user")
ef_password = config.get("database_master", "password")
ef_database = config.get("database_master", "database")
ef_port=config.get("database_master","port")

ef_host_ro = config.get("database_readonly", "host")
ef_user_ro = config.get("database_readonly", "user")
ef_password_ro = config.get("database_readonly", "password")
ef_database_ro = config.get("database_readonly", "database")
ef_port_ro = config.get("database_readonly","port")

def get_connection():
    try:
        connection = dbconnector.connect(user=ef_user_ro, password=ef_password_ro,
                               host=ef_host_ro,port=ef_port_ro,
                              database=ef_database_ro)
    except Exception as e:
        logger.error("Cannot get a database connection %s" %(e))
        raise Exception("Cannot get a database conneciton")
    return connection

def get_connection_ro():
    try:
        connection = dbconnector.connect(user=ef_user, password=ef_password,