Skip to content

Commit

Permalink
Cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jul 17, 2015
1 parent 9ad7d54 commit 16f7bf9
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 147 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.pyc
*.db
tmp
Binary file modified app.db
Binary file not shown.
132 changes: 0 additions & 132 deletions app.py

This file was deleted.

10 changes: 7 additions & 3 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from flask import Flask
from flask.ext.appbuilder import SQLA, AppBuilder
from flask.ext.appbuilder import SQLA, AppBuilder, IndexView

"""
Logging configuration
Expand All @@ -12,8 +12,13 @@
app = Flask(__name__)
app.config.from_object('config')
db = SQLA(app)

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

appbuilder = AppBuilder(
app, db.session, base_template='panoramix/base.html')
app, db.session, base_template='panoramix/base.html',
indexview=MyIndexView)
#appbuilder.app_name = 'Panoramix'


Expand All @@ -31,4 +36,3 @@ def set_sqlite_pragma(dbapi_connection, connection_record):
"""

from app import views

2 changes: 1 addition & 1 deletion app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def latest_metadata(cls, name):
print "---" * 100
print name
print results
max_time = results[0]['result']['maxTime']
max_time = results[0]['result']['minTime']
max_time = parse(max_time)
intervals = (max_time - timedelta(seconds=1)).isoformat() + '/'
intervals += (max_time + timedelta(seconds=1)).isoformat()
Expand Down
13 changes: 12 additions & 1 deletion app/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
{% extends "appbuilder/baselayout.html" %}
{% extends "appbuilder/base.html" %}
{% block content %}
<div class="jumbotron">
<div class="container">
<h1>Panoramix</h1>
<p>Panoramix is an interactive visualization platform built on top of Druid.io</p>
</div>
</div>
<div class="text-center">
<img width="250" src="/static/tux_panoramix.png">
</div>
{% endblock %}

15 changes: 14 additions & 1 deletion app/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import config
from datetime import timedelta
from datetime import timedelta, datetime
import parsedatetime

since_l = {
'1hour': timedelta(hours=1),
Expand All @@ -16,3 +17,15 @@ def get_pydruid_client():
config.DRUID_BASE_ENDPOINT)


def parse_human_datetime(s):
"""
Use the parsedatetime lib to return ``datetime.datetime`` from human
generated strings
>>> parse_human_datetime("now") <= datetime.now()
True
"""
cal = parsedatetime.Calendar()
d = cal.parse(s)[0]
return datetime(
d.tm_year, d.tm_mon, d.tm_mday, d.tm_hour, d.tm_min, d.tm_sec)
10 changes: 8 additions & 2 deletions app/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from datetime import timedelta
import logging

from flask import request, redirect, flash
from flask.ext.appbuilder.models.sqla.interface import SQLAInterface
from flask.ext.appbuilder import ModelView, CompactCRUDMixin, BaseView, expose
from app import appbuilder, db, models, viz, utils
import config
from wtforms import Form, SelectMultipleField, SelectField, TextField
from wtforms.fields import Field
from datetime import timedelta

class OmgWtForm(Form):
field_order = (
Expand Down Expand Up @@ -131,7 +133,11 @@ def refresh_datasources(self):
).format(**config.__dict__)
datasources = json.loads(requests.get(endpoint).text)
for datasource in datasources:
models.Datasource.sync_to_db(datasource)
try:
models.Datasource.sync_to_db(datasource)
except Exception as e:
logging.exception(e)
logging.error("Failed at syncing " + datasource)
flash("Refreshed metadata from Druid!", 'info')
return redirect("/datasourcemodelview/list/")

Expand Down
1 change: 1 addition & 0 deletions app/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class TimeSeriesBarViz(TimeSeriesViz):
verbose_name = "Time Series - Bar Chart"
chart_kind = "bar"


class TimeSeriesStackedBarViz(TimeSeriesViz):
verbose_name = "Time Series - Stacked Bar Chart"
chart_kind = "bar"
Expand Down
17 changes: 10 additions & 7 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,17 @@
BABEL_DEFAULT_FOLDER = 'translations'
# The allowed translation for you app
LANGUAGES = {
'en': {'flag':'gb', 'name':'English'},
'pt': {'flag':'pt', 'name':'Portuguese'},
'pt_BR': {'flag':'br', 'name': 'Pt Brazil'},
'es': {'flag':'es', 'name':'Spanish'},
'de': {'flag':'de', 'name':'German'},
'zh': {'flag':'cn', 'name':'Chinese'},
'ru': {'flag':'ru', 'name':'Russian'}
'en': {'flag':'us', 'name':'English'},
'fr': {'flag':'fr', 'name':'French'},
}
"""
'pt': {'flag':'pt', 'name':'Portuguese'},
'pt_BR': {'flag':'br', 'name': 'Pt Brazil'},
'es': {'flag':'es', 'name':'Spanish'},
'de': {'flag':'de', 'name':'German'},
'zh': {'flag':'cn', 'name':'Chinese'},
'ru': {'flag':'ru', 'name':'Russian'}
"""
#---------------------------------------------------
# Image and file configuration
#---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pydruid
parsedatetime
python-dateutil
flask
flask-appbuilder
Expand Down

0 comments on commit 16f7bf9

Please sign in to comment.