提交 946e2500 编写于 作者: H Hou Tianze

1.6.7: Handle update check network exceptions

上级 821a46d2
{
"files.exclude": {
"**/.classpath": true,
"**/.project": true,
"**/.settings": true,
"**/.factorypath": true
}
}
\ No newline at end of file
### Version History:
- 1.6.7: Handle update check network exceptions
- 1.6.6: Let it cry when dies, so we can have some trace
- 1.6.5: Fix `KeyError: u'md5'` in remote directory walking
- 1.6.4: Fix `--move` argument causing exception
......
Version History:
~~~~~~~~~~~~~~~~
- 1.6.7: Handle update check network exceptions
- 1.6.6: Let it cry when dies, so we can have some trace
- 1.6.5: Fix ``KeyError: u'md5'`` in remote directory walking
......
......@@ -478,33 +478,38 @@ class ByPy(object):
check_update = True
if check_update:
r = requests.get('https://raw.githubusercontent.com/houtianze/bypy/master/update/update.json')
if r.status_code == 200:
try:
j = r.json()
min_ver_key = 'minimumRequiredVersion'
if min_ver_key in j:
minver = j[min_ver_key]
if comp_semver(const.__version__, minver) < 0:
perr("Your current version ({}) is too low, "
"minimum required version is {}.\n"
"Please run 'pip install -U bypy' to update and try again.".format(
const.__version__, minver))
sys.exit(const.EUpdateNeeded)
else:
self.__setting[const.SettingKey_LastUpdateCheckTime] = nowsec
self.savesetting()
recommended_ver_key = 'recommendedVersion'
if recommended_ver_key in j:
recver = j[recommended_ver_key]
if comp_semver(const.__version__, recver) < 0:
pr("Your current version ({}) is low, "
"It's recommended to update to version {}.\n"
"Please run 'pip install -U bypy' to update.".format(
const.__version__, recver))
except ValueError:
self.pd("Invalid response for update check, skipping.")
try:
r = requests.get('https://raw.githubusercontent.com/houtianze/bypy/master/update/update.json')
if r.status_code == 200:
try:
j = r.json()
min_ver_key = 'minimumRequiredVersion'
if min_ver_key in j:
minver = j[min_ver_key]
if comp_semver(const.__version__, minver) < 0:
perr("Your current version ({}) is too low, "
"minimum required version is {}.\n"
"Please run 'pip install -U bypy' to update and try again.".format(
const.__version__, minver))
sys.exit(const.EUpdateNeeded)
else:
self.__setting[const.SettingKey_LastUpdateCheckTime] = nowsec
self.savesetting()
recommended_ver_key = 'recommendedVersion'
if recommended_ver_key in j:
recver = j[recommended_ver_key]
if comp_semver(const.__version__, recver) < 0:
pr("Your current version ({}) is low, "
"It's recommended to update to version {}.\n"
"Please run 'pip install -U bypy' to update.".format(
const.__version__, recver))
except ValueError:
self.pd("Invalid response for update check, skipping.")
else:
self.pd("HTTP Status {} while checking update, skipping.".format(r.status_code))
except:
self.pd("Error occurred while checking update, skipping.")
def pv(self, msg, **kwargs):
if self.verbose:
......
......@@ -12,7 +12,7 @@ import os
# https://packaging.python.org/single_source_version/
__title__ = 'bypy'
__version__ = '1.6.6'
__version__ = '1.6.7'
__author__ = 'Hou Tianze'
__license__ = 'MIT'
__desc__ = 'Python client for Baidu Yun (Personal Cloud Storage) 百度云/百度网盘 Python 客户端'
......
{
"access_token": "21.8a8596bd8a1262ec8b53510c71a869e1.2592000.1560759917.2844184044-1572671",
"expires_in": 2592000,
"refresh_token": "22.2b73561d88b05d31047161b3c6f2b13b.315360000.1873527917.2844184044-1572671",
"scope": "basic netdisk",
"session_key": "9mnRfHOMLndTHnFeCxk30dvI/tj1klRW9XKfF9Cmd/MiY+2aZZGvkrsYLPYSa+buXmrwyBvIhlqLBFvER6l9f9CPGJYTcJVPIA==",
"session_secret": "cd89ab0006614803b164b69440c7457a"
"access_token": "21.e31488969e0e452f8b1ab9685d349782.2592000.1584553337.2844184044-1572671",
"expires_in": 2592000,
"refresh_token": "22.dc5ae4fe5d0e34af31d45f003f5fc918.315360000.1897321337.2844184044-1572671",
"scope": "basic netdisk",
"session_key": "",
"session_secret": ""
}
\ No newline at end of file
{
"lastUpdateCheck": 1558167911,
"lastUpdateCheck": 1581961333,
"overwriteRemoteTempDir": true
}
\ No newline at end of file
#!/bin/sh
# need to run the following commands before running this release script
# (This is for macOS, and for python virtualenv is recommended)
# --------
# brew install pandoc
# pip3 install pandoc pypandoc twine pyflakes
#set -o errexit
#set -x
trap "echo '=== Release script interrupted ==='; exit -1" SIGINT
py2venv=${py2venv-"$HOME/Documents/t/pyvenv/2.7.16"}
py3venv=${py3venv-"$HOME/Documents/t/pyvenv/3.7.3"}
pycmd=python
actual=0
build=0
......@@ -15,18 +20,6 @@ upload=0
testit=0
tagit=0
createvenv() {
if [ ! -d "$py2venv" ]
then
python2 -m virtualenv "$py2venv"
fi
if [ ! -d "$py3venv" ]
then
python3 -m virtualenv "$py3venv"
fi
}
parsearg() {
while getopts "abigtu" opt; do
case "$opt" in
......@@ -52,14 +45,15 @@ parsearg() {
done
}
doctest() {
eval $1 -m pyflakes bypy
eval $1 setup.py test
#eval $1 -m doctest -v bypy.py
runtest() {
eval $pycmd -m pyflakes bypy
eval $pycmd setup.py test
#eval $pycmd -m doctest -v bypy.py
eval $pycmd -m bypy -V
eval $pycmd -m bypy --config-dir bypy/test/configdir quota
}
installtest() {
. "$1"
# due to requests not in testpypi
if [ $actual -eq 0 ]
then
......@@ -70,16 +64,11 @@ installtest() {
pip uninstall -y bypy
pip install -U bypy $indexopt
bypy -V
bypy quota
deactivate
bypy --config-dir bypy/test/configdir quota
}
main() {
#if [ ! -f 'HISTORY.rst' ]; then
# python genrst.py
#fi
python genrst.py
createvenv
eval $pycmd genrst.py
parsearg $*
if [ "$actual" -eq 0 ]
......@@ -103,14 +92,13 @@ main() {
if [ "$testit" -eq 1 ]
then
doctest python2
doctest python3
runtest
fi
if [ "$build" -eq 1 ]
then
rm -Rf dist/*
python setup.py bdist_wheel #sdist
eval $pycmd setup.py bdist_wheel #sdist
fi
uploadcmd="twine upload dist/* $repoopt"
......@@ -123,8 +111,7 @@ main() {
if [ "$install" -eq 1 ]
then
installtest "$py2venv/bin/activate"
installtest "$py3venv/bin/activate"
installtest
fi
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册