Compare commits
4 commits
d8d008a3a9
...
868ee28677
Author | SHA1 | Date | |
---|---|---|---|
868ee28677 | |||
30f392c18c | |||
268c522c65 | |||
71ecb70e9a |
2 changed files with 10 additions and 4 deletions
|
@ -25,7 +25,7 @@ repos:
|
||||||
- id: black
|
- id: black
|
||||||
args: ['--target-version', 'py37', '--line-length', '100']
|
args: ['--target-version', 'py37', '--line-length', '100']
|
||||||
- repo: https://github.com/PyCQA/isort
|
- repo: https://github.com/PyCQA/isort
|
||||||
rev: 5.11.4
|
rev: 5.12.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: isort
|
- id: isort
|
||||||
args: ['--profile', 'black', '--line-length', '100']
|
args: ['--profile', 'black', '--line-length', '100']
|
||||||
|
|
|
@ -42,7 +42,10 @@ parser.add_argument(
|
||||||
"--rc",
|
"--rc",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
dest="include_rc",
|
dest="include_rc",
|
||||||
help=("Allow release candidate (default: only stable release are " "considered)"),
|
help="Allow release candidate (default: only stable release are considered)",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-t", "--timeout", type=int, help="Specify timeout for HTTP requests (default: 20)", default=20
|
||||||
)
|
)
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
@ -74,10 +77,13 @@ if not CURRENT:
|
||||||
print(EXCEPTION if EXCEPTION else "")
|
print(EXCEPTION if EXCEPTION else "")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
|
CURRENT = CURRENT.replace("+", "-")
|
||||||
|
logging.debug("Cleaned current version: %s", CURRENT)
|
||||||
|
|
||||||
LATEST = None
|
LATEST = None
|
||||||
try:
|
try:
|
||||||
logging.debug("Get releases RSS feed from %s...", options.url)
|
logging.debug("Get releases RSS feed from %s...", options.url)
|
||||||
r = requests.get(options.url)
|
r = requests.get(options.url, timeout=options.timeout)
|
||||||
logging.debug("Data retreive:\n%s", r.text)
|
logging.debug("Data retreive:\n%s", r.text)
|
||||||
data = xmltodict.parse(r.text)
|
data = xmltodict.parse(r.text)
|
||||||
for item in data["rss"]["channel"]["item"]:
|
for item in data["rss"]["channel"]["item"]:
|
||||||
|
@ -92,7 +98,7 @@ except Exception: # pylint: disable=broad-except
|
||||||
logging.debug("Latest version: %s", LATEST)
|
logging.debug("Latest version: %s", LATEST)
|
||||||
|
|
||||||
if not LATEST:
|
if not LATEST:
|
||||||
print("UNKNOWN - Fail to retreive latest Forgejo release from the project " "RSS feed")
|
print("UNKNOWN - Fail to retreive latest Forgejo release from the project RSS feed")
|
||||||
print(f"Current version: {CURRENT}")
|
print(f"Current version: {CURRENT}")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue