Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 9, 2015
1 parent 9858304 commit 67c5f63
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 139 deletions.
7 changes: 2 additions & 5 deletions panoramix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
from flask import Flask
from flask.ext.appbuilder import SQLA, AppBuilder, IndexView

"""
Logging configuration
"""

# Logging configuration
logging.basicConfig(format='%(asctime)s:%(levelname)s:%(name)s:%(message)s')
logging.getLogger().setLevel(logging.DEBUG)

app = Flask(__name__)
app.config.from_object('panoramix.config')
db = SQLA(app)


class MyIndexView(IndexView):
index_template = 'index.html'

Expand All @@ -21,5 +19,4 @@ class MyIndexView(IndexView):
indexview=MyIndexView)

get_session = appbuilder.get_session

from panoramix import views
81 changes: 43 additions & 38 deletions panoramix/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
from flask_appbuilder.security.manager import AUTH_OID, AUTH_REMOTE_USER, AUTH_DB, AUTH_LDAP, AUTH_OAUTH
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)
basedir = os.path.abspath(os.path.dirname(__file__))
from dateutil import tz

Expand All @@ -10,32 +12,32 @@
There' a ``from local_config import *`` at the end of this file.
"""

#---------------------------------------------------------
# ---------------------------------------------------------
# Panoramix specifix config
#---------------------------------------------------------
# ---------------------------------------------------------
ROW_LIMIT = 5000
WEBSERVER_THREADS = 8

PANORAMIX_WEBSERVER_PORT = 8088
#---------------------------------------------------------
# ---------------------------------------------------------

# Your App secret key
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h'

# The SQLAlchemy connection string.
SQLALCHEMY_DATABASE_URI = 'sqlite:///tmp/panoramix.db'
#SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
#SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'
# SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
# SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'

# Flask-WTF flag for CSRF
CSRF_ENABLED = True

#Whether to run the web server in debug mode or not
# Whether to run the web server in debug mode or not
DEBUG = True

#------------------------------
# ------------------------------
# GLOBALS FOR APP Builder
#------------------------------
# ------------------------------
# Uncomment to setup Your App name
APP_NAME = "Panoramix"

Expand All @@ -48,9 +50,9 @@
# other tz can be overridden by providing a local_config
DRUID_TZ = tz.tzutc()

#----------------------------------------------------
# ----------------------------------------------------
# AUTHENTICATION CONFIG
#----------------------------------------------------
# ----------------------------------------------------
# The authentication type
# AUTH_OID : Is for OpenID
# AUTH_DB : Is for database (username/password()
Expand All @@ -59,37 +61,37 @@
AUTH_TYPE = AUTH_DB

# Uncomment to setup Full admin role name
#AUTH_ROLE_ADMIN = 'Admin'
# AUTH_ROLE_ADMIN = 'Admin'

# Uncomment to setup Public role name, no authentication needed
#AUTH_ROLE_PUBLIC = 'Public'
# AUTH_ROLE_PUBLIC = 'Public'

# Will allow user self registration
#AUTH_USER_REGISTRATION = True
# AUTH_USER_REGISTRATION = True

# The default user self registration role
#AUTH_USER_REGISTRATION_ROLE = "Public"
# AUTH_USER_REGISTRATION_ROLE = "Public"

# When using LDAP Auth, setup the ldap server
#AUTH_LDAP_SERVER = "ldap://ldapserver.new"
# AUTH_LDAP_SERVER = "ldap://ldapserver.new"

# Uncomment to setup OpenID providers example for OpenID authentication
#OPENID_PROVIDERS = [
# OPENID_PROVIDERS = [
# { 'name': 'Yahoo', 'url': 'https://me.yahoo.com' },
# { 'name': 'AOL', 'url': 'http://openid.aol.com/<username>' },
# { 'name': 'Flickr', 'url': 'http://www.flickr.com/<username>' },
# { 'name': 'MyOpenID', 'url': 'https://www.myopenid.com' }]
#---------------------------------------------------
# ---------------------------------------------------
# Babel config for translations
#---------------------------------------------------
# ---------------------------------------------------
# Setup default language
BABEL_DEFAULT_LOCALE = 'en'
# Your application default translation path
BABEL_DEFAULT_FOLDER = 'translations'
# The allowed translation for you app
LANGUAGES = {
'en': {'flag':'us', 'name':'English'},
'fr': {'flag':'fr', 'name':'French'},
'en': {'flag': 'us', 'name': 'English'},
'fr': {'flag': 'fr', 'name': 'French'},
}
"""
'pt': {'flag':'pt', 'name':'Portuguese'},
Expand All @@ -99,9 +101,9 @@
'zh': {'flag':'cn', 'name':'Chinese'},
'ru': {'flag':'ru', 'name':'Russian'}
"""
#---------------------------------------------------
# ---------------------------------------------------
# Image and file configuration
#---------------------------------------------------
# ---------------------------------------------------
# The file upload folder, when using models with files
UPLOAD_FOLDER = basedir + '/app/static/uploads/'

Expand All @@ -111,24 +113,27 @@
# The image upload url, when using models with images
IMG_UPLOAD_URL = '/static/uploads/'
# Setup image size default is (300, 200, True)
#IMG_SIZE = (300, 200, True)
# IMG_SIZE = (300, 200, True)

# ---------------------------------------------------
# Theme configuration
# these are located on static/appbuilder/css/themes
# you can create your own and easily use them placing them on the same dir structure to override
#APP_THEME = "bootstrap-theme.css" # default bootstrap
#APP_THEME = "cerulean.css"
#APP_THEME = "amelia.css"
#APP_THEME = "cosmo.css"
#APP_THEME = "cyborg.css"
#APP_THEME = "flatly.css"
#APP_THEME = "journal.css"
#APP_THEME = "readable.css"
#APP_THEME = "simplex.css"
#APP_THEME = "slate.css"
#APP_THEME = "spacelab.css"
#APP_THEME = "united.css"
#APP_THEME = "yeti.css"
# you can create your own and easily use them placing them on the
# same dir structure to override
# ---------------------------------------------------
# APP_THEME = "bootstrap-theme.css" # default bootstrap
# APP_THEME = "cerulean.css"
# APP_THEME = "amelia.css"
# APP_THEME = "cosmo.css"
# APP_THEME = "cyborg.css"
# APP_THEME = "flatly.css"
# APP_THEME = "journal.css"
# APP_THEME = "readable.css"
# APP_THEME = "simplex.css"
# APP_THEME = "slate.css"
# APP_THEME = "spacelab.css"
# APP_THEME = "united.css"
# APP_THEME = "yeti.css"

try:
from panoramix_config import *
Expand Down
10 changes: 4 additions & 6 deletions panoramix/forms.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
from wtforms import Field, Form, SelectMultipleField, SelectField, TextField
from flask_appbuilder.fieldwidgets import Select2Widget, Select2ManyWidget




class OmgWtForm(Form):
field_order = tuple()
css_classes = dict()

@property
def fields(self):
fields = []
Expand Down Expand Up @@ -64,21 +62,21 @@ def form_factory(datasource, viz, form_args=None):
select2 = [
'viz_type', 'metrics', 'groupby',
'row_limit', 'rolling_type', 'series',
'entity', 'x', 'y', 'size',]
'entity', 'x', 'y', 'size']
field_css_classes['since'] += ['select2_free_since']
field_css_classes['until'] += ['select2_free_until']
field_css_classes['granularity'] += ['select2_free_granularity']
for field in select2:
field_css_classes[field] += ['select2']


class QueryForm(OmgWtForm):
field_order = viz.form_fields
css_classes = field_css_classes

for i in range(10):
setattr(QueryForm, 'flt_col_' + str(i), SelectField(
'Filter 1', choices=[(s, s) for s in datasource.filterable_column_names]))
'Filter 1',
choices=[(s, s) for s in datasource.filterable_column_names]))
setattr(QueryForm, 'flt_op_' + str(i), SelectField(
'Filter 1', choices=[(m, m) for m in ['in', 'not in']]))
setattr(QueryForm, 'flt_eq_' + str(i), TextField("Super"))
Expand Down
12 changes: 4 additions & 8 deletions panoramix/highchart.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import pandas
from collections import defaultdict
import copy
import json
from pandas.io.json import dumps


class BaseHighchart(object):
stockchart = False
tooltip_formatter = ""
target_div = 'chart'

@property
def javascript_cmd(self):
js = dumps(self.chart)
Expand All @@ -18,7 +17,7 @@ def javascript_cmd(self):
)
if self.stockchart:
return "new Highcharts.StockChart(%s);" % js
return "new Highcharts.Chart(%s);" %js
return "new Highcharts.Chart(%s);" % js


class Highchart(BaseHighchart):
Expand Down Expand Up @@ -127,7 +126,6 @@ def tooltip_formatter(self):
"""
return tf


def serialize_series(self):
df = self.df
chart = self.chart
Expand All @@ -140,7 +138,8 @@ def serialize_series(self):
continue
sec = name in self.secondary_y
d = {
"name": name if not sec or self.mark_right else name + " (right)",
"name":
name if not sec or self.mark_right else name + " (right)",
"yAxis": int(sec),
"data": zip(df.index, data.tolist())
}
Expand All @@ -150,8 +149,6 @@ def serialize_series(self):
d['compare'] = self.compare # either `value` or `percent`
if self.chart_type in ("area", "column", "bar") and self.stacked:
d["stacking"] = 'normal'
#if kwargs.get("style"):
# d["dashStyle"] = pd2hc_linestyle(kwargs["style"].get(name, "-"))
chart["series"].append(d)

def serialize_xaxis(self):
Expand Down Expand Up @@ -219,7 +216,6 @@ def __init__(self, df, target_div='chart', height=800):
chart['chart']["height"] = height

def series(self):
#df = self.df[['name', 'x', 'y', 'z']]
df = self.df
series = defaultdict(list)
for row in df.to_dict(orient='records'):
Expand Down
Loading

0 comments on commit 67c5f63

Please sign in to comment.