-
Notifications
You must be signed in to change notification settings - Fork 207
/
helpers.py
61 lines (48 loc) · 1.88 KB
/
helpers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
def get_download_url(model_details):
"""
Return the appropriate ubuntu models.com/download url for the model
:param model: a certifiedmodel resource
:param model_details: a certifiedmodeldetails resource
:return: appropriate ubuntu.com/download url
"""
platform_category = model_details.get("category", "").lower()
architecture = model_details.get("architecture", "").lower()
make = model_details.get("make", "").lower()
if model_details.get("level") == "Enabled":
# Enabled systems use oem images without download links.
return
if platform_category in ["desktop", "laptop"]:
return "https://ubuntu.com/download/desktop"
if "core" in platform_category:
if make == "xilinx":
return "https://ubuntu.com/download/amd"
return "https://ubuntu.com/download/iot/"
if "server" in platform_category:
# Server platforms have special landing pages based on architecture.
arch = ""
if "arm" in architecture:
arch = "arm"
elif "ppc" in architecture:
arch = "power"
elif "s390x" in architecture:
arch = "s390x"
else:
return "https://ubuntu.com/download/server/"
return f"https://ubuntu.com/download/server/{arch}"
return "https://ubuntu.com/download"
def _get_clean_in_filter(filter_in):
"""
Return a clean comma-separated values string from a list of values
This is required for the in filter query parameter in the API
:return: comma separated value of a list or the parameter itself
"""
if isinstance(filter_in, list):
return ",".join(filter_in)
return filter_in
def _get_category_pathname(form_factor):
if form_factor == "Ubuntu Core":
return "iot"
elif form_factor == "Server SoC":
return "socs"
else:
return form_factor.lower() + "s"