提交 ecc0a8f8 编写于 作者: H Hou Tianze

Make auth server list dynamic

上级 0419c7f7
### Version History:
- 1.6.9: Make auth server list dynamic
- 1.6.8: Fix 1000 items limit for downloading
- 1.6.7: Handle update check network exceptions
- 1.6.6: Let it cry when dies, so we can have some trace
......
Version History:
~~~~~~~~~~~~~~~~
- 1.6.9: Make auth server list dynamic
- 1.6.8: Fix 1000 items limit for downloading
- 1.6.7: Handle update check network exceptions
......
......@@ -981,6 +981,21 @@ Possible fixes:
def __repr_timeout(self):
return self.__timeout if self.__timeout else 'infinite'
def __update_auth_server_list(self):
try:
r = requests.get('https://raw.githubusercontent.com/houtianze/bypy/master/update/auth.json')
if r.status_code == 200:
try:
j = r.json()
const.AuthServerList = j['AuthServerList']
const.RefreshServerList = j['RefreshServerList']
except ValueError:
self.pd("Invalid response for auth servers update, skipping.")
else:
self.pd("HTTP Status {} while updating auth servers, skipping.".format(r.status_code))
except:
self.pd("Error occurred while updating auth servers, skipping.")
def __server_auth(self):
params = {
'client_id' : self.__apikey,
......@@ -1005,6 +1020,8 @@ Possible fixes:
savedperr = perr
if not self.debug:
perr = nop
self.__update_auth_server_list()
for auth in const.AuthServerList:
(url, retry, msg) = auth
pr(msg)
......@@ -1083,6 +1100,7 @@ Possible fixes:
savedperr = perr
if not self.debug:
perr = nop
self.__update_auth_server_list()
for refresh in const.RefreshServerList:
(url, retry, msg) = refresh
pr(msg)
......
......@@ -12,7 +12,7 @@ import os
# https://packaging.python.org/single_source_version/
__title__ = 'bypy'
__version__ = '1.6.8'
__version__ = '1.6.9'
__author__ = 'Hou Tianze'
__license__ = 'MIT'
__desc__ = 'Python client for Baidu Yun (Personal Cloud Storage) 百度云/百度网盘 Python 客户端'
......@@ -180,19 +180,19 @@ VercelRedirectUrl = VercelUrl + '/auth'
VercelRefreshUrl = VercelUrl + '/refresh'
AuthServerList = [
# url, retry?, message
(OpenShiftRedirectUrl, False, "Authorizing/refreshing with the OpenShift server ..."),
(HerokuRedirectUrl, False, "OpenShift server failed, authorizing/refreshing with the Heroku server ..."),
(Heroku1RedirectUrl, False, "Heroku server failed, authorizing/refreshing with the Heroku1 server ..."),
(VercelRedirectUrl, False, "Heroku1 server failed, authorizing/refreshing with the Vercel server ..."),
(GaeRedirectUrl, False, "Vercel server failed. Last resort: authorizing/refreshing with the GAE server ..."),
#(OpenShiftRedirectUrl, False, "Authorizing/refreshing with the OpenShift server ..."),
(HerokuRedirectUrl, False, "Authorizing with the Heroku server ..."),
(Heroku1RedirectUrl, False, "Heroku server failed, authorizing with the Heroku1 server ..."),
(VercelRedirectUrl, False, "Heroku1 server failed, authorizing with the Vercel server ..."),
(GaeRedirectUrl, False, "Vercel server failed. Last resort: authorizing with the GAE server ..."),
]
RefreshServerList = [
# url, retry?, message
(OpenShiftRefreshUrl, False, "Authorizing/refreshing with the OpenShift server ..."),
(HerokuRefreshUrl, False, "OpenShift server failed, authorizing/refreshing with the Heroku server ..."),
(Heroku1RefreshUrl, False, "Heroku server failed, authorizing/refreshing with the Heroku1 server ..."),
(VercelRefreshUrl, False, "Heroku1 server failed, authorizing/refreshing with the Vercel server ..."),
(GaeRefreshUrl, False, "Vercel server failed. Last resort: authorizing/refreshing with the GAE server ..."),
#(OpenShiftRefreshUrl, False, "Authorizing/refreshing with the OpenShift server ..."),
(HerokuRefreshUrl, False, "Refreshing with the Heroku server ..."),
(Heroku1RefreshUrl, False, "Heroku server failed, refreshing with the Heroku1 server ..."),
(VercelRefreshUrl, False, "Heroku1 server failed, refreshing with the Vercel server ..."),
(GaeRefreshUrl, False, "Vercel server failed. Last resort: refreshing with the GAE server ..."),
]
### public static properties
......
{
"lastUpdateCheck": 1589986897,
"lastUpdateCheck": 1590597166,
"overwriteRemoteTempDir": true
}
\ No newline at end of file
#!/bin/sh
# !!! RUN THIS SCRIPT UNDER VIRTUALENV !!!
# need to run the following commands before running this release script
# (This is for macOS, and for python virtualenv is recommended)
# --------
......@@ -11,6 +12,17 @@
trap "echo '=== Release script interrupted ==='; exit -1" SIGINT
check() {
command -v "$1" || { echo "'$1' doesn't exist, aborting."; exit -1; }
}
check git
check python
check pandoc
check pyflakes
check twine
check jq
pycmd=python
actual=0
......@@ -68,6 +80,7 @@ installtest() {
}
main() {
./syncver.sh
eval $pycmd genrst.py
parsearg $*
......
{
"comment": "Update info",
"recommendedVersion": "1.6.5",
"recommendedVersion": "1.6.9",
"minimumRequiredVersion": "1.6.0"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册