gpxity.backends package

Submodules

gpxity.backends.directory module

Defines gpxity.Directory

class gpxity.backends.directory.Directory(url=None, auth=None, cleanup=False, debug=False, prefix: str = None)[source]

Bases: gpxity.backend.Backend

Uses a directory for storage. The filename minus the .gpx ending is used as the activity id. If the activity has a title, use the title as storage id, making it unique by attaching a number if needed. An activity without title gets a random name.

The main directory (given by Directory.url) will have subdirectories YYYY/MM (year/month) with only the activities for one month. Those are symbolic links to the main file and have the same file name.

If save() is given a value for ident, this is used as id, the file name will be id.gpx. Otherwise, this backend uses Activity.title for the id. If an activity has no title, it uses a random sequence of characters. Changing the title also changes the id.

Parameters:
  • url (str) – a directory. If no Url is given, either here or through auth, use a unique temporary directory named prefix.X where X are some random characters. If the directory does not exist, it is created.
  • auth (str) – You can use this as in every backend to define Url= in auth.cfg
  • cleanup (bool) – If True, destroy() will remove all activities. If url was not given, it will also remove the directory.
  • prefix – The prefix for a temporary directory path. Must not be given if url is given.
prefix

str – Class attribute, may be changed. The default prefix for temporary directories. Default value is gpxity.

fs_encoding

str – The encoding for file system names. By default, we expect the file system being able to handle arbitrary UTF-8 encoded names except character ‘/’ and special names ‘.’ and ‘..’. If needed, we will introduce new possible values for fs_encoding like perhaps ‘windows’. Gpxity will never support any other character set but UTF-8. Note that fs_encoding is independent of the platform we are running on - we might use a network file system.

is_temporary

bool – True if no Url was given and we created a temporary directory

decode_what(value: str) → str[source]

Not needed for directory, this is always the internal value.

destroy()[source]

If cleanup was set at init time, removes all activities. If url was set at init time, also removes the directory.

encode_what(value: str) → str[source]

Not needed for directory, this is always the internal value.

get_time() → datetime.datetime[source]

get server time as a Linux timestamp

gpx_path(ident)[source]

The full path name for the local copy of an activity

legal_whats

Returns – list(str) all legal values for what for this backend.

supported = {'remove', '_write_all', 'get_time'}

gpxity.backends.gpsies module

This implements gpsies.GPSIES for https://www.gpsies.com

so ginge das mit dem API-Key: https://github.com/telemaxx/gpsiesreader/blob/master/gpsies3.py

class gpxity.backends.gpsies.GPSIES(url=None, auth=None, cleanup=False, debug=False, timeout=None)[source]

Bases: gpxity.backend.Backend

The implementation for gpsies.com. The activity ident is the fileId given by gpsies.

Searching arbitrary tracks is not supported. GPSIES only looks at the tracks of a specific user.

Parameters:
decode_what(value: str) → str[source]

Translate the value from Gpsies into internal one.

destroy()[source]

also close session

encode_what(value: str) → str[source]

Translate internal value into Gpsies value

legal_whats

Returns – list(str) all legal values for what.

session

The requests.Session for this backend. Only initialized once.

supported = {'remove', '_write_title', '_write_description', '_write_what', '_write_public', '_write_all'}

gpxity.backends.mmt module

This implements gpxity.MMT for http://www.mapmytracks.com

There are some problems with the server running at mapmytracks.com:
  • it is not possible to change an existing activity - if the track changes, the activity must be re-uploaded and gets a new activity id This invalididates references held by other backend instances (maybe on other clients). But I could imagine that most similar services have this problem too.
  • does not support GPX very well beyond track data. One problem is that it does not support gpx.time, it ignores it in uploads and uses the time of the earliest trackpoint. To be consistent, Gpxity follows that for now and does not respect gpx.time either.
  • there is an official description of an API at https://github.com/MapMyTracks but this does not implement everything needed. For the missing parts we simulate what a web browser would do, see MMT._read_all() and MMT._write_attribute(). Of course that could fail if MMT changes its site. Which is true for the api itself, it can and does get incompatible changes at any time without notice to users or deprecation periods.
  • downloading activities with that abi is very slow and hangs forever for big activities (at least this was so in Feb 2017, maybe have to test again occasionally).
  • not all parts of MMT data are supported like images (not interesting for me, at least not now).
class gpxity.backends.mmt.MMT(url=None, auth=None, cleanup=False, debug=False, timeout=None)[source]

Bases: gpxity.backend.Backend

The implementation for MapMyTracks. The activity ident is the number given by MapMyTracks.

MMT knows tags. We map Activity.keywords to MMT tags. MMT will change keywords: It converts the first character to upper case. See Activity.keywords for how Gpxity handles this.

Parameters:
decode_what(value: str) → str[source]

Translate the value from MMT into internal one. Since gpxity once decided to use MMT definitions for activities, this should mostly be 1:1 here.

destroy()[source]

also close session

encode_what(value: str) → str[source]

Translate internal value into MMT value

get_time() → datetime.datetime[source]

get MMT server time

legal_whats

Returns – list(str) all legal values for what.

mid

the member id on MMT belonging to auth

override_ident(ident: str)[source]

Temporarily override the activity ident. While this is active, only the one activity meant must be used.

session

The requests.Session for this backend. Only initialized once.

supported = {'remove', 'track', '_write_title', '_write_description', '_write_add_keyword', '_write_keywords', '_write_what', 'get_time', '_write_public', '_write_remove_keyword', '_write_all'}

gpxity.backends.server_directory module

This implements gpxity.ServerDirectory

class gpxity.backends.server_directory.ServerDirectory(url=None, auth=None, cleanup=False, debug=False, prefix: str = None)[source]

Bases: gpxity.backends.directory.Directory

Like Directory but the activity ids are different: Just a number. A new id is generated by adding 1 to the highest existing id.

The symbolic links per YYYY/MM use the title of the activity as link name.

supported = {'remove', '_write_all', 'get_time'}