916 dia = PipDialog(self.tr("Purge Cache")) |
916 dia = PipDialog(self.tr("Purge Cache")) |
917 res = dia.startProcess(interpreter, args, |
917 res = dia.startProcess(interpreter, args, |
918 showArgs=False) |
918 showArgs=False) |
919 if res: |
919 if res: |
920 dia.exec() |
920 dia.exec() |
|
921 |
|
922 ####################################################################### |
|
923 ## Dependency tree handling methods below |
|
924 ####################################################################### |
|
925 |
|
926 def getDependecyTree(self, envName, localPackages=True, usersite=False, |
|
927 reverse=False): |
|
928 """ |
|
929 Public method to get the dependency tree of installed packages. |
|
930 |
|
931 @param envName name of the environment to get the packages for |
|
932 @type str |
|
933 @param localPackages flag indicating to get the tree for local |
|
934 packages only |
|
935 @type bool |
|
936 @param usersite flag indicating to get the tree for packages |
|
937 installed in user-site directory only |
|
938 @type bool |
|
939 @param reverse flag indicating to get the dependency tree in |
|
940 reverse order (i.e. list packages needed by other) |
|
941 @type bool |
|
942 @return list of nested dictionaries resembling the requested |
|
943 dependency tree |
|
944 @rtype list of dict |
|
945 """ |
|
946 dependencies = [] |
|
947 |
|
948 if envName: |
|
949 interpreter = self.getVirtualenvInterpreter(envName) |
|
950 if interpreter: |
|
951 args = [ |
|
952 "-m", "pipdeptree", |
|
953 "--json-tree", |
|
954 "--python", interpreter, |
|
955 ] |
|
956 if localPackages: |
|
957 args.append("--local-only") |
|
958 if usersite: |
|
959 args.append("--user-only") |
|
960 if reverse: |
|
961 args.append("--reverse") |
|
962 |
|
963 proc = QProcess() |
|
964 proc.start(sys.executable, args) |
|
965 if proc.waitForStarted(15000) and proc.waitForFinished(30000): |
|
966 output = str(proc.readAllStandardOutput(), |
|
967 Preferences.getSystem("IOEncoding"), |
|
968 'replace').strip() |
|
969 with contextlib.suppress(json.JSONDecodeError): |
|
970 dependencies = json.loads(output) |
|
971 |
|
972 return dependencies |