|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the conda information dialog. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtCore import Qt |
|
13 from PyQt5.QtWidgets import QDialog |
|
14 |
|
15 from .Ui_CondaInfoDialog import Ui_CondaInfoDialog |
|
16 |
|
17 import UI.PixmapCache |
|
18 |
|
19 |
|
20 class CondaInfoDialog(QDialog, Ui_CondaInfoDialog): |
|
21 """ |
|
22 Class implementing the conda information dialog. |
|
23 """ |
|
24 def __init__(self, infoDict, parent=None): |
|
25 """ |
|
26 Constructor |
|
27 |
|
28 @param infoDict dictionary containing the information to be shown |
|
29 @type dict |
|
30 @param parent reference to the parent widget |
|
31 @type QWidget |
|
32 """ |
|
33 super(CondaInfoDialog, self).__init__(parent) |
|
34 self.setupUi(self) |
|
35 self.setWindowFlags(Qt.Window) |
|
36 |
|
37 self.iconLabel.setPixmap( |
|
38 UI.PixmapCache.getPixmap("miniconda48")) |
|
39 |
|
40 # version information |
|
41 if "conda_version" in infoDict: |
|
42 self.condaVersionLabel.setText( |
|
43 infoDict["conda_version"]) |
|
44 if "conda_build_version" in infoDict: |
|
45 self.condaBuildVersionLabel.setText( |
|
46 infoDict["conda_build_version"]) |
|
47 if "conda_env_version" in infoDict: |
|
48 self.condaEnvVersionLabel.setText( |
|
49 infoDict["conda_env_version"]) |
|
50 if "python_version" in infoDict: |
|
51 self.pythonVersionLabel.setText( |
|
52 infoDict["python_version"]) |
|
53 |
|
54 # prefixes |
|
55 if "active_prefix" in infoDict or "active_prefix_name" in infoDict: |
|
56 if infoDict["active_prefix_name"] and infoDict["active_prefix"]: |
|
57 self.activeEnvironmentEdit.setText( |
|
58 "{0} ({1})".format(infoDict["active_prefix_name"], |
|
59 infoDict["active_prefix"])) |
|
60 elif infoDict["active_prefix"]: |
|
61 self.activeEnvironmentEdit.setText( |
|
62 infoDict["active_prefix"]) |
|
63 elif infoDict["active_prefix_name"]: |
|
64 self.activeEnvironmentEdit.setText( |
|
65 infoDict["active_prefix_name"]) |
|
66 else: |
|
67 self.activeEnvironmentEdit.setText( |
|
68 self.tr("None")) |
|
69 else: |
|
70 self.activeEnvironmentLabel.hide() |
|
71 self.activeEnvironmentEdit.hide() |
|
72 if "root_prefix" in infoDict: |
|
73 if "root_writable" in infoDict and infoDict["root_writable"]: |
|
74 self.baseEnvironmentEdit.setText( |
|
75 self.tr("{0} (writable)").format(infoDict["root_prefix"])) |
|
76 else: |
|
77 self.baseEnvironmentEdit.setText( |
|
78 infoDict["root_prefix"]) |
|
79 if "envs_dirs" in infoDict: |
|
80 self.envDirsEdit.setPlainText( |
|
81 "\n".join(infoDict["envs_dirs"])) |
|
82 |
|
83 # configurations |
|
84 if "rc_path" in infoDict: |
|
85 self.userConfigEdit.setText( |
|
86 infoDict["rc_path"]) |
|
87 if "user_rc_path" in infoDict: |
|
88 # overwrite with more specific info |
|
89 self.userConfigEdit.setText( |
|
90 infoDict["user_rc_path"]) |
|
91 if "sys_rc_path" in infoDict: |
|
92 self.systemConfigEdit.setText( |
|
93 infoDict["sys_rc_path"]) |
|
94 if "config_files" in infoDict: |
|
95 self.configurationsEdit.setPlainText( |
|
96 "\n".join(infoDict["config_files"])) |
|
97 else: |
|
98 self.configurationsLabel.hide() |
|
99 self.configurationsEdit.hide() |
|
100 |
|
101 # channels |
|
102 if "channels" in infoDict: |
|
103 self.channelsEdit.setPlainText( |
|
104 "\n".join(infoDict["channels"])) |
|
105 |
|
106 # various |
|
107 if "pkgs_dirs" in infoDict: |
|
108 self.cachesEdit.setPlainText( |
|
109 "\n".join(infoDict["pkgs_dirs"])) |
|
110 if "platform" in infoDict: |
|
111 self.platformLabel.setText( |
|
112 infoDict["platform"]) |
|
113 if "user_agent" in infoDict: |
|
114 self.useragentEdit.setText( |
|
115 infoDict["user_agent"]) |
|
116 else: |
|
117 self.useragentLabel.hide() |
|
118 self.useragentEdit.hide() |
|
119 if "UID" in infoDict and "GID" in infoDict: |
|
120 self.uidGidDataLabel.setText( |
|
121 "{0}:{1}".format(infoDict["UID"], infoDict["GID"])) |
|
122 else: |
|
123 self.uidGidLabel.hide() |
|
124 self.uidGidDataLabel.hide() |
|
125 if "netrc_file" in infoDict: |
|
126 if infoDict["netrc_file"]: |
|
127 self.netrcEdit.setText( |
|
128 infoDict["netrc_file"]) |
|
129 else: |
|
130 self.netrcEdit.setText( |
|
131 self.tr("None")) |
|
132 else: |
|
133 self.netrcLabel.hide() |
|
134 self.netrcEdit.hide() |
|
135 if "offline" in infoDict: |
|
136 self.offlineCheckBox.setChecked( |
|
137 infoDict["offline"]) |
|
138 |
|
139 msh = self.minimumSizeHint() |
|
140 self.resize(max(self.width(), msh.width()), msh.height()) |