pmaengineering / ppp-web

Web server and client application for Pretty PDF Printer, a package to convert XlsForms to human readable formats.
https://www.pma2020.org
MIT License
4 stars 4 forks source link

Error Message not clear #47

Open philstau opened 4 years ago

philstau commented 4 years ago

Description

Thanks for the great work! I tried the web feature with your demo file and succeeded. Then I tried one of our own files, which failed. However struggle to understand the error message. Could you kindly advise me what it may indicate?

Steps to Reproduce

  1. Using the following file: MYS_A_PERS_v11_num.xlsx

  2. Uploading on http://ppp.pma2020.org/

  3. Keeping all settings as is.

Desired/expected behavior

Normal Outcome

Actual behavior

The following error message appeared:

STDERR: Traceback (most recent call last): File "/app/.heroku/python/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/app/.heroku/python/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__main__.py", line 8, in <module> cli() File "/app/.heroku/python/lib/python3.6/site-packages/ppp/interfaces/cli.py", line 235, in cli debug=args.debug, highlight=args.highlight, preset=args.preset, template=args.template) File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__init__.py", line 158, in run convert_file(file, language, outpath=_outpath, **combo) File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__init__.py", line 52, in convert_file form = OdkForm.from_file(in_file) File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkform.py", line 108, in from_file xlsform = Xlsform(path, strict_validation=False) File "/app/.heroku/python/lib/python3.6/site-packages/pmix/xlsform.py", line 26, in __init__ self.data = [Xlstab.from_worksheet(ws) for ws in self] File "/app/.heroku/python/lib/python3.6/site-packages/pmix/xlsform.py", line 26, in <listcomp> self.data = [Xlstab.from_worksheet(ws) for ws in self] File "/app/.heroku/python/lib/python3.6/site-packages/pmix/xlstab.py", line 82, in from_worksheet xlstab = cls(data=worksheet.data, name=worksheet.name) File "/app/.heroku/python/lib/python3.6/site-packages/pmix/xlstab.py", line 47, in __init__ self.assert_unique_cols() File "/app/.heroku/python/lib/python3.6/site-packages/pmix/xlstab.py", line 60, in assert_unique_cols raise XlsformError('Headers not unique in {}'.format(self.name)) pmix.error.XlsformError: Headers not unique in Sheet1

Additional details

Kindly advise =) Thanks!

joeflack4 commented 4 years ago

Hey there! Glad you're using PPP. Sorry about the issues.

There's a bug in a dependency of PPP that is checking for sheets outside of the XLSForm spec--in this case, Sheet1. It found duplicate column names in the sheet, which is causing the error. @jkpr Maybe file an issue in pmix for this?

I deleted Sheet1 and got a new error, list_name not found in choices worksheet. You do have list name. I am assuming this is a new part of the XLSForm/XForm spec that it allows for a space or an underscore between the words. @jkpr Can you look into this? If so we should also create an issue for that. I believe this is a PPP-specific error.

The next error I got is:

File "/app/.heroku/python/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/app/.heroku/python/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__main__.py", line 8, in <module>
cli()
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/interfaces/cli.py", line 235, in cli
debug=args.debug, highlight=args.highlight, preset=args.preset, template=args.template)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__init__.py", line 158, in run
convert_file(file, language, outpath=_outpath, **combo)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__init__.py", line 52, in convert_file
form = OdkForm.from_file(in_file)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkform.py", line 110, in from_file
return cls(xlsform)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkform.py", line 84, in __init__
'country': self.metadata['country'](),
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkform.py", line 77, in <lambda>
'country': lambda: self.metadata['form_id'][3:5],
TypeError: 'NoneType' object is not subscriptable

This is an error in PPP due to some PMA-specifics it looks like we are expecting (but shouldn't be). @jkpr I was able to fix this by adding a settings worksheet and mocking some data inside of it.

Then I got:

File "/app/.heroku/python/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/app/.heroku/python/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__main__.py", line 8, in <module>
cli()
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/interfaces/cli.py", line 235, in cli
debug=args.debug, highlight=args.highlight, preset=args.preset, template=args.template)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__init__.py", line 158, in run
convert_file(file, language, outpath=_outpath, **combo)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/__init__.py", line 62, in convert_file
output = form.to_html(lang=language, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkform.py", line 359, in to_html
html_questionnaire += item.to_html(lang=language, **kwargs)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkprompt.py", line 598, in to_html
question = self.to_dict(lang=lang, **settings)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkprompt.py", line 556, in to_dict
prompt['input_field'] = self.to_html_input_field(lang)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkprompt.py", line 506, in to_html_input_field
field = self.choices.name_labels(lang=lang)
File "/app/.heroku/python/lib/python3.6/site-packages/ppp/odkchoices.py", line 80, in name_labels
formatted_row = {'label': labels[i]}
TypeError: 'NoneType' object is not subscriptable

I believe this is because I had "English" in the language field at ppp.pma2020.org but did not put "English (en)". Tried again with "English (en)" but still didn't work. Changed XLSForm headers to remove the (lc) where 'lc' stands for 'language' code. I deleted all instances of (lc) in the workbook, and that was the final fix needed. @jkpr We still need to support this spec. I don't know if we have an issue up for this yet.

@jkpr I think if we can create individual issues for all the errors encountered here, we can then close this issue.

@philstau What are you using for your platform? ODK, SurveyCTO, or something else maybe? Also, here's the file I edited. It should convert now: MYS_A_PERS_v11b_num.xlsx

philstau commented 4 years ago

Wow! Thanks @joeflack4 This was so quick and helpful!

I applied your instructions again to my original and it worked very well. I also applied it to six other files and it works very well!

I had one more issue, where I had a group nested into another group. But by deleting one of the groups it worked out fine.

We are using ODK Collect on Android tablets. That's all =)

Very cool and helpful! Thank you so much for this nice application.

joeflack4 commented 4 years ago

Np!