Skip to content

Commit

Permalink
Adding argparse for port and debug mode on bin/panoramix
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Sep 8, 2015
1 parent 483935c commit 6dd81a3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
17 changes: 14 additions & 3 deletions panoramix/bin/panoramix
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
#!/usr/bin/env python
from panoramix import app, config
from subprocess import Popen
import argparse


if __name__ == "__main__":
if config.DEBUG:
parser = argparse.ArgumentParser(
description='Start a Panoramix web server')
parser.add_argument(
'-d', '--debug', action='store_true',
help="Start the web server in debug mode")
parser.add_argument(
'-p', '--port', default=config.PANORAMIX_WEBSERVER_PORT,
help="Specify the port on which to run the web server")
args = parser.parse_args()
args.debug = args.debug or config.DEBUG
if args.debug:
app.run(
host='0.0.0.0',
port=int(config.PANORAMIX_WEBSERVER_PORT),
port=int(args.port),
debug=True)
else:
cmd = (
"gunicorn "
"-w 8 "
"-b 0.0.0.0:{config.PANORAMIX_WEBSERVER_PORT} "
"-b 0.0.0.0:{args.port} "
"panoramix:app").format(**locals())
print("Starting server with command: " + cmd)
Popen(cmd, shell=True).wait()
4 changes: 4 additions & 0 deletions panoramix/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ class TableColumn(Model, AuditMixin):
def __repr__(self):
return self.column_name

@property
def isnum(self):
return self.type in ('LONG', 'DOUBLE', 'FLOAT')

class Cluster(Model, AuditMixin):
__tablename__ = 'clusters'
id = Column(Integer, primary_key=True)
Expand Down
4 changes: 2 additions & 2 deletions panoramix/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TableColumnInlineView(CompactCRUDMixin, ModelView):
datamodel = SQLAInterface(models.TableColumn)
can_delete = False
edit_columns = [
'column_name', 'description', 'table', 'groupby', 'filterable',
'column_name', 'description', 'groupby', 'filterable', 'table',
'count_distinct', 'sum', 'min', 'max']
list_columns = [
'column_name', 'type', 'groupby', 'filterable', 'count_distinct',
Expand Down Expand Up @@ -63,7 +63,7 @@ class SqlMetricInlineView(CompactCRUDMixin, ModelView):
list_columns = ['metric_name', 'verbose_name', 'metric_type' ]
edit_columns = [
'metric_name', 'description', 'verbose_name', 'metric_type',
'table', 'expression']
'expression', 'table',]
add_columns = edit_columns
page_size = 100
appbuilder.add_view_no_menu(SqlMetricInlineView)
Expand Down

0 comments on commit 6dd81a3

Please sign in to comment.