Skip to content

Commit

Permalink
More linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Feb 29, 2016
1 parent cb46a61 commit 0a84259
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion panoramix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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__)
Expand Down Expand Up @@ -34,3 +33,4 @@ def index(self):
sm = appbuilder.sm

get_session = appbuilder.get_session
from panoramix import config, views
14 changes: 7 additions & 7 deletions panoramix/config.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
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 (
# AUTH_OID, AUTH_REMOTE_USER, AUTH_DB, AUTH_LDAP, AUTH_OAUTH)
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
Expand Down Expand Up @@ -133,5 +133,5 @@

try:
from panoramix_config import *
except:
except Exception:
pass
5 changes: 0 additions & 5 deletions panoramix/migrations/versions/1e2841a4128_.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,10 @@

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 ###
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

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))
Expand Down
1 change: 0 additions & 1 deletion panoramix/migrations/versions/430039611635_log_more.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

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))
Expand Down
3 changes: 2 additions & 1 deletion panoramix/migrations/versions/43df8de3a5f4_dash_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@

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')
2 changes: 1 addition & 1 deletion panoramix/migrations/versions/5a7bad26f2a7_.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import mysql


def upgrade():
Expand Down
12 changes: 8 additions & 4 deletions panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
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
Expand Down Expand Up @@ -134,6 +134,7 @@ def slice_url(self):
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
Expand All @@ -150,7 +151,8 @@ def edit_url(self):
@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):
Expand Down Expand Up @@ -350,7 +352,8 @@ def name(self):
@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):
Expand Down Expand Up @@ -732,7 +735,8 @@ def __repr__(self):
@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 [
Expand Down
1 change: 1 addition & 0 deletions panoramix/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
11 changes: 8 additions & 3 deletions panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def post_add(self, table):
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),
Expand Down Expand Up @@ -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>"),
}


Expand Down Expand Up @@ -528,7 +533,7 @@ def testconn(self):
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,
Expand Down Expand Up @@ -607,7 +612,7 @@ def select_star(self, database_id, table_name):
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
Expand Down

0 comments on commit 0a84259

Please sign in to comment.