Skip to content

Commit

Permalink
Fix Python3 imports and statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Fischer authored and sebastianneubauer committed Jan 5, 2018
1 parent 81970d3 commit 88e5d31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
5 changes: 3 additions & 2 deletions postgraas_server/create_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ def create_app(config):
app.config['SQLALCHEMY_DATABASE_URI'] = get_meta_db_config_path(config)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app_config = get_application_config(config)
for key, value in app_config:
app.config[key.upper()] = int(value) if key.upper() in INT_OPTIONS else value

for key in app_config:
app.config[key.upper()] = int(app_config[key]) if key.upper() in INT_OPTIONS else app_config[key]
app.config['SENTRY_INCLUDE_PATHS'] = [
'postgraas_server',
]
Expand Down
7 changes: 3 additions & 4 deletions postgraas_server/postgraas_api.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import logging
from create_app import create_app
from configuration import get_config

logger = logging.getLogger(__name__)
from postgraas_server.configuration import get_config
from postgraas_server.create_app import create_app

logger = logging.getLogger(__name__)

app = create_app(get_config())


if __name__ == "__main__":
app.run(debug=True, use_reloader=True)
5 changes: 3 additions & 2 deletions postgraas_server/prometheus_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

import logging
from contextlib import contextmanager
import configuration as cfg

import click
import psycopg2
from flask import Blueprint, Flask, Response, abort
from prometheus_client import CONTENT_TYPE_LATEST, generate_latest
from prometheus_client.core import REGISTRY, GaugeMetricFamily

import postgraas_server.configuration as cfg

logger = logging.getLogger(__name__)

_NO_TRACING = 0
Expand Down Expand Up @@ -49,7 +50,6 @@ def count_postgraas_instances(config):


class CustomCollector(object):

def __init__(self, config):
self.metric_name = 'number_of_postgraas_instances'
self.help = 'number of postgraas instances'
Expand All @@ -63,6 +63,7 @@ def collect(self):
def describe(self):
yield GaugeMetricFamily(self.metric_name, self.help)


blueprint = Blueprint('monitoring', __name__)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ def delete_test_database_and_user(db_name, username, config):
pgcd.delete_database(db_name, config)
except ValueError as e:
pass
#print ValueError(e.args[0])
# print(ValueError(e.args[0]))
try:
pgcd.delete_user(username, config)
except ValueError as e:
pass
#print ValueError(e.args[0])
# print(ValueError(e.args[0]))


@pytest.fixture(params=['pg_cluster'])
def parametrized_setup(request, tmpdir):
Expand Down
13 changes: 6 additions & 7 deletions tests/test_unit/test_configuration.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
from configparser import ConfigParser
try:
from StringIO import StringIO
except ImportError:
from io import StringIO

import os

from io import StringIO
from cryptography.fernet import Fernet

import postgraas_server.configuration as cf
Expand Down Expand Up @@ -31,7 +30,7 @@ def test_get_user(self):

config = ConfigParser()

config.readfp(StringIO(config_string))
config.read_file(StringIO(config_string))
username = cf.get_user(config)
expected = 'postgraas_user'

Expand All @@ -44,7 +43,7 @@ def test_get_user(self):
'''
config = ConfigParser()

config.readfp(StringIO(config_string))
config.read_file(StringIO(config_string))
username = cf.get_user(config)
expected = 'postgraas_user@testserver1'

Expand Down

0 comments on commit 88e5d31

Please sign in to comment.