OpenCellID Utils
----------------
.. image:: https://travis-ci.org/ashmastaflash/opencellid-wrapper.svg?branch=master
:target: https://travis-ci.org/ashmastaflash/opencellid-wrapper
.. image:: https://codeclimate.com/github/ashmastaflash/opencellid-wrapper/badges/gpa.svg
:target: https://codeclimate.com/github/ashmastaflash/opencellid-wrapper
:alt: Code Climate
.. image:: https://codeclimate.com/github/ashmastaflash/opencellid-wrapper/badges/coverage.svg
:target: https://codeclimate.com/github/ashmastaflash/opencellid-wrapper/coverage
:alt: Test Coverage
.. image:: https://codeclimate.com/github/ashmastaflash/opencellid-wrapper/badges/issue_count.svg
:target: https://codeclimate.com/github/ashmastaflash/opencellid-wrapper
:alt: Issue Count
This project is not associated with the OpenCellID project. This is a utility
package for downloading and parsing the OpenCellID database.
OpenCelliD Project is licensed under a Creative Commons Attribution-ShareAlike
4.0 International License.
Usage (with API key from Unwired Labs)
--------------------------------------
::
import opencellid
ocid_obj = opencellid.OpenCellIdFeed("/dir/for/feed/file/", "api_key")
# Update OpenCellID feed from web:
ocid_obj.update_feed()
# Print all rows in OpenCellID feed:
for row in ocid_obj:
print row
Usage (no API key, update from Mozilla Location Services)
---------------------------------------------------------
::
import opencellid
ocid_obj = opencellid.OpenCellIdFeed("/dir/for/feed/file/")
# Update OpenCellID feed from web:
ocid_obj.update_feed()
# Print all rows in OpenCellID feed:
for row in ocid_obj:
print row
Error Handling
--------------
The tool will attempt to detect if the download is a gzipped CSV file before
boving the download to replace the original gzipped CSV. If an IOError is
encountered, a meaningful message will be displayed, and the exception will
be re-raised. For example, if you're being rate-limited, you'll see...
::
>>> ocid_obj.update_feed()
Updating OpenCellID feed from Unwired Labs.
Feed did not update... you're being rate-limited!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "opencellid/opencellid_feed.py", line 60, in update_feed
consumer.next()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/csv.py", line 107, in next
self.fieldnames
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/csv.py", line 90, in fieldnames
self._fieldnames = self.reader.next()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 464, in readline
c = self.read(readsize)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 268, in read
self._read(readsize)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 303, in _read
self._read_gzip_header()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 197, in _read_gzip_header
raise IOError, 'Not a gzipped file'
IOError: Not a gzipped file
And if your API key is not accepted, you'll see...
::
>>> ocid_obj.update_feed()
Updating OpenCellID feed from Unwired Labs.
API token rejected by Unwired Labs!!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "opencellid/opencellid_feed.py", line 60, in update_feed
consumer.next()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/csv.py", line 107, in next
self.fieldnames
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/csv.py", line 90, in fieldnames
self._fieldnames = self.reader.next()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 464, in readline
c = self.read(readsize)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 268, in read
self._read(readsize)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 303, in _read
self._read_gzip_header()
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gzip.py", line 197, in _read_gzip_header
raise IOError, 'Not a gzipped file'
IOError: Not a gzipped file
When this happens, the original feed is not updated, so you can catch and
re-initialize the ``ocid_obj`` to pull from MLS until you can sort out the
rate limiting or API key issue.
Installation
------------
pip install opencellid
Testing
-------
py.test
The test fixture file cell_towers.csv.gz contains information from the
OpenCellID database, which is licensed CC-BY-SA 4.0
Changelog
=========
v1.3.3
------
New
~~~
- Add support for Python 3.6, 3.7. [Ash]
Closes #11
v1.3 (2018-10-16)
-----------------
Changes
~~~~~~~
- Updated CodeClimate settings. [Ash Wilson]
Closes #3
- Updated download URL for OpenCellID feed. [Ash Wilson]
Updated tests to avoid Travis-CI silence timeout.
Closes #2
v1.2 (2017-06-13)
-----------------
Changes
~~~~~~~
- Improved error handling for bad API token and rate limiting
situations. [Ash Wilson]
v1.0 (2017-06-13)
-----------------
Changes
~~~~~~~
- Support update from UnwiredLabs or Mozilla Location Services. API
changed, now use update_feed() method and source will be chosen
depending on the presence of an API key. [Ash Wilson]
v0.1.1 (2017-01-23)
-------------------
New
~~~
- Unit and integration tests. [Ash Wilson]
- Creates an OpenCellIdFeed object which can be updated from web and
iterated over. [Ash Wilson]
Metadata
Release files for opencellid 1.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opencellid-1.3.4.tar.gz | 8.7 kB | Without provenance | Details for opencellid-1.3.4.tar.gz |
Release files / opencellid-1.3.4.tar.gz
| Download URL | opencellid-1.3.4.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0887e6055e5987a172788a0833501893450212fdc8c8bc817687af9f45d9ec2a
|
|
BLAKE2b-256 checksum How to use checksums |
e46bf786b63e411116cd233428fe775d6c869054ae37c49ac6190abc9a1ebd48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.14
|
Security for opencellid 1.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.