Giter Site home page Giter Site logo

tomasbedrich / pycaching Goto Github PK

View Code? Open in Web Editor NEW
57.0 15.0 46.0 4.33 MB

A Python 3 interface for working with Geocaching.com website.

Home Page: https://pycaching.readthedocs.io/

License: GNU Lesser General Public License v3.0

Python 100.00%
geocaching scraping python

pycaching's People

Contributors

0xflotus avatar belked avatar cachingfox avatar darkoutcast6 avatar dee-gmiterko avatar filipek92 avatar forslund avatar friedrichfroebel avatar gcbor avatar geotime61 avatar ian-howell avatar jakoma02 avatar jarhill0 avatar kumy avatar lpefferkorn avatar mkouhia avatar mrvdb avatar pkubiak avatar richardvdweerd avatar s0s-90 avatar serycjon avatar tomasbedrich avatar twlare avatar weinshec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pycaching's Issues

printing trackable information results in exceptions

vagrant@vagrant:~$ ./env/bin/python
Python 3.5.2 (default, Jul 5 2016, 12:43:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

import sys, datetime, pycaching, logging, time
from pycaching.log import Log, Type as LogType
logging.basicConfig(filename='tblog.log',level=logging.DEBUG)
trcode='PLE556'
geocaching = pycaching.login()
trackable = geocaching.get_trackable(trcode)
trackable
<pycaching.trackable.Trackable object at 0x7fc4497cc7b8>
trackable.name
Traceback (most recent call last):
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/util.py", line 26, in wrapper
return func(*args, **kwargs)
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/trackable.py", line 79, in name
return self._name
AttributeError: 'Trackable' object has no attribute '_name'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/util.py", line 30, in wrapper
self.load()
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/trackable.py", line 199, in load
if "cache_details" in location_url:
TypeError: argument of type 'NoneType' is not iterable

also:

print(trackable.name, trackable.goal, trackable.description, trackable.location)
Traceback (most recent call last):
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/util.py", line 26, in wrapper
return func(*args, **kwargs)
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/trackable.py", line 95, in location
return self._location
AttributeError: 'Trackable' object has no attribute '_location'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/util.py", line 30, in wrapper
self.load()
File "/home/vagrant/env/lib/python3.5/site-packages/pycaching/trackable.py", line 199, in load
if "cache_details" in location_url:
TypeError: argument of type 'NoneType' is not iterable

"Found it" for events

Event-caches are marked as "not found", because the corresponding text is "Attended" and not "Found it!"

-- Uwe Zimmermann

Premium caches: retrieve some details

At the moment, when using load_cache() to retrieve a premium cache details with a free account, a PMOnlyException exception is thrown.
It would be great to fetch the available cache informations:

  • name
  • size
  • author
  • difficulty
  • terrain

Thank you!

Searching doesn't work

>>> import pycaching
>>> from pycaching import Geocaching, Point
>>> point = Point(10.123456, 10.123456)
>>> geocaching = Geocaching()
>>> geocaching.login("cache-map", "pGUgNw59")
>>> for cache in geocaching.search(point, limit=50):
...     if cache.cache_type == "Traditional Cache":
...         print(cache.name)
...
Bauchi Park Cache
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ricoo/Drive/sites/other/utilities/pycaching/pycaching/geocaching.py", line 159, in search
    page = self._search_get_page(point, page_num)
  File "/Users/ricoo/Drive/sites/other/utilities/pycaching/pycaching/geocaching.py", line 42, in wrapper
    return func(*args, **kwargs)
  File "/Users/ricoo/Drive/sites/other/utilities/pycaching/pycaching/geocaching.py", line 193, in _search_get_page
    post["__EVENTTARGET"] = self._pagging_postbacks[page_num]
KeyError: 2
>>>

Additional locations

Some caches provides a list of additional waypoints (GC58QHM, GCMNF7).

The additional waypoints are commonly used for adding coordinates for Parking areas, steps in multi caches and similar things.

The additional waypoints list contains the following columns for each waypoint

  • Visible
  • Type
  • Prefix
  • Lookup
  • Name
  • Coordinate
  • Note

My suggestion is that a light object is created (perhaps a namedtuple) with at least Type, Lookup, Name, Coordinate and Note fields.

Either the list is converted to a dict with the Lookup (name is not unique) as key or as a plain list.

I will submit a pull request referencing this issue with a simple implementation.

Use .rc file to store default login credentials

Problem: It is annoying and even unsafe to enter your login credentials every time again when using pycaching from interactive interpreter.

Solution: allow pycaching to load username and password from .rc file stored in user's home directory. I would propose a filename .geocaching_credentials in a JSON format. Then a task would be to update Geocaching.login method to have username and password parameters optional and use .rc file instead. In case that neither parameters were passed nor .rc file exists, it would raise an error.

Enable request for trackable routes

When accessing a trackable page via web browser I am able to download the route of the specified trackable as a KML file. Could be very helpful to enable an automated download of these routes (saving them as files would be enough from my point of view).
Seems like the download link could be parsed using id="ctl00_ContentBody_lnkGoogleKML".

API to retrieve found and not found caches

I'm looking for a function to get the list a found and not found caches.
These lists are available through the URL 'my/logs.aspx?s=1&lt=2' and 'my/logs.aspx?s=1&lt=2' but each cache is referenced as a GUID, not as a GC code.

(My final purpose is to retrieve the position of all my found/not found caches to draw a map)

Create CONTRIBUTING.md

Describe:

  • style guide (mention line length exception)
  • test running and required coverage
  • "contributors friendly" issues
  • using double quotes
  • create .editorconfig file

Iterating trough .Cache object raises ValueError in most cases

ValueError points to line 1112 in cache.py:

in from_string return cls(name) File "/usr/lib/python3.6/enum.py", line 291, in __call__ return cls.__new__(cls, value) File "/usr/lib/python3.6/enum.py", line 533, in __new__ return cls._missing_(value) File "/usr/lib/python3.6/enum.py", line 546, in _missing_ raise ValueError("%r is not a valid %s" % (value, cls.__name__)) ValueError: 'střední' is not a valid Size

get_cache method works ok.

T. Pavelka

Loading waypoints fails

Loading the waypoints of some caches fails in parsing with an AttributeError. I only have one example (from the tests), but someone should look into whether this applies to all caches, or something like all archive caches.

Steps to reproduce:

In [1]: import pycaching

In [2]: gc = pycaching.login('REDACTED', 'REDACTED')

In [3]: cache = gc.get_cache('GC2WXPN')

In [4]: cache.waypoints
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pycaching/util.py in wrapper(*args, **kwargs)
     25         try:
---> 26             return func(*args, **kwargs)
     27         except AttributeError:

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pycaching/cache.py in waypoints(self)
    274         """
--> 275         return self._waypoints
    276 

AttributeError: 'Cache' object has no attribute '_waypoints'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-4-d0929eb115a1> in <module>()
----> 1 cache.waypoints

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pycaching/util.py in wrapper(*args, **kwargs)
     28             logging.debug("Lazy loading {} into <object {} id {}>".format(
     29                 func.__name__, type(self), id(self)))
---> 30             self.load()
     31             return func(*args, **kwargs)  # try to return it again
     32 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pycaching/cache.py in load(self)
    680 
    681         # Additional Waypoints
--> 682         self.waypoints = Waypoint.from_html(root, "ctl00_ContentBody_Waypoints")
    683 
    684         logging.debug("Cache loaded: {}".format(self))

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pycaching/cache.py in from_html(cls, soup, table_id)
    954                 columns = r1.find_all("td") + r2.find_all("td")
    955                 identifier = columns[4].text.strip()
--> 956                 type = columns[2].find("img").get("title")
    957                 location_string = columns[6].text.strip()
    958                 try:

AttributeError: 'NoneType' object has no attribute 'get'

It seems Groundspeak has altered the formatting of the cache print pages.

I believe that changing this line:

type = columns[2].find("img").get("title")

to type = columns[1].find("img").get("title") and this line:

note = columns[10].text.strip()

to note = columns[7].text.strip() will fix the issue, but I've only tested that with this one cache.

cache.description is not handled gracefully

If there is no long description for the cache listed on the website, cache.description returns

<div class="UserSuppliedContent">
<span id="ctl00_ContentBody_LongDescription"></span>
</div>

This should be handled gracefully, and just return an empty string. I will put in a pull request for this when I fix it (see #78)

Enum for cache types and sizes

It is painful to filter caches by sizes or types. Groundspeak often changes the data, eg. "Traditional Cache" to "Traditional" and the filtering code then would have to be rewritten.
It would be better to encapsulate string data to some kind of enum, that would remain unchanged when underlaying strings would change.

Search is broken due to changes in GC.com in 2014-10-14

The search now returns this error::

  File "geosearch.py", line 7, in <module>
    for cache in geocaching.search(point, limit=50):
  File "/home/alex/.virtualenvs/pycaching/lib/python3.4/site-packages/pycaching/geocaching.py", line 138, in search
    page = self._search_get_page(point, page_num)
  File "/home/alex/.virtualenvs/pycaching/lib/python3.4/site-packages/pycaching/geocaching.py", line 21, in wrapper
    return func(*args, **kwargs)
  File "/home/alex/.virtualenvs/pycaching/lib/python3.4/site-packages/pycaching/geocaching.py", line 198, in _search_get_page
    return [self._search_parse_cache(c) for c in data]
  File "/home/alex/.virtualenvs/pycaching/lib/python3.4/site-packages/pycaching/geocaching.py", line 198, in <listcomp>
    return [self._search_parse_cache(c) for c in data]
  File "/home/alex/.virtualenvs/pycaching/lib/python3.4/site-packages/pycaching/geocaching.py", line 21, in wrapper
    return func(*args, **kwargs)
  File "/home/alex/.virtualenvs/pycaching/lib/python3.4/site-packages/pycaching/geocaching.py", line 225, in _search_parse_cache
    c.hidden = Util.parse_date(placed.text)
  File "/home/alex/.virtualenvs/pycaching/lib/python3.4/site-packages/pycaching/util.py", line 38, in parse_date
    raise errors.ValueError("Unknown date format.")

It is probably due to the recent changes in GC.com (change in the location of the user preferences, so the date formats are misinterpreted).

Beautiful Soup warning

Warning reported on WIndows x64:

Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:16:59) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
import pycaching
g = pycaching.login("user","pass")

C:\Program Files (x86)\Python 3.5\lib\site-packages\bs4__init__.py:166: UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("html.parser"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.

To get rid of this warning, change this:
BeautifulSoup([your markup])
to this:
BeautifulSoup([your markup], "html.parser") markup_type=markup_type))

Localization issue ?

>>> cache = geocaching.load_cache("GC12345")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.2/dist-packages/pycaching/geocaching.py", line 21, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.2/dist-packages/pycaching/geocaching.py", line 320, in load_cache
    c.cache_type = cache_type
  File "/usr/local/lib/python3.2/dist-packages/pycaching/cache.py", line 231, in cache_type
    raise ValueError("Cache type '{}' is not possible.".format(cache_type))
pycaching.errors.ValueError: Cache type 'Cache Mystère' is not possible.

(my geocaching.com account is in French)

Feature proposal: create or edit notifications

Hi,
I'd like to know if it was reasonably possible to add support for creating (or simply editing existing) notifications. My personal need/ use case consists updating coordinates of FTF notifications whenever I change my location and I've done some experimentation how to make this straight forward by using additional tools.

Cache long description not always parsed correctly

cache.py uses

to locate a cache's long description. This works for most caches, but some have additional
between the short and long descriptions. This causes cache.py to return the short description for both the .summary and .description fields. An example cache where this occurs is GC6C3A2. I solved this problem for my application by replacing cache.py line 655:
self.description = str(user_content[1].text)
with this:
self.description = root.find(id="ctl00_ContentBody_LongDescription").text.strip()
This worked for all the caches I tested, but my testing was not exhaustive.

Approximate geocache locations

So, @mkouhia, I've finally merged your work into the dev branch.

But before we can move forward, please try to fix an error on geocaching.py:360 (undefined variable new_zoom).

As I've walked through your code I've noticed, that it may be useful to create one more object – a Tile – to encapsulate (x, y, z) tuples and methods for working with tiles. What do you think?

error while installing

I tried installing the package, and got the following error:

Collecting pycaching
  Using cached https://files.pythonhosted.org/packages/e1/b8/dab5c9432d1af40f03fce718d05fc8fdc1588f88f724871d208460fde535/pycaching-3.6.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\MYUSERNAME\AppData\Local\Temp\pycharm-packaging\pycaching\setup.py", line 43, in <module>
        with (root / "requirements.txt").open(encoding="utf-8") as f:
      File "C:\Python36\lib\pathlib.py", line 1164, in open
        opener=self._opener)
      File "C:\Python36\lib\pathlib.py", line 1018, in _opener
        return self._accessor.open(self, flags, mode)
      File "C:\Python36\lib\pathlib.py", line 390, in wrapped
        return strfunc(str(pathobj), *args)
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\MYUSERNAME\\AppData\\Local\\Temp\\pycharm-packaging\\pycaching\\requirements.txt'
    
    ----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in C:\Users\MYUSERNAME\AppData\Local\Temp\pycharm-packaging\pycaching\

this happened on my friend's computer too. Has something maybe broken in the package files? am I doing it wrong? any workaround?

Thanks

Add possibility to fetch password from password store

I always have a bad feeling about storing passwords in plain text, which is why I use a password store to save my passwords gpg encrypted (GNU pass in my case). Since most of these password managers feature a command line interface I think it would be a nice feature to set an appropriate password-retrieval command in the config file mutually exclusive with plain-text password option.

IndexError when using linter

When calling python setup.py lint after cloning the repo (as described in CONTRIBUTING.rst), I get some error messages.

Calling flake8 ---version displays 2.6.2 (pycodestyle: 2.0.0, pyflakes: 1.2.3, mccabe: 0.5.2) CPython 3.6.0a3 on Windows.

The error message which is repeated some times:

running lint
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python\lib\multiprocessing\spawn.py", line 106, in spawn_main
    exitcode = _main(fd)
  File "C:\Python\lib\multiprocessing\spawn.py", line 115, in _main
    prepare(preparation_data)
  File "C:\Python\lib\multiprocessing\spawn.py", line 226, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Python\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
    run_name="__mp_main__")
  File "C:\Python\lib\runpy.py", line 254, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Python\lib\runpy.py", line 93, in _run_module_code
    with _TempModule(mod_name) as temp_module, _ModifiedArgv0(fname):
  File "C:\Python\lib\runpy.py", line 54, in __enter__
    self._saved_value = sys.argv[0]
IndexError: list index out of range

attribute missing

Add attribute touristOK

WARNING:root:Unknown attribute 'touristOK', ignoring.

trackable.post_log seems to work quite randomly

Hi,
I've experimented with the library for a while and I think I observed with some random behaviour with trackable.post_log. To me, it seems to work on/off, i.e. sometimes logging tbs is successful and some other time not.

Has anyone noticed similar behaviour? I think I can give an example of at least couple of TBs (TB5ZBY7) which fail to log.
By increasing log level I get

DEBUG:requests.packages.urllib3.connectionpool:"GET /track/details.aspx?tracker=XXXXXX HTTP/1.1" 200 68978
DEBUG:requests.packages.urllib3.connectionpool:"GET /track/log.aspx?wid=a9c1fca6-4b8c-4235-9ed4-a7cb7ab9257d&c=XXXXXX HTTP/1.1" 200 58194
DEBUG:requests.packages.urllib3.connectionpool:"POST /track/log.aspx?wid=a9c1fca6-4b8c-4235-9ed4-a7cb7ab9257d&c=XXXXXX HTTP/1.1" 200 58151

when it fails and

DEBUG:requests.packages.urllib3.connectionpool:"GET /track/details.aspx?tracker=XXXXXX HTTP/1.1" 200 69202
DEBUG:requests.packages.urllib3.connectionpool:"GET /track/log.aspx?wid=a9c1fca6-4b8c-4235-9ed4-a7cb7ab9257d&c=XXXXXX HTTP/1.1" 200 58194
DEBUG:requests.packages.urllib3.connectionpool:"POST /track/log.aspx?wid=a9c1fca6-4b8c-4235-9ed4-a7cb7ab9257d&c=XXXXXX HTTP/1.1" 302 158
DEBUG:requests.packages.urllib3.connectionpool:"GET /track/log.aspx?LogReferenceCode=YYYYYYYY HTTP/1.1" 200 53937

when it succeeds. TB logging code is hidden in above but I used the same one both times - PM if you wish to test this.

Refactor search_quick

  • simplify helper objects and methods like UTFGrid and GridCoordinateBlock
  • move logic determining which tiles to download outside of Geocaching class

Iterating over search pages throws KeyError

Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.8-intel/egg/pycaching/geocaching.py", line 124, in search
File "build/bdist.macosx-10.8-intel/egg/pycaching/geocaching.py", line 155, in _searchGetPage
KeyError: 11

pycaching.errors.ValueError: Unknown cache size

When the geocache account is set to another language than English, any request involving seeking cache info fails.

Example of code that fails (taken from docs):

point = Point(56.25263, 15.26738)

for cache in geocaching.search(point, limit=50):
if cache.type == Type.traditional:
print(cache.name)

Yields:

pycaching.errors.ValueError: Unknown cache size

Works as expected with user's preference set to English.

Log type '24' is not recognized

Load any cache as c and run the following:

for l in c.load_logbook():
    print('{} by {} ({}):\n\n{}'.format(l.type, l.author, l.visited, l.text))

All logs will output successfully, until the end, when the following exception is raised: pycaching.errors.ValueError: Unknown log type '24'..

By visiting https://www.geocaching.com/images/logtypes/24.png, one can see that log type '24' is 'Publish Listing'. Can this be added?

Allow tracking codes besides trackable id

Maybe it's a good idea to allow tracking codes besides the trackable id. Currently there seems to be a check for the first two characters of the given code and therefore inserting a tracking code fails.
The URL is the same as far as I know.

Rot13 crashes for non-ascii chars

While parsing French caches (that contains non ascii chars in the hint), the rot13 function crashes.

File "build/bdist.macosx-10.7-x86_64/egg/pycaching/geocaching.py", line 303, in loadCache
File "build/bdist.macosx-10.7-x86_64/egg/pycaching/util.py", line 86, in rot13decode
File "/Users/driquet/git/geotrails/venv/lib/python2.7/encodings/rot_13.py", line 20, in decode
return codecs.charmap_decode(input,errors,decoding_map)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 9: ordinal not in range(128)

Broken quick search

Not good. Probably some new kind of protection...

[pycaching] ricoo@pro ~/work/pycaching master $ ./setup.py nosetests --tests test.test_geocaching.TestMethods
running nosetests
running egg_info
writing top-level names to pycaching.egg-info/top_level.txt
writing pycaching.egg-info/PKG-INFO
writing dependency_links to pycaching.egg-info/dependency_links.txt
writing requirements to pycaching.egg-info/requires.txt
reading manifest file 'pycaching.egg-info/SOURCES.txt'
writing manifest file 'pycaching.egg-info/SOURCES.txt'
test_search (test.test_geocaching.TestMethods) ... ok
Perform search and check found caches ... FAIL
Test if search results matches exact cache locations. ... ok

======================================================================
FAIL: Perform search and check found caches
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ricoo/ownCloud/work/pycaching/test/test_geocaching.py", line 47, in test_search_quick
    self.assertIn(wp, res)
AssertionError: 'GC41FJC' not found in []
    """Fail immediately, with the given message."""
>>  raise self.failureException("'GC41FJC' not found in []")

-------------------- >> begin captured logging << --------------------
root: INFO: Searching quick in <pycaching.geo.Rectangle object at 0x10529ff60>
root: DEBUG: Area converted to 1 tiles, zoom level 14
root: DEBUG: Lazy loading blocks into <object <class 'pycaching.geo.Tile'> id 4379866560>
root: DEBUG: Downloading UTFGrid for <object Tile, id 4379866560, coords (8800, 5574, 14)>
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: INFO: Starting new HTTP connection (1): tiles01.geocaching.com
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8800&z=14&y=5574 HTTP/1.1" 204 0
root: DEBUG: Cannot load UTFgrid: no content. Trying to load .png tile first
root: DEBUG: Downloading UTFGrid for <object Tile, id 4379866560, coords (8800, 5574, 14)>
root: DEBUG: Getting .png file
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.png?x=8800&z=14&y=5574 HTTP/1.1" 200 9447
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8800&z=14&y=5574 HTTP/1.1" 204 0
root: DEBUG: There is really no content! Returning 0 caches.
root: DEBUG: No block loaded to <object Tile, id 4379866560, coords (8800, 5574, 14)>
root: DEBUG: Lazy loading blocks into <object <class 'pycaching.geo.Tile'> id 4392281480>
root: DEBUG: Downloading UTFGrid for <object Tile, id 4392281480, coords (8800, 5575, 14)>
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8800&z=14&y=5575 HTTP/1.1" 204 0
root: DEBUG: Cannot load UTFgrid: no content. Trying to load .png tile first
root: DEBUG: Downloading UTFGrid for <object Tile, id 4392281480, coords (8800, 5575, 14)>
root: DEBUG: Getting .png file
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.png?x=8800&z=14&y=5575 HTTP/1.1" 200 5588
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8800&z=14&y=5575 HTTP/1.1" 204 0
root: DEBUG: There is really no content! Returning 0 caches.
root: DEBUG: No block loaded to <object Tile, id 4392281480, coords (8800, 5575, 14)>
root: DEBUG: Lazy loading blocks into <object <class 'pycaching.geo.Tile'> id 4379866560>
root: DEBUG: Downloading UTFGrid for <object Tile, id 4379866560, coords (8801, 5574, 14)>
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8801&z=14&y=5574 HTTP/1.1" 204 0
root: DEBUG: Cannot load UTFgrid: no content. Trying to load .png tile first
root: DEBUG: Downloading UTFGrid for <object Tile, id 4379866560, coords (8801, 5574, 14)>
root: DEBUG: Getting .png file
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.png?x=8801&z=14&y=5574 HTTP/1.1" 200 4799
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8801&z=14&y=5574 HTTP/1.1" 204 0
root: DEBUG: There is really no content! Returning 0 caches.
root: DEBUG: No block loaded to <object Tile, id 4379866560, coords (8801, 5574, 14)>
root: DEBUG: Lazy loading blocks into <object <class 'pycaching.geo.Tile'> id 4379866616>
root: DEBUG: Downloading UTFGrid for <object Tile, id 4379866616, coords (8801, 5575, 14)>
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8801&z=14&y=5575 HTTP/1.1" 204 0
root: DEBUG: Cannot load UTFgrid: no content. Trying to load .png tile first
root: DEBUG: Downloading UTFGrid for <object Tile, id 4379866616, coords (8801, 5575, 14)>
root: DEBUG: Getting .png file
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.png?x=8801&z=14&y=5575 HTTP/1.1" 200 5193
root: DEBUG: Getting UTFGrid
requests.packages.urllib3.connectionpool: DEBUG: "GET /map.info?x=8801&z=14&y=5575 HTTP/1.1" 204 0
root: DEBUG: There is really no content! Returning 0 caches.
root: DEBUG: No block loaded to <object Tile, id 4379866616, coords (8801, 5575, 14)>
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 3 tests in 31.256s

FAILED (failures=1)

[pycaching] ricoo@pro ~/work/pycaching master $ ./setup.py nosetests --tests test.test_geocaching.TestMethods
running nosetests
running egg_info
writing requirements to pycaching.egg-info/requires.txt
writing pycaching.egg-info/PKG-INFO
writing top-level names to pycaching.egg-info/top_level.txt
writing dependency_links to pycaching.egg-info/dependency_links.txt
reading manifest file 'pycaching.egg-info/SOURCES.txt'
writing manifest file 'pycaching.egg-info/SOURCES.txt'
test_search (test.test_geocaching.TestMethods) ... ok
Perform search and check found caches ... ok
Test if search results matches exact cache locations. ... ok

----------------------------------------------------------------------
Ran 3 tests in 32.127s

OK

sphinxdoc/source/conf.py generates lots of lint errors

when running python3 setup.py lint

I get a lot of errors in ./sphinxdoc/source/conf.py

The errors are mostly
E265 block comment should start with '# '
and a couple of unused imports.

should the file (or maybe the entire sphinxdoc directory) be excluded from lint or should the errors be corrected?

Longitude/Latitude are being converted incorrectly when the final product should be negative.

In lines 73-76 of geo.py, the degree portion of coordinates is converted to negative if the corresponding measure is in the Southern Hemisphere or the Western Hemisphere. On line 78, the degree and minute components of the latitude and longitude are passed on to a function which converts them to decimal degree format. In that function, the degree component is added to the minute component over sixty. However, when the coordinates are in the Southern Hemisphere or the Western Hemisphere, the degree component of one or both coordinates is negative, but the corresponding minute component is positive. This has the unintended effect of converting Southern or Western coordinates by the formula –(degree – (minute/60)), when the correct formula would be –(degree + (minute/60)).

I believe this problem is a two-line fix. The previously linked code block(73-76 of geo.py) should be changed to the following:

            if "S" in string:
                latDeg *= -1
                latMin *= -1
            if "W" in string:
                lonDeg *= -1
                lonMin *= -1

This converts both the degree and minute portions of the coordinate to negative numbers, so that they can be added to increase the absolute value of the result, as intended.

This bug seems to have been introduced two years ago. I suspect the author never noticed it, as he appears to live in the Czech Republic, which is in the Northern and Eastern Hemispheres. 😜

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.