!pip install Notion
import os
from notion.client import NotionClient
# Obtain the `token_v2` value by inspecting your browser cookies on a logged-in (non-guest) session on Notion.so
client = NotionClient(token_v2=os.environ['key'])
# If the token can be associated to multiple emails, we choose the correct one
client.set_user_by_email(os.environ['email '])
Collecting Notion
Downloading notion-0.0.28-py3-none-any.whl (43 kB)
|████████████████████████████████| 43 kB 2.1 MB/s
Collecting tzlocal
Downloading tzlocal-4.1-py3-none-any.whl (19 kB)
Requirement already satisfied: python-slugify in /shared-libs/python3.7/py/lib/python3.7/site-packages (from Notion) (5.0.2)
Collecting cached-property
Downloading cached_property-1.5.2-py2.py3-none-any.whl (7.6 kB)
Collecting dictdiffer
Downloading dictdiffer-0.9.0-py2.py3-none-any.whl (16 kB)
Collecting bs4
Downloading bs4-0.0.1.tar.gz (1.1 kB)
Collecting commonmark
Downloading commonmark-0.9.1-py2.py3-none-any.whl (51 kB)
|████████████████████████████████| 51 kB 8.0 MB/s
Requirement already satisfied: requests in /shared-libs/python3.7/py/lib/python3.7/site-packages (from Notion) (2.26.0)
Collecting beautifulsoup4
Downloading beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 10.9 MB/s
Collecting soupsieve>1.2
Downloading soupsieve-2.2.1-py3-none-any.whl (33 kB)
Requirement already satisfied: text-unidecode>=1.3 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from python-slugify->Notion) (1.3)
Requirement already satisfied: idna<4,>=2.5 in /shared-libs/python3.7/py-core/lib/python3.7/site-packages (from requests->Notion) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests->Notion) (1.26.7)
Requirement already satisfied: charset-normalizer~=2.0.0 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests->Notion) (2.0.7)
Requirement already satisfied: certifi>=2017.4.17 in /shared-libs/python3.7/py/lib/python3.7/site-packages (from requests->Notion) (2021.10.8)
Collecting backports.zoneinfo
Downloading backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl (70 kB)
|████████████████████████████████| 70 kB 15.2 MB/s
Collecting pytz-deprecation-shim
Downloading pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB)
Collecting tzdata
Downloading tzdata-2021.5-py2.py3-none-any.whl (339 kB)
|████████████████████████████████| 339 kB 43.8 MB/s
Building wheels for collected packages: bs4
Building wheel for bs4 (setup.py) ... done
Created wheel for bs4: filename=bs4-0.0.1-py3-none-any.whl size=1271 sha256=2da3a6dbb026c88b68b1a0e9f9d80cd2145b26724960ecf636322d3bd0056e14
Stored in directory: /root/.cache/pip/wheels/0a/9e/ba/20e5bbc1afef3a491f0b3bb74d508f99403aabe76eda2167ca
Successfully built bs4
Installing collected packages: tzdata, soupsieve, backports.zoneinfo, pytz-deprecation-shim, beautifulsoup4, tzlocal, dictdiffer, commonmark, cached-property, bs4, Notion
Successfully installed Notion-0.0.28 backports.zoneinfo-0.2.1 beautifulsoup4-4.10.0 bs4-0.0.1 cached-property-1.5.2 commonmark-0.9.1 dictdiffer-0.9.0 pytz-deprecation-shim-0.1.0.post0 soupsieve-2.2.1 tzdata-2021.5 tzlocal-4.1
WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
You should consider upgrading via the '/root/venv/bin/python -m pip install --upgrade pip' command.
Execution error
KeyError: 'secret_4CYR0CsKTaHg4ihsSLkggxv16LGwB1VCQLCOf18mnoB'
database_url = "https://www.notion.so/deepnote/14e4cb5528404d0e8b57cfe687e9355f?v=090f36ef8be94d3988beed2dc550a0d6"
def close_issues_with_pr(pr_link):
collection = client.get_block(database_url).collection
for row in collection.get_rows():
if row.pr == pr_link:
row.status = 'Done'
from github_webhook import Webhook
from flask import Flask
app = Flask(__name__) # Standard Flask app
webhook = Webhook(app, secret="U7L56ddCXr") # Defines '/postreceive' endpoint, with a secret (see below)
@webhook.hook(event_type="pull_request") # Defines a handler for the 'pull_request' event
def on_pull_request(data):
print("Got push with: {0}".format(data))
if data['action'] == 'closed':
# The PR has been closed or merged, so set the corresponding Notion ticket to Done
number = data['number']
print(f"Closed PR #{number}")
close_issues_with_pr(data['pull_request']['html_url'])
Execution error
ModuleNotFoundError: No module named 'github_webhook'
app.run(host="0.0.0.0", port=8080)
* Serving Flask app "__main__" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)