More linting

This commit is contained in:
Maxime Beauchemin
2016-02-29 00:22:37 -08:00
parent cb46a61728
commit 0a842598df
12 changed files with 28 additions and 26 deletions

View File

@@ -4,7 +4,6 @@ from flask import Flask, redirect
from flask.ext.appbuilder import SQLA, AppBuilder, IndexView
from flask.ext.appbuilder.baseviews import expose
from flask.ext.migrate import Migrate
from panoramix import config, views
APP_DIR = os.path.dirname(__file__)
@@ -34,3 +33,4 @@ appbuilder = AppBuilder(
sm = appbuilder.sm
get_session = appbuilder.get_session
from panoramix import config, views

View File

@@ -1,3 +1,9 @@
"""
All configuration in this file can be overridden by providing a local_config
in your PYTHONPATH.
There' a ``from local_config import *`` at the end of this file.
"""
import os
from flask_appbuilder.security.manager import AUTH_DB
# from flask_appbuilder.security.manager import (
@@ -5,12 +11,6 @@ from flask_appbuilder.security.manager import AUTH_DB
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
from dateutil import tz
"""
All configuration in this file can be overridden by providing a local_config
in your PYTHONPATH.
There' a ``from local_config import *`` at the end of this file.
"""
# ---------------------------------------------------------
# Panoramix specifix config
@@ -133,5 +133,5 @@ CSS_THEME = '/static/assets/stylesheets/themes/panoramix-bootstrap-theme.css'
try:
from panoramix_config import *
except:
except Exception:
pass

View File

@@ -12,15 +12,10 @@ down_revision = '5a7bad26f2a7'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('table_columns', sa.Column('expression', sa.Text(), nullable=True))
### end Alembic commands ###
def downgrade():
### commands auto generated by Alembic - please adjust! ###
op.drop_column('table_columns', 'expression')
### end Alembic commands ###

View File

@@ -12,7 +12,6 @@ down_revision = '1e2841a4128'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
op.add_column('datasources', sa.Column('offset', sa.Integer(), nullable=True))

View File

@@ -12,7 +12,6 @@ down_revision = 'd827694c7555'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
op.add_column('logs', sa.Column('dashboard_id', sa.Integer(), nullable=True))

View File

@@ -12,10 +12,11 @@ down_revision = '7dbf98566af7'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
op.add_column('dashboards', sa.Column('json_metadata', sa.Text(), nullable=True))
def downgrade():
op.drop_column('dashboards', 'json_metadata')

View File

@@ -12,7 +12,7 @@ down_revision = '4e6a06bad7a8'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
op.add_column('dashboards', sa.Column('css', sa.Text(), nullable=True))

View File

@@ -12,7 +12,6 @@ down_revision = '8e80a26a31db'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():
op.add_column('slices', sa.Column('description', sa.Text(), nullable=True))

View File

@@ -12,7 +12,6 @@ down_revision = '43df8de3a5f4'
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql
def upgrade():

View File

@@ -2,10 +2,10 @@ from copy import deepcopy, copy
from collections import namedtuple
from datetime import timedelta, datetime
import json
import logging
from six import string_types
import sqlparse
import requests
import textwrap
from dateutil.parser import parse
from flask import flash
@@ -134,6 +134,7 @@ class Slice(Model, AuditMixinNullable):
try:
slice_params = json.loads(self.params)
except Exception as e:
logging.exception(e)
slice_params = {}
slice_params['slice_id'] = self.id
slice_params['slice_name'] = self.slice_name
@@ -150,7 +151,8 @@ class Slice(Model, AuditMixinNullable):
@property
def slice_link(self):
url = self.slice_url
return '<a href="{url}">{self.slice_name}</a>'.format(**locals())
return '<a href="{url}">{self.slice_name}</a>'.format(
url=url, self=self)
@property
def js_files(self):
@@ -350,7 +352,8 @@ class SqlaTable(Model, Queryable, AuditMixinNullable):
@property
def table_link(self):
url = "/panoramix/explore/{self.type}/{self.id}/".format(self=self)
return '<a href="{url}">{self.table_name}</a>'.format(**locals())
return '<a href="{url}">{self.table_name}</a>'.format(
url=url, self=self)
@property
def metrics_combo(self):
@@ -732,7 +735,8 @@ class DruidDatasource(Model, AuditMixinNullable, Queryable):
@property
def datasource_link(self):
url = "/panoramix/explore/{self.type}/{self.id}/".format(self=self)
return '<a href="{url}">{self.datasource_name}</a>'.format(**locals())
return '<a href="{url}">{self.datasource_name}</a>'.format(
url=url, self=self)
def get_metric_obj(self, metric_name):
return [

View File

@@ -44,6 +44,7 @@ def parse_human_datetime(s):
Use the parsedatetime lib to return ``datetime.datetime`` from human
generated strings
>>> from datetime import date, timedelta
>>> parse_human_datetime('2015-04-03')
datetime.datetime(2015, 4, 3, 0, 0)
>>> parse_human_datetime('2/3/1969')

View File

@@ -167,6 +167,7 @@ class TableModelView(PanoramixModelView, DeleteMixin):
try:
table.fetch_metadata()
except Exception as e:
logging.exception(e)
flash(
"Table [{}] doesn't seem to exist, "
"couldn't fetch metadata".format(table.table_name),
@@ -215,7 +216,11 @@ class SliceModelView(PanoramixModelView, DeleteMixin):
'table', 'dashboards', 'params']
base_order = ('changed_on','desc')
description_columns = {
'description': Markup("The content here can be displayed as widget headers in the dashboard view. Supports <a href='https://daringfireball.net/projects/markdown/'>markdown</a>"),
'description': Markup(
"The content here can be displayed as widget headers in the "
"dashboard view. Supports "
"<a href='https://daringfireball.net/projects/markdown/'>"
"markdown</a>"),
}
@@ -528,7 +533,7 @@ class Panoramix(BaseView):
engine = create_engine(uri)
engine.connect()
return json.dumps(engine.table_names(), indent=4)
except Exception as e:
except Exception:
return Response(
traceback.format_exc(),
status=500,
@@ -607,7 +612,7 @@ class Panoramix(BaseView):
t = mydb.get_table(table_name)
fields = ", ".join(
[c.name for c in t.columns] or "*")
s = "SELECT\n{fields}\nFROM {table_name}".format(**locals())
s = "SELECT\n{}\nFROM {}".format(fields, table_name)
return self.render_template(
"panoramix/ajah.html",
content=s