예제 #1
0
def make_post_request_to_translate(full_url, data):
    header = {"content-type": "application/json"}
    response = requests.post(full_url, data=json.dumps(data), headers=header)
    appLogger.debug("Response status is {}".format(response.status_code))
    return response
예제 #2
0
def get_response_time(response):
    response_time = response.elapsed.total_seconds()
    appLogger.debug("Request completed in {} ms".format(response_time * 1000))
    return response_time * 1000
예제 #3
0
def create_endpoint(endpoint_str):
    appLogger.debug('Getting full url for sending request to Bitfinex API')
    full_url = BITFINEX_API_CONFIG['url'].format(endpoint_str)
    return full_url
예제 #4
0
def make_request(full_url):
    response = requests.get(full_url)
    appLogger.debug("Response status is {}".format(response.status_code))
    return response
예제 #5
0
def get_response_body(response_for_body):
    body: list = response_for_body.json()
    appLogger.debug('Getting response body from Bitfinex API')
    return body
예제 #6
0
def get_json_from_asset(file_path):
    with open(file_path, 'r') as f:
        content_type: Dict = json.load(f)
        appLogger.debug('Getting content type from asset')
        return content_type
예제 #7
0
def get_response_headers(response_for_headers):
    headers_data: Dict = dict(response_for_headers.headers)
    appLogger.debug('Getting response headers from Bitfinex API')
    return headers_data
예제 #8
0
            list_of_users_and_words: list = cursor.fetchall()
            user_id_words = []
            for row in list_of_users_and_words:
                user_dict = {
                    'user_id': row[0],
                    'num_of_user_words': row[1]
                }
                user_id_words.append(user_dict)
            return user_id_words
        except Exception as err:
            appLogger.error(err)
            raise err



    def delete_user(self, user_id) -> None:
        appLogger.debug('Delete user')
        cursor = self.connection_to_db.cursor()
        delete_user = '''DELETE FROM dict WHERE USER_ID = %s'''
        values_to_delete: list = [user_id]
        try:
            cursor.execute(delete_user, values_to_delete)
            self.connection_to_db.commit()
        except Exception as err:
            appLogger.error(err)
            raise err

pg_config = config['PostgresSection']
connection = Connection(pg_config['user'], pg_config['password'], pg_config['host'], pg_config['port'], pg_config['database'])
appLogger.debug('Connection created')