stdcarrot / py3amf Goto Github PK
View Code? Open in Web Editor NEWThis project forked from hydralabs/pyamf
AMF for Python3
License: Other
This project forked from hydralabs/pyamf
AMF for Python3
License: Other
I see a new release (0.8.11) of Py3AMF is available on PyPI. However the older 0.8.10 is no longer available for download there. The problem is that external projects depend on it, namely oe-alliance-core, the basis of a ton of satellite receiver set top boxes. That build is now broken. Is there any way you could put 0.8.10 on PyPI again, until things in openoe-alliance catch up?
Incidentally, there's no 0.8.11 on your github either.
I am on python 3.6.2 and when I run my tests through pytest I get the following warnings related to Py3AMF:
/Users/nilswerner/.pyenv/versions/3.6.2/envs/drf-formulator-feed/lib/python3.6/site-packages/pyamf/remoting/__init__.py:139: DeprecationWarning: generator 'Envelope.__iter__' raisedStopIteration
for request in iter(self):
/Users/nilswerner/.pyenv/versions/3.6.2/envs/drf-formulator-feed/lib/python3.6/site-packages/pyamf/remoting/__init__.py:139: DeprecationWarning: generator 'Envelope.__iter__' raisedStopIteration
for request in iter(self):
tests/unit/test_drf_service/test_amf_client.py::test_get_filename_response
/Users/nilswerner/.pyenv/versions/3.6.2/envs/drf-formulator-feed/lib/python3.6/site-packages/pyamf/remoting/__init__.py:139: DeprecationWarning: generator 'Envelope.__iter__' raisedStopIteration
for request in iter(self):
/Users/nilswerner/.pyenv/versions/3.6.2/envs/drf-formulator-feed/lib/python3.6/site-packages/pyamf/remoting/__init__.py:139: DeprecationWarning: generator 'Envelope.__iter__' raisedStopIteration
for request in iter(self):```
Hi. I am trying to use Py3AMF to communicate with an AMF gateway, and I'm getting a bunch of errors in the process, due to poor understanding of the gateway on the remote end (completely because of me). However, I am unable to use pyamf.remoting.decode()
to parse the resulting error messages from the server, despite them being valid AMF. I get the following error:
AttributeError: Static attributes {'destination', 'headers', 'rootCause', 'timeToLive', 'timestamp', 'extendedData', 'clientId', 'body', 'messageId'} expected when decoding <class 'pyamf.flex.messaging.ErrorMessage'>
Below is the full hex dump of one such responses that the library refuses to parse, with some data redacted with '#':
00 00 00 01 00 12 41 70 70 65 6E 64 54 6F 47 61 74 65 77 61 79 55 72 6C 00 00 00 00 28 02 00 25 3F 50 48 50 53 45 53 53 49 44 3D 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 5D 00 01 00 0B 2F 31 2F 6F 6E 53 74 61 74 75 73 00 04 6E 75 6C 6C 00 00 01 1F 11 0A 0B 49 66 6C 65 78 2E 6D 65 73 73 61 67 69 6E 67 2E 6D 65 73 73 61 67 65 73 2E 45 72 72 6F 72 4D 65 73 73 61 67 65 1B 63 6F 72 72 65 6C 61 74 69 6F 6E 49 64 01 13 66 61 75 6C 74 43 6F 64 65 06 29 41 4D 46 50 48 50 5F 52 55 4E 54 49 4D 45 5F 45 52 52 4F 52 17 66 61 75 6C 74 44 65 74 61 69 6C 06 81 7F 43 3A 5C 50 72 6F 67 72 61 6D 20 46 69 6C 65 73 20 28 78 38 36 29 5C 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 5C 61 6D 66 70 68 70 5C 73 65 72 76 69 63 65 73 5C 23 23 23 23 23 23 23 23 2E 70 68 70 20 6F 6E 20 6C 69 6E 65 20 33 30 32 17 66 61 75 6C 74 53 74 72 69 6E 67 06 57 4D 69 73 73 69 6E 67 20 61 72 67 75 6D 65 6E 74 20 31 20 66 6F 72 20 47 65 74 23 23 23 23 23 3A 3A 74 65 73 74 23 23 23 23 28 29 01
Am I doing it wrong, or is there something wrong with the module? How can I handle error messages gracefully? Right now I am catching AttributeError, but I'm missing out on the error message data.
It would be great if version 0.8.7 was available in PyPi, since the http header fix is really import for me.
msg = messaging.RemotingMessage(
messageId=str(uuid.uuid1()).upper(),
clometOd=None,
operation='findBizObjEx',
destination='superSystemFacadeService',
timeTolive=0,
timestamp=0
)
string = "78daa5524d6fd33018fe2b93cf69643b8d49bc5"
userDtoBytes = bytearray(string, encoding='utf-8')
msg.headers['userDtoBytes'] = userDtoBytes"
userDtoBytes = bytearray(string, encoding='utf-8')
msg.headers['userDtoBytes'] = userDtoBytes
I tried to construct this request but an exception was thrown!
Seems to be an argument that does not support passing a bytearray
I hope to get your reply
Traceback (most recent call last):
File "C:/Users/EDZ/PycharmProjects/untitled1/pyamf_test.py", line 62, in
ihotel_spider.construct_flex_message()
File "C:/Users/EDZ/PycharmProjects/untitled1/pyamf_test.py", line 56, in construct_flex_message
bin_msg = remoting.encode(ev)
File "C:\Users\EDZ\Envs\py2\lib\site-packages\pyamf\remoting_init_.py", line 724, in encode
write_body(name, message, stream, encoder, strict)
File "C:\Users\EDZ\Envs\py2\lib\site-packages\pyamf\remoting_init.py", line 550, in _write_body
encode_body(message)
File "C:\Users\EDZ\Envs\py2\lib\site-packages\pyamf\remoting_init.py", line 523, in _encode_body
encoder.writeElement(x)
File "cpyamf/codec.pyx", line 623, in cpyamf.codec.Encoder.writeElement (cpyamf\codec.c:10902)
File "cpyamf/codec.pyx", line 629, in cpyamf.codec.Encoder.writeElement (cpyamf\codec.c:10661)
File "cpyamf/amf0.pyx", line 581, in cpyamf.amf0.Encoder.handleBasicTypes (cpyamf\amf0.c:7975)
File "cpyamf/amf0.pyx", line 577, in cpyamf.amf0.Encoder.writeAMF3 (cpyamf\amf0.c:7917)
File "cpyamf/codec.pyx", line 645, in cpyamf.codec.Encoder.writeElement (cpyamf\codec.c:10786)
File "cpyamf/amf3.pyx", line 930, in cpyamf.amf3.Encoder.writeObject (cpyamf\amf3.c:11500)
File "cpyamf/codec.pyx", line 629, in cpyamf.codec.Encoder.writeElement (cpyamf\codec.c:10661)
File "cpyamf/amf3.pyx", line 1034, in cpyamf.amf3.Encoder.handleBasicTypes (cpyamf\amf3.c:12466)
File "cpyamf/codec.pyx", line 587, in cpyamf.codec.Encoder.handleBasicTypes (cpyamf\codec.c:9961)
File "cpyamf/amf3.pyx", line 790, in cpyamf.amf3.Encoder.writeDict (cpyamf\amf3.c:10088)
File "cpyamf/codec.pyx", line 645, in cpyamf.codec.Encoder.writeElement (cpyamf\codec.c:10786)
File "cpyamf/amf3.pyx", line 911, in cpyamf.amf3.Encoder.writeObject (cpyamf\amf3.c:11322)
File "C:\Users\EDZ\Envs\py2\lib\site-packages\pyamf\alias.py", line 404, in getEncodableAttributes
return obj.dict.copy()
AttributeError: 'bytearray' object has no attribute 'dict'
Hello, i am use Wireshark for capture packets and me need decode this.
I try your library but get error - pyamf.DecodeError: Malformed stream (amfVersion=11822)
How i can solve this?
C:\xampp_2015\htdocs\Py3AMF>a
Traceback (most recent call last):
File "C:\xampp_2015\htdocs\Py3AMF\test.py", line 24, in
resp_msg = remoting.decode(resp.content)
File "C:\xampp_2015\htdocs\Py3AMF\pyamf\remoting_init_.py", line 631, in decode
raise pyamf.DecodeError(
pyamf.DecodeError: Malformed stream (amfVersion=15423)
Hi, i have problem decoding amf data included with this character �
this is my code :
def decodeEnvelope(self, resp):
# Decode the Base64 encoded response to bytes
decoded_bytes = base64.b64decode(resp)
# Attempt to decode the bytes as unicode with ignoring errors
decoded_data = decoded_bytes.decode('latin-1', errors='ignore')
# Decode the AMF (Action Message Format) data directly
try:
decodedAMF = remoting.decode(decoded_data)
return decodedAMF
except Exception as e:
print(f"Failed to decode AMF data: {e}")
return None
and the resp data is AAAAAAABAAsvMS9vblJlc3VsdAAEbnVsbAAAAuIDAAZzdGF0dXMAP/AAAAAAAAAABWVycm9yAAAAAAAAAAAAAAN1aWQCAAYzNjAxMDkACnNlc3Npb25rZXkCACAxMGE5YjY0YzgxMDdiM2M5NWE1YTVhZDMwMDBjYmI5NgAEaGFzaAIAQGY3ZmFmMzlmYzA1OGEyNzFmZTNmNzRlMzE0Njc3MTg4ZGExN2ZhZmNmZjk3OGQ3MjExNTZlMTNkMmYwOWU0MDcAC3N5c3RlbV90aW1lAgAKdHNqS2lRSFdvUgAEbmV3cwIB8U5ld3M8YnI+LSA5MCsgTGV2ZWwgc2tpbGxzIGFyZSBub3cgYXZhaWxhYmxlIGluIHRoZSBhY2FkZW15ITxicj4tIEVtYmxlbSsgaXMgbm93IGF2YWlsYWJsZSE8YnI+LSBOZXcgRXh0cmVtZSBUYWxlbnQgQ2F0YWNseXNtIGlzIG5vdyBhdmFpbGFibGUhPGJyPi0gTmV3IFBldHMgYXJlIGF2YWlsYWJsZSBpbiBlYWNoIHZpbGxhZ2VzIHBldCBzaG9wITxicj4tIEdlYXIgRmlsdGVycyBhcmUgbm93IGF2YWlsYWJsZSBmb3IgRW1ibGVtKyE8YnI+LSBTa2lsbCBQcmVzZXQgdXBkYXRlZCAzIHNsb3RzL2ZyZWUgdXNlciwgNiBzbG90cy9lbWJsZW0sIDkgc2xvdHMvZW1ibGVtKzxicj48YnI+QnVnIEZpeGVzPGJyPi0gRml4ZWQgYW4gaXNzdWUgd2l0aCBDbGFuIFNob3AsIHNvbWUgaXRlbXMgd2VyZW6SdCBidXlhYmxlLjxicj4tIEZpeGVkIGFuIGlzc3VlIHdpdGggRXllIG9mIE1pcnJvciBUaXRhbiB3aGVuIHVzaW5nIFN1cnByaXNlIEF0dGFjayBDbGFzcyBhbmQgU2VuanV0c3UuAAtjbGFuX3NlYXNvbgIAAjM2AAtjcmV3X3NlYXNvbgIAATUAAAk=
There is two DeprecationWarning in Python 3.12.
pyamf/util/__init__.py:217: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
datetime.datetime.utcfromtimestamp(-31536000.0)
pyamf/adapters/__init__.py:44
/home/benoit/Repos/openzim/warc2zim/.hatch/warc2zim/lib/python3.12/site-packages/pyamf/adapters/__init__.py:44: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
import pkg_resources
First one is probably minor to fix.
Second one is kind of a blocker for Python 3.12, but there is a fallback in the code, so it probably still works in most situations.
The second one can probably easily be fixed with https://docs.python.org/3/library/importlib.resources.html with something like this:
try:
from importlib import resources
....
except:
try:
import pkg_resources
packageDir = pkg_resources.resource_filename('pyamf', 'adapters')
except:
packageDir = os.path.dirname(__file__)
It seems, the Python Py3amf does not have last 2 objects supported from this list:
undefined-marker=0x00
null-marker=0x01
false-marker=0x02
true-marker=0x03
integer-marker=0x04
double-marker=0x05
string-marker=0x06
xml-doc-marker=0x07
date-marker=0x08
array-marker=0x09
object-marker=0x0A
xml-marker=0x0B
byte-array-marker=0x0C
vector-int-marker=0x0D
vector-uint-marker=0x0E
vector-double-marker=0x0F
vector-object-marker=0x10
dictionary-marker=0x11
If I am wrong, please tell me where. When I try to parse amf3 content that has dictionary, it fails.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.