Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from helpers.sources.osenv import OSConstants
from helpers.sources.mongo import MongoConstants
from helpers.extensions import LanguageExtensions
import os, time, datetime
import os, time, datetime, logging

app = Flask(__name__)
dev = os.environ.get('dev') == 'true' or not os.environ.get('PORT')
Expand All @@ -27,18 +27,16 @@
storages = {}
for repo_name, collection_name in collections:
try:
storage = Constants(MongoConstants(collection_name, constants.get('MONGOLAB_URI')))
storages[repo_name] = Constants(MongoConstants(collection_name, constants.get('MONGOLAB_URI')))
except:
storage = None
storages[repo_name] = storage
logging.exception('Failed to connect to storage: %s %s', repo_name, collection_name)

bots ={}
bots = {}
for repo_name in constants.get('GH_REPOS').split(','):
try:
bot = GithubBot(constants, repo_name, LANGS[repo_name], CURRENT[repo_name])
bots[repo_name] = GithubBot(constants, repo_name, LANGS[repo_name], CURRENT[repo_name])
except:
bot = None
bots[repo_name] = bot
logging.exception('Failed to bot: %s', repo_name)

@app.before_request
def preprocess_request():
Expand Down Expand Up @@ -194,18 +192,18 @@ def user_leaderboard_view(login):

@app.template_filter('min')
def min_filter(l):
return min(l)
return min(l) if l else 0

@app.template_filter('sum')
def sum_filter(l):
return sum(l)
return sum(l) if l else 0

@app.template_filter('lang_nice')
def lang_nice_filter(s):
return extensions.get_language_from_extension(s)

if __name__ == '__main__':
if dev:
app.run(host='0.0.0.0', port=5000, debug=True)
app.run(host='0.0.0.0', port=5000, debug=False)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would like to keep debug=True if running in dev mode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i actually found that when i ran heroku local with debug=True, it swallowed uncaught exceptions. with debug=False, it emitted them to stdout (or stderr).

not sure why, and i don't feel strongly. i'm happy to revert this or fix that another way if you know one!

else:
app.run(host='0.0.0.0', port=int(os.environ.get('PORT')), debug=False)