-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
21d22e6
commit 34e2af7
Showing
3 changed files
with
54 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.7.8-beta2 | ||
1.7.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,12 @@ | |
@email: [email protected] | ||
""" | ||
|
||
import re | ||
import sys | ||
from os.path import dirname, join | ||
|
||
import requests | ||
|
||
from feapder.commands import create_builder | ||
from feapder.commands import shell | ||
from feapder.commands import zip | ||
|
@@ -32,12 +35,18 @@ | |
Available commands: | ||
""" | ||
|
||
NEW_VERSION_TIP = """ | ||
────────────────────────────────────────────────────── | ||
New version available \033[31m{version}\033[0m → \033[32m{new_version}\033[0m | ||
Run \033[33mpip install --upgrade feapder\033[0m to update! | ||
""" | ||
|
||
def _print_commands(): | ||
with open(join(dirname(dirname(__file__)), "VERSION"), "rb") as f: | ||
version = f.read().decode("ascii").strip() | ||
with open(join(dirname(dirname(__file__)), "VERSION"), "rb") as f: | ||
VERSION = f.read().decode("ascii").strip() | ||
|
||
print(HELP.rstrip().format(version=version)) | ||
|
||
def _print_commands(): | ||
print(HELP.rstrip().format(version=VERSION)) | ||
cmds = { | ||
"create": "create project、spider、item and so on", | ||
"shell": "debug response", | ||
|
@@ -49,6 +58,21 @@ def _print_commands(): | |
print('\nUse "feapder <command> -h" to see more info about a command') | ||
|
||
|
||
def check_new_version(): | ||
try: | ||
url = "https://pypi.org/simple/feapder/" | ||
resp = requests.get(url, timeout=3) | ||
html = resp.text | ||
|
||
last_version = re.findall(r"feapder-([\d.]*?).tar.gz", html)[-1] | ||
now_stable_version = re.sub("-beta.*", "", VERSION) | ||
|
||
if now_stable_version < last_version: | ||
return f"feapder=={last_version}" | ||
except: | ||
pass | ||
|
||
|
||
def execute(): | ||
try: | ||
args = sys.argv | ||
|
@@ -68,6 +92,12 @@ def execute(): | |
except KeyboardInterrupt: | ||
pass | ||
|
||
new_version = check_new_version() | ||
if new_version: | ||
version = f"feapder=={VERSION.replace('-beta', 'b')}" | ||
tip = NEW_VERSION_TIP.format(version=version, new_version=new_version) | ||
print(tip) | ||
|
||
|
||
if __name__ == "__main__": | ||
execute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters