Miscellaneous style fixes spotted by landscape (#874)
This commit is contained in:
parent
82a8e6316f
commit
7c810dbd20
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ class FormFactory(object):
|
|||
"description": _("Columns to display")
|
||||
}),
|
||||
'druid_time_origin': (FreeFormSelectField, {
|
||||
"label": _( "Origin"),
|
||||
"label": _("Origin"),
|
||||
"choices": (
|
||||
('', _('default')),
|
||||
('now', _('now')),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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":
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue