openelections / openelections-core

Core repo for election results data acquisition, transformation and output.
MIT License
176 stars 97 forks source link

Fetch fails to unzip .zip files #181

Closed ericlagergren closed 10 years ago

ericlagergren commented 10 years ago

When running invoke fetch --state=wa I run into this error when attempting to unzip the .zip files.

Traceback (most recent call last):
  File "/usr/local/bin/invoke", line 9, in <module>
    load_entry_point('invoke==0.5.1', 'console_scripts', 'invoke')()
  File "/usr/local/lib/python2.7/dist-packages/invoke/cli.py", line 261, in main
    dispatch(argv)
  File "/usr/local/lib/python2.7/dist-packages/invoke/cli.py", line 250, in dispatch
    dedupe=not args['no-dedupe']
  File "/usr/local/lib/python2.7/dist-packages/invoke/executor.py", line 72, in execute
    results[t] = t(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/invoke/tasks.py", line 70, in __call__
    result = self.body(*args, **kwargs)
  File "/home/eric/sbdmn/core/openelex/tasks/fetch.py", line 38, in fetch
    fetcher.fetch(url, std_filename)
  File "/home/eric/sbdmn/core/openelex/us/wa/fetch.py", line 28, in fetch
    self._extract_zip(url, zip_fname, overwrite)
  File "/home/eric/sbdmn/core/openelex/us/wa/fetch.py", line 56, in _extract_zip
    self.cache.abspath)
  File "/usr/lib/python2.7/zipfile.py", line 963, in extract
    member = self.getinfo(member)
  File "/usr/lib/python2.7/zipfile.py", line 859, in getinfo
    'There is no item named %r in the archive' % name)
KeyError: "There is no item named u'2008Gen by-precinct data (by county)/Adams Gen09 prec results, RV- cast on sheet2.zip' in the archive"

This is due to an incorrect url_paths.csv file. The file had a lot (like, two or so for each of the of 39 counties) messed up file paths, especially for the files in .xls format.

I've submitted a pull request with the corrected url_paths.csv file. See: https://github.com/openelections/core/pull/182

ericlagergren commented 10 years ago

https://github.com/openelections/core/issues/182 was merged, so this is issue is fixed.