diff --git a/caravel/__init__.py b/caravel/__init__.py index 45fa4b71e9..b750b99842 100644 --- a/caravel/__init__.py +++ b/caravel/__init__.py @@ -24,9 +24,9 @@ CONFIG_MODULE = os.environ.get('CARAVEL_CONFIG', 'caravel.config') app = Flask(__name__) app.config.from_object(CONFIG_MODULE) if not app.debug: - # In production mode, add log handler to sys.stderr. - app.logger.addHandler(logging.StreamHandler()) - app.logger.setLevel(logging.INFO) + # In production mode, add log handler to sys.stderr. + app.logger.addHandler(logging.StreamHandler()) + app.logger.setLevel(logging.INFO) db = SQLA(app) diff --git a/caravel/config.py b/caravel/config.py index 3780ca787a..79c87d0a92 100644 --- a/caravel/config.py +++ b/caravel/config.py @@ -37,7 +37,7 @@ SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h' # noqa SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel.db' # this is for platform specific: "nt" is for windows, "posix" is *nix (including Mac) if os.name == "nt": - SQLALCHEMY_DATABASE_URI = 'sqlite:///c:\\tmp\\caravel.db' + SQLALCHEMY_DATABASE_URI = 'sqlite:///c:\\tmp\\caravel.db' # SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp' # SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp' diff --git a/caravel/forms.py b/caravel/forms.py index 6499747b7c..c06565d23a 100755 --- a/caravel/forms.py +++ b/caravel/forms.py @@ -310,7 +310,7 @@ class FormFactory(object): "description": _("Columns to display") }), 'druid_time_origin': (FreeFormSelectField, { - "label": _( "Origin"), + "label": _("Origin"), "choices": ( ('', _('default')), ('now', _('now')), diff --git a/caravel/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py b/caravel/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py index e5a9d4fe85..ff7314e157 100644 --- a/caravel/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py +++ b/caravel/migrations/versions/1226819ee0e3_fix_wrong_constraint_on_table_columns.py @@ -11,7 +11,7 @@ revision = '1226819ee0e3' down_revision = '956a063c52b3' from alembic import op -from caravel import db, models +from caravel import db from caravel.utils import generic_find_constraint_name import logging diff --git a/caravel/models.py b/caravel/models.py index 444a4da6b7..1a4468009e 100644 --- a/caravel/models.py +++ b/caravel/models.py @@ -362,7 +362,6 @@ class Queryable(object): return "/caravel/explore/{obj.type}/{obj.id}/".format(obj=self) - class Database(Model, AuditMixinNullable): """An ORM object that stores Database related information""" @@ -536,7 +535,6 @@ class SqlaTable(Model, Queryable, AuditMixinNullable): 'database_id', 'schema', 'table_name', name='_customer_location_uc'),) - def __repr__(self): return self.table_name @@ -743,7 +741,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable): qry = qry.limit(row_limit) if timeseries_limit and groupby: - # some sql dialects require for order by expressions + # some sql dialects require for order by expressions # to also be in the select clause inner_select_exprs += [main_metric_expr] subq = select(inner_select_exprs) @@ -765,7 +763,7 @@ class SqlaTable(Model, Queryable, AuditMixinNullable): sql = "{}".format( qry.compile( engine, compile_kwargs={"literal_binds": True},), - ) + ) df = pd.read_sql_query( sql=sql, con=engine @@ -1125,7 +1123,7 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable): def int_or_0(v): try: v = int(v) - except Exception as e: + except (TypeError, ValueError): v = 0 return v v1nums = [int_or_0(n) for n in v1.split('.')] @@ -1282,7 +1280,7 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable): if rejected_metrics: raise MetricPermException( "Access to the metrics denied: " + ', '.join(rejected_metrics) - ) + ) granularity = granularity or "all" if granularity != "all": diff --git a/caravel/utils.py b/caravel/utils.py index b4296c92ee..9afdc39615 100644 --- a/caravel/utils.py +++ b/caravel/utils.py @@ -10,7 +10,6 @@ import functools import json import logging import numpy -import time import parsedatetime import sqlalchemy as sa @@ -300,7 +299,7 @@ def json_iso_dttm_ser(obj): obj = obj.isoformat() else: raise TypeError( - "Unserializable object {} of type {}".format(obj, type(obj)) + "Unserializable object {} of type {}".format(obj, type(obj)) ) return obj @@ -314,7 +313,7 @@ def json_int_dttm_ser(obj): obj = (obj - EPOCH).total_seconds() * 1000 else: raise TypeError( - "Unserializable object {} of type {}".format(obj, type(obj)) + "Unserializable object {} of type {}".format(obj, type(obj)) ) return obj diff --git a/caravel/views.py b/caravel/views.py index db4b3a02ba..cdb796bcbd 100755 --- a/caravel/views.py +++ b/caravel/views.py @@ -1331,7 +1331,6 @@ class Caravel(BaseCaravelView): } return json.dumps(data, default=utils.json_int_dttm_ser, allow_nan=False) - @has_access @expose("/refresh_datasources/") def refresh_datasources(self):