Updated script that can be controled by Nodejs web app

This commit is contained in:
mac OS
2024-11-25 12:24:18 +07:00
parent c440eda1f4
commit 8b0ab2bd3a
8662 changed files with 1803808 additions and 34 deletions

View File

@ -0,0 +1,203 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2024 engn33r
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -0,0 +1,184 @@
Metadata-Version: 2.1
Name: websocket-client
Version: 1.8.0
Summary: WebSocket client for Python with low level API options
Home-page: https://github.com/websocket-client/websocket-client.git
Download-URL: https://github.com/websocket-client/websocket-client/releases
Author: liris
Author-email: liris.pp@gmail.com
Maintainer: engn33r
Maintainer-email: websocket.client@proton.me
License: Apache-2.0
Project-URL: Documentation, https://websocket-client.readthedocs.io/
Project-URL: Source, https://github.com/websocket-client/websocket-client/
Keywords: websockets client
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Intended Audience :: Developers
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: docs
Requires-Dist: Sphinx >=6.0 ; extra == 'docs'
Requires-Dist: sphinx-rtd-theme >=1.1.0 ; extra == 'docs'
Requires-Dist: myst-parser >=2.0.0 ; extra == 'docs'
Provides-Extra: optional
Requires-Dist: python-socks ; extra == 'optional'
Requires-Dist: wsaccel ; extra == 'optional'
Provides-Extra: test
Requires-Dist: websockets ; extra == 'test'
[![docs](https://readthedocs.org/projects/websocket-client/badge/?style=flat)](https://websocket-client.readthedocs.io/)
[![Build Status](https://github.com/websocket-client/websocket-client/actions/workflows/build.yml/badge.svg)](https://github.com/websocket-client/websocket-client/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/websocket-client/websocket-client/branch/master/graph/badge.svg?token=pcXhUQwiL3)](https://codecov.io/gh/websocket-client/websocket-client)
[![PyPI Downloads](https://pepy.tech/badge/websocket-client)](https://pepy.tech/project/websocket-client)
[![PyPI version](https://img.shields.io/pypi/v/websocket_client)](https://pypi.org/project/websocket_client/)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
# websocket-client
websocket-client is a WebSocket client for Python. It provides access
to low level APIs for WebSockets. websocket-client implements version
[hybi-13](https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-13)
of the WebSocket protocol. This client does not currently support the
permessage-deflate extension from
[RFC 7692](https://tools.ietf.org/html/rfc7692).
## Documentation
This project's documentation can be found at
[https://websocket-client.readthedocs.io/](https://websocket-client.readthedocs.io/)
## Contributing
Please see the [contribution guidelines](https://github.com/websocket-client/websocket-client/blob/master/CONTRIBUTING.md)
## Installation
You can use `pip install websocket-client` to install, or `pip install -e .`
to install from a local copy of the code. This module is tested on Python 3.8+.
There are several optional dependencies that can be installed to enable
specific websocket-client features.
- To install `python-socks` for proxy usage and `wsaccel` for a minor performance boost, use:
`pip install websocket-client[optional]`
- To install `websockets` to run unit tests using the local echo server, use:
`pip install websocket-client[test]`
- To install `Sphinx` and `sphinx_rtd_theme` to build project documentation, use:
`pip install websocket-client[docs]`
While not a strict dependency, [rel](https://github.com/bubbleboy14/registeredeventlistener)
is useful when using `run_forever` with automatic reconnect. Install rel with `pip install rel`.
Footnote: Some shells, such as zsh, require you to escape the `[` and `]` characters with a `\`.
## Usage Tips
Check out the documentation's FAQ for additional guidelines:
[https://websocket-client.readthedocs.io/en/latest/faq.html](https://websocket-client.readthedocs.io/en/latest/faq.html)
Known issues with this library include lack of WebSocket Compression
support (RFC 7692) and [minimal threading documentation/support](https://websocket-client.readthedocs.io/en/latest/threading.html).
## Performance
The `send` and `validate_utf8` methods can sometimes be bottleneck.
You can disable UTF8 validation in this library (and receive a
performance enhancement) with the `skip_utf8_validation` parameter.
If you want to get better performance, install wsaccel. While
websocket-client does not depend on wsaccel, it will be used if
available. wsaccel doubles the speed of UTF8 validation and
offers a very minor 10% performance boost when masking the
payload data as part of the `send` process. Numpy used to
be a suggested performance enhancement alternative, but
[issue #687](https://github.com/websocket-client/websocket-client/issues/687)
found it didn't help.
## Examples
Many more examples are found in the
[examples documentation](https://websocket-client.readthedocs.io/en/latest/examples.html).
### Long-lived Connection
Most real-world WebSockets situations involve longer-lived connections.
The WebSocketApp `run_forever` loop will automatically try to reconnect
to an open WebSocket connection when a network
connection is lost if it is provided with:
- a `dispatcher` argument (async dispatcher like rel or pyevent)
- a non-zero `reconnect` argument (delay between disconnection and attempted reconnection)
`run_forever` provides a variety of event-based connection controls
using callbacks like `on_message` and `on_error`.
`run_forever` **does not automatically reconnect** if the server
closes the WebSocket gracefully (returning
[a standard websocket close code](https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1)).
[This is the logic](https://github.com/websocket-client/websocket-client/pull/838#issuecomment-1228454826) behind the decision.
Customizing behavior when the server closes
the WebSocket should be handled in the `on_close` callback.
This example uses [rel](https://github.com/bubbleboy14/registeredeventlistener)
for the dispatcher to provide automatic reconnection.
```python
import websocket
import _thread
import time
import rel
def on_message(ws, message):
print(message)
def on_error(ws, error):
print(error)
def on_close(ws, close_status_code, close_msg):
print("### closed ###")
def on_open(ws):
print("Opened connection")
if __name__ == "__main__":
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://api.gemini.com/v1/marketdata/BTCUSD",
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.run_forever(dispatcher=rel, reconnect=5) # Set dispatcher to automatic reconnection, 5 second reconnect delay if connection closed unexpectedly
rel.signal(2, rel.abort) # Keyboard Interrupt
rel.dispatch()
```
### Short-lived Connection
This is if you want to communicate a short message and disconnect
immediately when done. For example, if you want to confirm that a WebSocket
server is running and responds properly to a specific request.
```python
from websocket import create_connection
ws = create_connection("ws://echo.websocket.events/")
print(ws.recv())
print("Sending 'Hello, World'...")
ws.send("Hello, World")
print("Sent")
print("Receiving...")
result = ws.recv()
print("Received '%s'" % result)
ws.close()
```

View File

@ -0,0 +1,56 @@
../../../bin/wsdump,sha256=FrQhl_emEK8n5aLGP_TfEtlNEOmurIVSkxu3XEKuNEQ,286
websocket/__init__.py,sha256=GvVpTPkjvhYEGZcjXszSfrs2FaVHudUdGgGSqf_Rbw4,833
websocket/__pycache__/__init__.cpython-313.pyc,,
websocket/__pycache__/_abnf.cpython-313.pyc,,
websocket/__pycache__/_app.cpython-313.pyc,,
websocket/__pycache__/_cookiejar.cpython-313.pyc,,
websocket/__pycache__/_core.cpython-313.pyc,,
websocket/__pycache__/_exceptions.cpython-313.pyc,,
websocket/__pycache__/_handshake.cpython-313.pyc,,
websocket/__pycache__/_http.cpython-313.pyc,,
websocket/__pycache__/_logging.cpython-313.pyc,,
websocket/__pycache__/_socket.cpython-313.pyc,,
websocket/__pycache__/_ssl_compat.cpython-313.pyc,,
websocket/__pycache__/_url.cpython-313.pyc,,
websocket/__pycache__/_utils.cpython-313.pyc,,
websocket/__pycache__/_wsdump.cpython-313.pyc,,
websocket/_abnf.py,sha256=WesUJSSGSRpzuTp0VeK12O4SYYVMN6CyN6bqXS4lk2w,14385
websocket/_app.py,sha256=xCAlaM2FfsPLsaEsBGXhdg4olHDEEzif6llSWefHcm8,24176
websocket/_cookiejar.py,sha256=893SWoHmk_JysiXj8lkyLy95co5zvuC62XGMrvmgI7E,2399
websocket/_core.py,sha256=P-lYcwk-LKJUKDqBleJsmRSIJjX2v_o4FongdJYbhn8,21080
websocket/_exceptions.py,sha256=r7lGaC8Y2brBnaK_YJJRDdYY6UCGWxOXoQsMcgFFeJ4,2178
websocket/_handshake.py,sha256=h_88S6vhStOZBj5zMGJtIKFV1RVMVuEskLybjJCnaj4,6578
websocket/_http.py,sha256=33GsroWgLhOsE8pMC2Xka-RjonPuUypjeFRABFAtQJo,12818
websocket/_logging.py,sha256=DHRUl4sEaSkolvMo4A6upn7UIYF0kJT5NlAL0vWCHRI,2228
websocket/_socket.py,sha256=NpsUBO1ihnC-xPA0U2o1-hMXK8eiplNcU9R2VZvZ3qU,5198
websocket/_ssl_compat.py,sha256=SRPtw1rT3LPSl9q70mCi5hW9h2xS-nIfdcXbjyGi8sE,1188
websocket/_url.py,sha256=kbEdbdZ-BMMoYQ3sMfcp9QEY1IYrDppIKCpIIHdGVMc,5251
websocket/_utils.py,sha256=R36FnFTxYVJyKlh-yEaapRxpoK8Xwn9JFXCy2q2haY0,6961
websocket/_wsdump.py,sha256=kV82LWLlD6d3vzOKOVAEqkfoCA_Qkpd0hc9WN2Tq2kM,7010
websocket/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
websocket/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
websocket/tests/__pycache__/__init__.cpython-313.pyc,,
websocket/tests/__pycache__/echo-server.cpython-313.pyc,,
websocket/tests/__pycache__/test_abnf.cpython-313.pyc,,
websocket/tests/__pycache__/test_app.cpython-313.pyc,,
websocket/tests/__pycache__/test_cookiejar.cpython-313.pyc,,
websocket/tests/__pycache__/test_http.cpython-313.pyc,,
websocket/tests/__pycache__/test_url.cpython-313.pyc,,
websocket/tests/__pycache__/test_websocket.cpython-313.pyc,,
websocket/tests/data/header01.txt,sha256=eR9UDpnf7mREys9MttKytzB5OXA5IwOGWJZKmaF4II8,163
websocket/tests/data/header02.txt,sha256=1HzQGIMG0OGwfnboRkUqwbTEg2nTevOX2Waj0gQARaw,161
websocket/tests/data/header03.txt,sha256=l_soTbfEWjZTLC5Ydx2U8uj8NJ30IwAc8yo5IUG5fyQ,216
websocket/tests/echo-server.py,sha256=yYwKXimgqo6gHFjGgqhkADb6fRncSrF-OewX6UinZVg,482
websocket/tests/test_abnf.py,sha256=fGZ335DReScT4zSNayl5H8z7MxzJ9NXbiSvt97SJGDI,4629
websocket/tests/test_app.py,sha256=0YoTjRjcZ2MqG3Hd8-4rfvkPkNA9BUAt1UODkjXu3Y0,12364
websocket/tests/test_cookiejar.py,sha256=FNm9Hjxu0YBwA8GLRi1GSrAp8jkKzdND6Icm7iIIu_Y,4395
websocket/tests/test_http.py,sha256=VLqGlXOovB6DGZDnq25c7cOjAWWTJAhhjeKSFYXnLnc,12461
websocket/tests/test_url.py,sha256=5oONcPf4rU8KSQjDYjNevcnUpOnqUNFmontSiXB5Qd4,17718
websocket/tests/test_websocket.py,sha256=F5XtOwa_v2JHUE-xOpCWdhUgUYfNbHGErHJKQ0bEsTI,18390
websocket_client-1.8.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
websocket_client-1.8.0.dist-info/LICENSE,sha256=RT5qaUJ-2f-SoD7y17Ie8dtB_fVtYjB6SbqFBZ96DGI,11339
websocket_client-1.8.0.dist-info/METADATA,sha256=mUuXo30suA6pEGGHkoT30gxksNLloIXGTTH1JPE5zjc,7962
websocket_client-1.8.0.dist-info/RECORD,,
websocket_client-1.8.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
websocket_client-1.8.0.dist-info/entry_points.txt,sha256=IoCGCuANLuLxE3m2QXEd2Ip57qScBjf7RfQnkjn6DNE,50
websocket_client-1.8.0.dist-info/top_level.txt,sha256=8m_tTpcUlzWGl8v-pj5Wi7XhAFaN1_bLKRHQKCyz5_I,10

View File

@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.43.0)
Root-Is-Purelib: true
Tag: py3-none-any

View File

@ -0,0 +1,2 @@
[console_scripts]
wsdump = websocket._wsdump:main

View File

@ -0,0 +1 @@
websocket