1045 |
1045 |
1046 ####################################################################### |
1046 ####################################################################### |
1047 ## License handling methods below |
1047 ## License handling methods below |
1048 ####################################################################### |
1048 ####################################################################### |
1049 |
1049 |
1050 def getLicenses(self, envName, localPackages=True, usersite=False, summary=False): |
1050 def getLicenses(self, envName): |
1051 """ |
1051 """ |
1052 Public method to get the licenses per package for a given environment. |
1052 Public method to get the licenses per package for a given environment. |
1053 |
1053 |
1054 @param envName name of the environment to get the licenses for |
1054 @param envName name of the environment to get the licenses for |
1055 @type str |
1055 @type str |
1056 @param localPackages flag indicating to get the licenses for local |
|
1057 packages only |
|
1058 @type bool |
|
1059 @param usersite flag indicating to get the licenses for packages |
|
1060 installed in user-site directory only |
|
1061 @type bool |
|
1062 @param summary flag indicating to get a summary listing (defaults to |
|
1063 False) |
|
1064 @type bool (optional) |
|
1065 @return list of dictionaries containing the license and version per |
1056 @return list of dictionaries containing the license and version per |
1066 package |
1057 package |
1067 @rtype dict |
1058 @rtype dict |
1068 """ |
1059 """ |
1069 licenses = [] |
1060 licenses = [] |
1078 "--with-system", |
1069 "--with-system", |
1079 "--with-authors", |
1070 "--with-authors", |
1080 "--with-urls", |
1071 "--with-urls", |
1081 "--with-description", |
1072 "--with-description", |
1082 ] |
1073 ] |
1083 if localPackages: |
|
1084 args.append("--local-only") |
|
1085 if usersite: |
|
1086 args.append("--user-only") |
|
1087 if summary: |
|
1088 args.append("--summary-by-license") |
|
1089 |
1074 |
1090 proc = QProcess() |
1075 proc = QProcess() |
1091 proc.start(interpreter, args) |
1076 proc.start(interpreter, args) |
1092 if proc.waitForStarted(15000) and proc.waitForFinished(30000): |
1077 if proc.waitForStarted(15000) and proc.waitForFinished(30000): |
1093 output = str( |
1078 output = str( |
1097 ).strip() |
1082 ).strip() |
1098 with contextlib.suppress(json.JSONDecodeError): |
1083 with contextlib.suppress(json.JSONDecodeError): |
1099 licenses = json.loads(output) |
1084 licenses = json.loads(output) |
1100 |
1085 |
1101 return licenses |
1086 return licenses |
1102 |
|
1103 def getLicensesSummary(self, envName, localPackages=True, usersite=False): |
|
1104 """ |
|
1105 Public method to get a summary of licenses found in a given |
|
1106 environment. |
|
1107 |
|
1108 @param envName name of the environment to get the licenses summary for |
|
1109 @type str |
|
1110 @param localPackages flag indicating to get the licenses summary for |
|
1111 local packages only |
|
1112 @type bool |
|
1113 @param usersite flag indicating to get the licenses summary for |
|
1114 packages installed in user-site directory only |
|
1115 @type bool |
|
1116 @return list of dictionaries containing the license and the count of |
|
1117 packages |
|
1118 @rtype dict |
|
1119 """ |
|
1120 return self.getLicenses( |
|
1121 envName, localPackages=localPackages, usersite=usersite, summary=True |
|
1122 ) |
|