-
Notifications
You must be signed in to change notification settings - Fork 0
/
application_details.py
71 lines (56 loc) · 2.84 KB
/
application_details.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
62
63
64
65
66
67
68
69
70
'''
Copyright 2023 Flexera Software LLC
See LICENSE.TXT for full license text
SPDX-License-Identifier: MIT
Author : sgeary
Created On : Fri Aug 25 2023
File : application_details.py
'''
import logging
import common.api.project.get_project_information
logger = logging.getLogger(__name__)
#----------------------------------------------#
def determine_application_details(projectID, baseURL, authToken):
logger.debug("Entering determine_application_details.")
# Create a application name for the report if the custom fields are populated
# Default values
applicationName = None
applicationVersion = None
applicationPublisher = None
projectInformation = common.api.project.get_project_information.get_project_information_summary(baseURL, projectID, authToken)
# Project level custom fields added in 2022R1
if "customFields" in projectInformation:
customFields = projectInformation["customFields"]
# See if the custom project fields were propulated for this project
for customField in customFields:
# Is there the reqired custom field available?
if customField["fieldLabel"] == "Application Name":
if customField["value"] is not None and customField["value"] != "":
applicationName = customField["value"]
# Is the custom version field available?
if customField["fieldLabel"] == "Application Version":
if customField["value"] is not None and customField["value"] != "":
applicationVersion = customField["value"]
# Is the custom Publisher field available?
if customField["fieldLabel"] == "Application Publisher":
if customField["value"] is not None and customField["value"] != "":
applicationPublisher = customField["value"]
# Join the custom values to create the application name for the report artifacts
if applicationName is None:
applicationName = projectInformation["name"]
if applicationVersion is None:
applicationNameVersion = applicationName
else:
applicationNameVersion = applicationName + " - " + applicationVersion
if applicationPublisher is None:
applicationDocumentString = applicationNameVersion
else:
applicationDocumentString = applicationPublisher + " - " + applicationNameVersion
applicationDetails = {}
applicationDetails["applicationName"] = applicationName
applicationDetails["applicationVersion"] = applicationVersion
applicationDetails["applicationPublisher"] = applicationPublisher
applicationDetails["applicationNameVersion"] = applicationNameVersion
applicationDetails["applicationDocumentString"] = applicationDocumentString
logger.info(" applicationDetails: %s" %applicationDetails)
return applicationDetails