Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.settings
*.pyc
.project
.pydevproject
# files for git to ignore
.DS_STORE
*.sublime-project
*.sublime-workspace
*.idea
*__pycache__
*__pycache__
14 changes: 12 additions & 2 deletions gps/__init__.py → gpspy3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
api_major_version = 5 # bumped on incompatible changes
api_minor_version = 0 # bumped on compatible changes

from .gps import *
from .misc import *
#Setup a logger that can be imported and used
import logging

logger = logging.getLogger(__name__)
handler = logging.StreamHandler()
formatter = logging.Formatter(
'%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)


# The 'client' module exposes some C utility functions for Python clients.
# The 'packet' module exposes the packet getter via a Python interface.

4 changes: 3 additions & 1 deletion gps/client.py → gpspy3/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import socket
import sys
import select #, exceptions
from gpspy3 import logger


if sys.hexversion >= 0x2060000:
import json # For Python 2.6
Expand Down Expand Up @@ -86,7 +88,7 @@ def read(self):
if eol == -1:
# ensure that data is available on the socket
if not self.waiting(timeout=1):
print("gps.client: no data available on socket")
logger.warn("gps.client: no data available on socket")
return -1
frag = self.sock.recv(4096)
self.linebuffer += frag.decode() # convert to str
Expand Down
2 changes: 1 addition & 1 deletion gps/fake.py → gpspy3/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"""
import os, sys, time, signal, pty, termios # fcntl, array, struct
import threading, socket, select # exceptions
import gps
import gpspy3.gps
import packet as sniffer

# The two magic numbers below have to be derived from observation. If
Expand Down
10 changes: 5 additions & 5 deletions gps/gps.py → gpspy3/gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
# The JSON parts of this (which will be reused by any new interface)
# now live in a different module.
#
from .client import *
from .misc import iso_time
from gpspy3.misc import iso_time
from gpspy3.client import *
from gpspy3 import logger

NaN = float('nan')


def isnan(x):
return str(x) == 'nan'

Expand Down Expand Up @@ -286,7 +286,7 @@ def default(k, dflt, vbit=0):
self.utc = default("time", None, TIME_SET)
if self.utc is not None:
# Time can be either Unix time as a float or an ISO8601 string
print("GPS: received fix.time type={}".format(type(self.fix.time))) # TODO: Remove after verified
logger.info("GPS: received fix.time type={}".format(type(self.fix.time))) # TODO: Remove after verified
if isinstance(self.fix.time, float): # changed from type(self.fix.time) == type(0.0):
self.fix.time = self.utc
elif isinstance(self.fix.time, bytes): # added
Expand Down Expand Up @@ -374,7 +374,7 @@ def stream(self, flags=0, devpath=None):
if switch == '-v':
verbose = True
if len(arguments) > 2:
print('Usage: gps.py [-v] [host [port]]')
logger.error('Usage: gps.py [-v] [host [port]]')
sys.exit(1)

opts = {"verbose": verbose}
Expand Down
File renamed without changes.
Empty file added requirements.txt
Empty file.
21 changes: 21 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
from setuptools import setup, find_packages
from pip.req import parse_requirements
from pip.download import PipSession

install_reqs = parse_requirements("requirements.txt", session=PipSession())
reqs = [str(ir.req) for ir in install_reqs]

setup(
name = "gpspy3",
version = "0.1.0",
packages=find_packages(),
author = "",
author_email = "",
description = (""),
license = "",
keywords = "",
url = "",
install_requires=reqs
)