Skip to content

Rename module mod_pywebsocket to pywebsocket3 #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ include COPYING
include MANIFEST.in
include README
recursive-include example *.py
recursive-include mod_pywebsocket *.py
recursive-include pywebsocket3 *.py
recursive-include test *.py
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@

# pywebsocket3 #

The pywebsocket project aims to provide a [WebSocket](https://tools.ietf.org/html/rfc6455) standalone server.
The pywebsocket3 project aims to provide a [WebSocket](https://tools.ietf.org/html/rfc6455) standalone server.

pywebsocket is intended for **testing** or **experimental** purposes.

Run this to read the general document:
```
$ pydoc mod_pywebsocket

```bash
pydoc pywebsocket3
```

Please see [Wiki](https://github.com/GoogleChromeLabs/pywebsocket3/wiki) for more details.

# INSTALL #

To install this package to the system, run this:
```
$ python setup.py build
$ sudo python setup.py install

```bash
python setup.py build
sudo python setup.py install
```

To install this package as a normal user, run this instead:

```bash
python setup.py build
python setup.py install --user
```
$ python setup.py build
$ python setup.py install --user
```

# LAUNCH #

To use pywebsocket as standalone server, run this to read the document:

```bash
pydoc pywebsocket3.standalone
```
$ pydoc mod_pywebsocket.standalone
```

# Disclaimer #

This is not an officially supported Google product
3 changes: 2 additions & 1 deletion example/abort_handshake_wsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import absolute_import
from mod_pywebsocket import handshake

from pywebsocket3 import handshake


def web_socket_do_extra_handshake(request):
Expand Down
3 changes: 2 additions & 1 deletion example/abort_wsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import absolute_import
from mod_pywebsocket import handshake

from pywebsocket3 import handshake


def web_socket_do_extra_handshake(request):
Expand Down
2 changes: 2 additions & 0 deletions example/bench_wsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
"""

from __future__ import absolute_import

import time

from six.moves import range


Expand Down
2 changes: 2 additions & 0 deletions example/benchmark_helper_wsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Handler for benchmark.html."""

from __future__ import absolute_import

import six


Expand Down
4 changes: 1 addition & 3 deletions example/close_wsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import absolute_import
import struct

from mod_pywebsocket import common
from mod_pywebsocket import stream
from pywebsocket3 import common


def web_socket_do_extra_handshake(request):
Expand Down
1 change: 1 addition & 0 deletions example/cookie_wsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import absolute_import

from six.moves import urllib


Expand Down
30 changes: 15 additions & 15 deletions example/echo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""Simple WebSocket client named echo_client just because of historical reason.

mod_pywebsocket directory must be in PYTHONPATH.
pywebsocket3 directory must be in PYTHONPATH.

Example Usage:

# server setup
% cd $pywebsocket
% PYTHONPATH=$cwd/src python ./mod_pywebsocket/standalone.py -p 8880 \
% cd $pywebsocket3
% PYTHONPATH=$cwd/src python ./pywebsocket3/standalone.py -p 8880 \
-d $cwd/src/example

# run client
Expand All @@ -47,27 +47,27 @@

from __future__ import absolute_import
from __future__ import print_function

import argparse
import base64
import codecs
from hashlib import sha1
import logging
import argparse
import os
import random
import re
import six
import socket
import ssl
import struct
import sys
from hashlib import sha1

import six

from mod_pywebsocket import common
from mod_pywebsocket.extensions import PerMessageDeflateExtensionProcessor
from mod_pywebsocket.extensions import _PerMessageDeflateFramer
from mod_pywebsocket.extensions import _parse_window_bits
from mod_pywebsocket.stream import Stream
from mod_pywebsocket.stream import StreamOptions
from mod_pywebsocket import util
from pywebsocket3 import common, util
from pywebsocket3.extensions import (
PerMessageDeflateExtensionProcessor,
_PerMessageDeflateFramer,
_parse_window_bits,
)
from pywebsocket3.stream import Stream, StreamOptions

_TIMEOUT_SEC = 10
_UNDEFINED_PORT = -1
Expand Down
3 changes: 2 additions & 1 deletion example/internal_error_wsh.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import absolute_import
from mod_pywebsocket import msgutil

from pywebsocket3 import msgutil


def web_socket_do_extra_handshake(request):
Expand Down
6 changes: 3 additions & 3 deletions mod_pywebsocket/__init__.py → pywebsocket3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
""" A Standalone WebSocket Server for testing purposes

mod_pywebsocket is an API that provides WebSocket functionalities with
pywebsocket3 is an API that provides WebSocket functionalities with
a standalone WebSocket server. It is intended for testing or
experimental purposes.

Expand All @@ -37,7 +37,7 @@
1. Follow standalone server documentation to start running the
standalone server. It can be read by running the following command:

$ pydoc mod_pywebsocket.standalone
$ pydoc pywebsocket3.standalone

2. Once the standalone server is launched verify it by accessing
http://localhost[:port]/console.html. Include the port number when
Expand Down Expand Up @@ -96,7 +96,7 @@

web_socket_transfer_data is called after the handshake completed
successfully. A handler can receive/send messages from/to the client
using request. mod_pywebsocket.msgutil module provides utilities
using request. pywebsocket3.msgutil module provides utilities
for data transfer.

You can receive a message by the following statement.
Expand Down
4 changes: 3 additions & 1 deletion mod_pywebsocket/common.py → pywebsocket3/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
"""

from __future__ import absolute_import
from mod_pywebsocket import http_header_util

from pywebsocket3 import http_header_util


# Additional log level definitions.
LOGLEVEL_FINE = 9
Expand Down
14 changes: 8 additions & 6 deletions mod_pywebsocket/dispatch.py → pywebsocket3/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@
"""

from __future__ import absolute_import

import io
import logging
import os
import re
import traceback

from mod_pywebsocket import common
from mod_pywebsocket import handshake
from mod_pywebsocket import msgutil
from mod_pywebsocket import stream
from mod_pywebsocket import util
from pywebsocket3 import (
common,
handshake,
msgutil,
stream,
util
)

_SOURCE_PATH_PATTERN = re.compile(r'(?i)_wsh\.py$')
_SOURCE_SUFFIX = '_wsh.py'
Expand Down
6 changes: 3 additions & 3 deletions mod_pywebsocket/extensions.py → pywebsocket3/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from __future__ import absolute_import
from mod_pywebsocket import common
from mod_pywebsocket import util
from mod_pywebsocket.http_header_util import quote_if_necessary

from pywebsocket3 import common, util
from pywebsocket3.http_header_util import quote_if_necessary

# The list of available server side extension processor classes.
_available_processors = {}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@
"""

from __future__ import absolute_import

import logging

from mod_pywebsocket import common
from mod_pywebsocket.handshake import hybi
from pywebsocket3 import common
from pywebsocket3.handshake import hybi
# Export AbortedByUserException, HandshakeException, and VersionException
# symbol from this module.
from mod_pywebsocket.handshake.base import AbortedByUserException
from mod_pywebsocket.handshake.base import HandshakeException
from mod_pywebsocket.handshake.base import VersionException
from pywebsocket3.handshake.base import (
AbortedByUserException,
HandshakeException,
VersionException
)


_LOGGER = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@

from __future__ import absolute_import

from mod_pywebsocket import common
from mod_pywebsocket import http_header_util
from mod_pywebsocket.extensions import get_extension_processor
from mod_pywebsocket.stream import StreamOptions
from mod_pywebsocket.stream import Stream
from mod_pywebsocket import util

from six.moves import map
from six.moves import range
from pywebsocket3 import common, http_header_util, util
from pywebsocket3.extensions import get_extension_processor
from pywebsocket3.stream import Stream, StreamOptions

from six.moves import map, range


# Defining aliases for values used frequently.
_VERSION_LATEST = common.VERSION_HYBI_LATEST
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@
"""

from __future__ import absolute_import

import base64
import re
from hashlib import sha1

from mod_pywebsocket import common
from mod_pywebsocket.handshake.base import get_mandatory_header
from mod_pywebsocket.handshake.base import HandshakeException
from mod_pywebsocket.handshake.base import parse_token_list
from mod_pywebsocket.handshake.base import validate_mandatory_header
from mod_pywebsocket.handshake.base import HandshakerBase
from mod_pywebsocket import util
from pywebsocket3 import common, util
from pywebsocket3.handshake.base import (
get_mandatory_header,
HandshakeException,
parse_token_list,
validate_mandatory_header,
HandshakerBase
)


# Used to validate the value in the Sec-WebSocket-Key header strictly. RFC 4648
# disallows non-zero padding, so the character right before == must be any of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
"""

from __future__ import absolute_import

import six.moves.urllib.parse


_SEPARATORS = '()<>@,;:\\"/[]?={} \t'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"""

from __future__ import absolute_import

import sys


Expand Down Expand Up @@ -61,7 +62,7 @@ def __init__(self, file_, max_memorized_lines=sys.maxsize):

def __getattribute__(self, name):
"""Return a file attribute.

Returns the value overridden by this class for some attributes,
and forwards the call to _file for the other attributes.
"""
Expand Down
14 changes: 9 additions & 5 deletions mod_pywebsocket/msgutil.py → pywebsocket3/msgutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@
"""

from __future__ import absolute_import
import six.moves.queue

import threading

import six.moves.queue

# Export Exception symbols from msgutil for backward compatibility
from mod_pywebsocket._stream_exceptions import ConnectionTerminatedException
from mod_pywebsocket._stream_exceptions import InvalidFrameException
from mod_pywebsocket._stream_exceptions import BadOperationException
from mod_pywebsocket._stream_exceptions import UnsupportedFrameException
from pywebsocket3._stream_exceptions import (
ConnectionTerminatedException,
InvalidFrameException,
BadOperationException,
UnsupportedFrameException
)


# An API for handler to send/receive WebSocket messages.
Expand Down
Loading