diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..2421e386c30d267a5ef5359de163b054857e89e7 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.exclude": { + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true + } +} \ No newline at end of file diff --git a/HISTORY.md b/HISTORY.md index 203c5b0382dcf1f0e781bab5da055544b5811375..657f27a452efbbb59fd85f9cc20053f4dbfe2972 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,6 @@ ### 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 diff --git a/HISTORY.rst b/HISTORY.rst index c7678f43a423fe59aaa999dfeae3aabf980e079c..9cba993fafcdd2787655954f6175b644b8c56d75 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,8 @@ 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 diff --git a/bypy/bypy.py b/bypy/bypy.py index 4389393a5cc90ea85b5bdce5a08366f32f91bff7..3808158f03767b1684fcdd0a15e93b2dfa10c217 100755 --- a/bypy/bypy.py +++ b/bypy/bypy.py @@ -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: diff --git a/bypy/const.py b/bypy/const.py index f213f8e76d6b957a9a154299e9d389c5769a94f4..c6629625dc8e4fdc44b0b75ece964dbd400bc0ba 100755 --- a/bypy/const.py +++ b/bypy/const.py @@ -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 客户端' diff --git a/bypy/test/configdir/bypy.json b/bypy/test/configdir/bypy.json index 6de73c7833c4d0b77d64bc3401842b208b3893d7..ed440ea066d896a3efd35352451b7fae63273b6d 100644 --- a/bypy/test/configdir/bypy.json +++ b/bypy/test/configdir/bypy.json @@ -1,8 +1,8 @@ { - "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 diff --git a/bypy/test/configdir/bypy.setting.json b/bypy/test/configdir/bypy.setting.json index 8dc86acfe44a82920c5d3a295370a0fdb282e0d6..c7014573cac94765f26e2593e92171a42aaa58dc 100644 --- a/bypy/test/configdir/bypy.setting.json +++ b/bypy/test/configdir/bypy.setting.json @@ -1,4 +1,4 @@ { - "lastUpdateCheck": 1558167911, + "lastUpdateCheck": 1581961333, "overwriteRemoteTempDir": true } \ No newline at end of file diff --git a/release.sh b/release.sh index 5bfe36a64d638c27e3823622155fc218fc1b891f..b50e68af5d8762fccc56a9a117e55122da5df8d9 100755 --- a/release.sh +++ b/release.sh @@ -1,12 +1,17 @@ #!/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 }