Compare commits

..

4 commits

Author SHA1 Message Date
868ee28677 Clean detected current version: replace + sign by -
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
2023-07-26 00:38:40 +02:00
30f392c18c Add -t/--timeout parameter 2023-07-26 00:38:21 +02:00
268c522c65 Code cleaning 2023-07-26 00:37:55 +02:00
71ecb70e9a pre-commit: upgrade isort for python 11 compatibility 2023-07-26 00:36:19 +02:00
2 changed files with 9 additions and 6 deletions

View file

@ -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']

View file

@ -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,13 +77,13 @@ if not CURRENT:
print(EXCEPTION if EXCEPTION else "") print(EXCEPTION if EXCEPTION else "")
sys.exit(3) sys.exit(3)
CURRENT = CURRENT.replace('+', '-') CURRENT = CURRENT.replace("+", "-")
logging.debug('Cleaned current version: %s', CURRENT) 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"]:
@ -95,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)