aboutsummaryrefslogtreecommitdiff
path: root/tools/get_p2_url.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/get_p2_url.py')
-rw-r--r--tools/get_p2_url.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/tools/get_p2_url.py b/tools/get_p2_url.py
index 23b2d0b..f2162cd 100644
--- a/tools/get_p2_url.py
+++ b/tools/get_p2_url.py
@@ -2,6 +2,7 @@
import requests
import re
from bs4 import BeautifulSoup
+import sys
import lzma
from urllib.parse import urlparse
from contextlib import suppress
@@ -37,12 +38,25 @@ if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--update-site', default='http://sw-center.st.com/stm32cubeide/updatesite1')
parser.add_argument('artifact_id')
+ parser.add_argument('-v', '--version', action='store_true')
+ parser.add_argument('--write-version', type=argparse.FileType('w'))
args = parser.parse_args()
+ if args.write_version:
+ args.version = True
+ version_file = args.write_version
+ else:
+ version_file = sys.stdout
+
+ if args.version:
+ print(f'[Artifact {args.artifact_id}]', file=version_file)
+
res = fucked_up_get(f'{args.update_site}/compositeContent.xml')
res.raise_for_status()
soup = BeautifulSoup(res.content, features='html.parser')
latest_version = soup.find('repository')['version']
+ if args.version:
+ print('IDE version:', latest_version, file=version_file)
res = fucked_up_get(f'{args.update_site}/{latest_version}/artifacts.xml.xz')
res.raise_for_status()
@@ -50,9 +64,12 @@ if __name__ == '__main__':
artifact = soup.find('artifact', recursive=True, id=args.artifact_id)
art_id, art_ver, art_cls = artifact['id'], artifact['version'], artifact['classifier']
+ if args.version:
+ print('Artifact version:', artifact['version'], file=version_file)
filename = f'{art_id}_{art_ver}.jar'
-
url = f'{args.update_site}/{latest_version}/plugins/{filename}'
- print(f'{url}')
+
+ if not args.version or args.write_version:
+ print(f'{url}')