Skip to content

Commit 447775f

Browse files
avtikhonkyukhin
authored andcommitted
github-ci: port send-telegram-notify to python3
For now python3 is used as the default python on all OS and it is needed to enable it in send-telegram-notify action. Found issue: Traceback (most recent call last): File "<string>", line 3, in <module> AttributeError: module 'urllib' has no attribute 'quote_plus' In Python 3 quote_plus included into urllib.parse. Check documentaion [1]: Note The urllib module has been split into parts and renamed in Python 3 to urllib.request, urllib.parse, and urllib.error. Check the same issue [2]. This patch changes use of all needed routines just from 'urllib'. Closes tarantool/tarantool-qa#112 [1]: https://docs.python.org/2/library/urllib.html [2]: web2py/web2py#1822
1 parent d896411 commit 447775f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.github/actions/send-telegram-notify/action.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ runs:
55
steps:
66
# install 'requests' Python module
77
- run: |
8-
python -m pip install --upgrade pip ||:
9-
pip install requests ||:
8+
python3 -m pip install --upgrade pip ||:
9+
pip3 install requests ||:
1010
shell: bash
1111
# logout github environment
1212
- env:
@@ -72,8 +72,9 @@ runs:
7272
fi
7373
# Use MarkdownV2 while Markdown is legacy
7474
# https://core.telegram.org/bots/api#markdownv2-style
75-
python -c "import urllib, requests ; \\
76-
url = 'https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s&parse_mode=MarkdownV2&disable_web_page_preview=true' \\
77-
% ('$TELEGRAM_TOKEN', '$send_to', urllib.quote_plus('$msg')) ; \\
78-
_ = requests.post(url, timeout=10)"
75+
python3 -c "from urllib import request, parse ; \\
76+
url = 'https://api.telegram.org/bot%s/sendMessage' % ('$TELEGRAM_TOKEN') ; \\
77+
data = parse.urlencode({'chat_id' : '$send_to', 'parse_mode' : 'MarkdownV2', 'disable_web_page_preview' : 'true', 'text' : '$msg'}).encode('ascii') ; \\
78+
response = request.urlopen(url=url, data=data, timeout=10) ; \\
79+
print(response.read())"
7980
shell: bash

0 commit comments

Comments
 (0)