Skip to content

Commit

Permalink
Fix packaging and make Python3-compliant (removing unused websockets)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalex committed Dec 17, 2018
1 parent da157ef commit 1a39b92
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 37 deletions.
6 changes: 6 additions & 0 deletions MANIFEST.in
@@ -0,0 +1,6 @@
include requirements.txt
include LICENSE
include README.md

global-exclude *.pyc
global-exclude __pycache__
33 changes: 0 additions & 33 deletions notion/monitor.py
Expand Up @@ -192,36 +192,3 @@ def poll_async(self):
def poll_forever(self):
while True:
self.poll()

def poll_forever_websocket(self):
"""
An alternative implementation of the watch behavior using websockets. Doesn't seem to be particularly faster.
Note: requires installation of the "asyncio" and "websockets" packages.
"""

import asyncio
import websockets

async def hello():

while True:
try:

self.initialize()

headers = [("Cookie", "AWSALB={};".format(self.client.session.cookies.get("AWSALB")))]

url = "wss://msgstore.www.notion.so/primus/?sessionId={}&EIO=3&transport=websocket&sid={}".format(self.session_id, self.sid)

async with websockets.connect(url, extra_headers=headers) as websocket:
await websocket.send("2probe")
await websocket.recv()
await websocket.send("5")
while True:
event = json.loads(re.match("\d+(.*)", await websocket.recv()).groups()[0])
self._refresh_updated_records([event])

except websockets.ConnectionClosed:
pass

asyncio.get_event_loop().run_until_complete(hello())
2 changes: 1 addition & 1 deletion notion/settings.py
Expand Up @@ -5,7 +5,7 @@
API_BASE_URL = BASE_URL + "api/v3/"
SIGNED_URL_PREFIX = "https://www.notion.so/signed/"
S3_URL_PREFIX = "https://s3-us-west-2.amazonaws.com/secure.notion-static.com/"
DATA_DIR = str(Path.home().joinpath(".notion-py"))
DATA_DIR = str(Path(os.path.expanduser("~")).joinpath(".notion-py"))
CACHE_DIR = str(Path(DATA_DIR).joinpath("cache"))
LOG_FILE = str(Path(DATA_DIR).joinpath("notion.log"))

Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Expand Up @@ -3,6 +3,4 @@ commonmark
bs4
tzlocal
python-slugify
# asyncio
# websockets
dictdiffer
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -13,15 +13,17 @@

setuptools.setup(
name="notion",
version="0.0.9",
version="0.0.15",
author="Jamie Alexandre",
author_email="jamalex+python@gmail.com",
description="Unofficial Python API client for Notion.so",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/jamalex/notion-py",
install_requires=install_requires,
include_package_data=True,
packages=setuptools.find_packages(),
python_requires='>=3.4',
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit 1a39b92

Please sign in to comment.