diff --git a/onadata/apps/api/__init__.py b/onadata/apps/api/__init__.py index 47057b871..e69de29bb 100644 --- a/onadata/apps/api/__init__.py +++ b/onadata/apps/api/__init__.py @@ -1,54 +0,0 @@ - -import re - -import pyxform.odk_validate - - -############################################################################# -# WARNING -# This is a monkey patch to fix a bug in odk and should be removed as soon as -# the fix is upstream -############################################################################# - -def _cleanup_errors(error_message): - - # this is the same code as the original function - def get_last_item(xpathStr): - l = xpathStr.split("/") - return l[len(l) - 1] - - def replace_function(match): - strmatch = match.group() - if strmatch.startswith("/html/body") \ - or strmatch.startswith("/root/item") \ - or strmatch.startswith("/html/head/model/bind") \ - or strmatch.endswith("/item/value"): - return strmatch - return "${%s}" % get_last_item(match.group()) - pattern = "(/[a-z0-9\-_]+(?:/[a-z0-9\-_]+)+)" - error_message = re.compile(pattern, flags=re.I).sub(replace_function, - error_message) - k = [] - lastline = '' - for line in error_message.splitlines(): - has_java_filename = line.find('.java:') is not -1 - is_a_java_method = line.find('\tat') is not -1 - is_duplicate = (line == lastline) - lastline = line - if not has_java_filename and not is_a_java_method and not is_duplicate: - if line.startswith('java.lang.RuntimeException: '): - line = line.replace('java.lang.RuntimeException: ', '') - if line.startswith('org.javarosa.xpath.XPathUnhandledException: '): - line = line.replace('org.javarosa.xpath.XPathUnhandledException: ', '') - if line.startswith('java.lang.NullPointerException'): - continue - k.append(line) - - # original value causing UnicodeDecodeError - #return u'\n'.join(k) - - # Fix: - return '\n'.join(k).decode('ascii', errors="replace") - - -pyxform.odk_validate._cleanup_errors = _cleanup_errors diff --git a/onadata/apps/logger/views.py b/onadata/apps/logger/views.py index 112fd87f1..2958a1d32 100644 --- a/onadata/apps/logger/views.py +++ b/onadata/apps/logger/views.py @@ -33,7 +33,7 @@ from django.views.decorators.csrf import csrf_exempt from django_digest import HttpDigestAuthenticator from pyxform import Survey -from pyxform.spss import survey_to_spss_label_zip +#from pyxform.spss import survey_to_spss_label_zip from wsgiref.util import FileWrapper from onadata.apps.main.models import UserProfile, MetaData @@ -466,6 +466,7 @@ def download_spss_labels(request, username, form_id_string): survey= Survey.from_xls(filelike_obj=xlsform_io) zip_filename= '{}_spss_labels.zip'.format(xform.id_string) + raise NotImplementedError('Requires KoBo fork of pyxform') zip_io= survey_to_spss_label_zip(survey, xform.id_string) response = StreamingHttpResponse(FileWrapper(zip_io), diff --git a/requirements/base.pip b/requirements/base.pip index d7cfcc6d6..b3fa47e59 100644 --- a/requirements/base.pip +++ b/requirements/base.pip @@ -18,9 +18,8 @@ poster==0.8.1 psycopg2==2.5.4 pymongo==2.7.2 lxml==3.4.0 -#-e git+https://github.com/onaio/pyxform.git@onaio#egg=pyxform -# kobo fork supports csvs with utf, character escaping, etc. --e git+https://github.com/kobotoolbox/pyxform.git@2.017.36#egg=pyxform +# Use vanilla pyxform for RMS; caveat: breaks SPSS export +pyxform==0.11.2 django-reversion==2.0.8 xlrd==0.9.3 xlwt==0.7.5