diff --git a/apps/api/views.py b/apps/api/views.py index 84545704..cd3f8e15 100644 --- a/apps/api/views.py +++ b/apps/api/views.py @@ -1,13 +1,17 @@ import os +import commonware.log from cuddlefish import apiparser from django.shortcuts import render_to_response from django.template import RequestContext from django.conf import settings +from django.http import Http404 from jetpack.models import SDK +log = commonware.log.getLogger('f.api') + sdks = SDK.objects.all() if sdks.count() > 0: MAIN_SDK = sdks[0] @@ -115,11 +119,21 @@ def module(r, package_name, module_name): sdk_version = SDKVERSION doc_file = '.'.join((module_name, 'md')) - text = open( - os.path.join(SDKPACKAGESDIR, - package_name, 'docs', doc_file)).read() + doc_path = os.path.join(SDKPACKAGESDIR, + package_name, 'docs', doc_file) + try: + text = open(doc_path).read() + except Exception, err: + log.error(str(err)) + raise Http404 + # changing the tuples to dictionaries - hunks = list(apiparser.parse_hunks(text)) + try: + hunks = list(apiparser.parse_hunks(text)) + except Exception, err: + log.error(str(err)) + hunks = [[None,'Sorry. Error in reading the doc']] + entities = [] for h in hunks: # convert JSON to a nice list diff --git a/manage.py b/manage.py index cfeb4248..bce1dcb4 100755 --- a/manage.py +++ b/manage.py @@ -13,7 +13,7 @@ site.addsitedir(path('vendor/lib/python')) site.addsitedir(path('apps')) site.addsitedir(path('lib')) -site.addsitedir(path('lib/jetpack-sdk-0.8/python-lib')) # weak sauce +site.addsitedir(path('lib/addon-sdk-0.9/python-lib')) # weak sauce # Move the new items to the front of sys.path. (via virtualenv) new_sys_path = []