ampledata / aprs

Python APRS Module
https://github.com/ampledata/aprs
Other
95 stars 53 forks source link

Problems with examples #14

Open fredlcoxiii opened 7 years ago

fredlcoxiii commented 7 years ago

Thank you for working on making APRS available through Python. I encountered problems with both the send and receive examples. I will copy the source files and results of execution below. I am using 32 bit Python 3.6.0 on Windows 10:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 07:18:10) [MSC v.1900 32 bit (Intel)] on win32

I executed "pip install aprs" a little earlier this evening, so everything should be fresh.

================================================================= ''' test APRS code for receiving

from https://pypi.python.org/pypi/aprs/6.0.1 '''

import aprs

def p(x): print(x)

a = aprs.TCP('W2GMD', '12345')

a = aprs.TCP('KE0KUZ', '23990') a.start()

a.receive(callback=p)

OUTPUT: 2017-03-26 21:27:26,391 aprs INFO aprs.classes.start:368 - Connecting to to "('rotate.aprs.net', 14580)" 2017-03-26 21:27:26,555 aprs DEBUG aprs.classes.start:371 - Sending full _auth=user KE0KUZ pass 23990 vers APRS Python Module filter p/KE0KUZ Traceback (most recent call last): File "xreceive.py", line 13, in a.start() File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classe s.py", line 372, in start self.interface.sendall(self._full_auth + '\n\r') TypeError: a bytes-like object is required, not 'str'

================================================================= ''' test APRS code for sending

from https://pypi.python.org/pypi/aprs/6.0.1 ''' import aprs

frame = aprs.Frame('KE0KUZ>APRS:>Hello World!')

a = aprs.TCP('W2GMD', '12345')

a = aprs.TCP('KE0KUZ', '23990') a.start()

a.send(frame)

OUTPUT: Traceback (most recent call last): File "xsend.py", line 8, in frame = aprs.Frame('KE0KUZ>APRS:>Hello World!') File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classes.py", line 87, in init self.parse() File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classes.py", line 120, in parse self.parse_text() File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classes.py", line 132, in parse_text for char in self.frame.decode('UTF-8'): AttributeError: 'str' object has no attribute 'decode'

fredlcoxiii commented 7 years ago

I'm not sure why the code and output fonts are so scrambled in what I sent you. They looked fine when I sent them. You can't tell it from the above, but I commented out the lines that contained your callsign and added the equivalent lines with my callsign and passcode. If you need me to try to resend, please let me know and if possible make suggestions of how to do so without the font distortions.

fredlcoxiii commented 7 years ago

I see the insert code "<>" command, so I'll try again.

================================================================== `''' test APRS code for receiving

from https://pypi.python.org/pypi/aprs/6.0.1 '''

import aprs

def p(x): print(x)

a = aprs.TCP('W2GMD', '12345')

a = aprs.TCP('KE0KUZ', '23990') a.start()

a.receive(callback=p)`

2017-03-26 21:27:26,391 aprs INFO aprs.classes.start:368 - Connecting to to "('rotate.aprs.net', 14580)" 2017-03-26 21:27:26,555 aprs DEBUG aprs.classes.start:371 - Sending full _auth=user KE0KUZ pass 23990 vers APRS Python Module filter p/KE0KUZ Traceback (most recent call last): File "xreceive.py", line 13, in <module> a.start() File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classe s.py", line 372, in start self.interface.sendall(self._full_auth + '\n\r') TypeError: a bytes-like object is required, not 'str'

================================================================== `''' test APRS code for sending

from https://pypi.python.org/pypi/aprs/6.0.1 ''' import aprs

frame = aprs.Frame('KE0KUZ>APRS:>Hello World!')

a = aprs.TCP('W2GMD', '12345')

a = aprs.TCP('KE0KUZ', '23990') a.start()

a.send(frame)`

Traceback (most recent call last): File "xsend.py", line 8, in <module> frame = aprs.Frame('KE0KUZ>APRS:>Hello World!') File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classe s.py", line 87, in __init__ self.parse() File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classe s.py", line 120, in parse self.parse_text() File "C:\Program Files (x86)\Python36-32\lib\site-packages\aprs\classe s.py", line 132, in parse_text for char in self.frame.decode('UTF-8'): AttributeError: 'str' object has no attribute 'decode'

fredlcoxiii commented 7 years ago

Well, it didn't seem to help to use the <> command. If you email me, I'll send you the source files and outputs in email. fredlcoxiii@gmail.com

vetsin commented 7 years ago

Looks like the library does not support Python 3.6.0 as you're using. Try the newest version of 2.7.

stroobandt commented 7 years ago

I also receive a TypeError when running Example 2 in Python 3.6.2:

In [1]: import aprs
   ...: 

In [2]: frame = aprs.Frame('ON4AA>APRS:>Hello World!')
   ...: 

In [3]: a = aprs.TCP('ON4AA', '12345')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-70e392395786> in <module>()
----> 1 a = aprs.TCP('ON4AA', '12345')

/usr/lib/python3.6/site-packages/aprs/classes.py in __init__(self, user, password, servers, aprs_filter)
    271         super(TCP, self).__init__(user, password)
    272         servers = servers or aprs.APRSIS_SERVERS  # Unicode
--> 273         aprs_filter = aprs_filter or b'/'.join([b'p', user])  # Unicode
    274         if isinstance(aprs_filter, str):
    275             aprs_filter = bytes(aprs_filter, 'UTF-8')

TypeError: sequence item 1: expected a bytes-like object, str found
stroobandt commented 7 years ago

…and in Python 2.7.12, Example 2 returns the following error:

Traceback (most recent call last):
  File "./aprs", line 3, in <module>
    import aprs
  File "/usr/local/lib/python2.7/dist-packages/aprs/__init__.py", line 29, in <module>
    from .geo_util import dec2dm_lat, dec2dm_lng, ambiguate  # NOQA
  File "/usr/local/lib/python2.7/dist-packages/aprs/geo_util.py", line 13
    def dec2dm_lat(dec: float) -> str:
                      ^
SyntaxError: invalid syntax
2E0PGS commented 5 years ago

Yep I have the same issue. https://github.com/rossengeorgiev/aprs-python works out the box however.

in3aqk commented 4 years ago

Same issues as above described from other developers, any solutions?

casterlan commented 4 years ago

…and in Python 2.7.12, Example 2 returns the following error:

Traceback (most recent call last):
  File "./aprs", line 3, in <module>
    import aprs
  File "/usr/local/lib/python2.7/dist-packages/aprs/__init__.py", line 29, in <module>
    from .geo_util import dec2dm_lat, dec2dm_lng, ambiguate  # NOQA
  File "/usr/local/lib/python2.7/dist-packages/aprs/geo_util.py", line 13
    def dec2dm_lat(dec: float) -> str:
                      ^
SyntaxError: invalid syntax

The problem is "annotations" like "(dec: float)" are PEP3107 implemented in 3.6 and later. So this would need to be re-written to be forward compatible starting with 2.7.

Ref: https://www.python.org/dev/peps/pep-3107/ https://realpython.com/lessons/annotations/