17 |
17 |
18 class PipPage(ConfigurationPageBase, Ui_PipPage): |
18 class PipPage(ConfigurationPageBase, Ui_PipPage): |
19 """ |
19 """ |
20 Class implementing the pip configuration page. |
20 Class implementing the pip configuration page. |
21 """ |
21 """ |
|
22 |
22 def __init__(self): |
23 def __init__(self): |
23 """ |
24 """ |
24 Constructor |
25 Constructor |
25 """ |
26 """ |
26 super().__init__() |
27 super().__init__() |
27 self.setupUi(self) |
28 self.setupUi(self) |
28 self.setObjectName("PipPage") |
29 self.setObjectName("PipPage") |
29 |
30 |
30 self.indexLabel.setText(self.tr( |
31 self.indexLabel.setText( |
31 '<b>Note:</b> Leave empty to use the default index URL (' |
32 self.tr( |
32 '<a href="{0}">{0}</a>).' |
33 "<b>Note:</b> Leave empty to use the default index URL (" |
33 ).format(Pip.DefaultPyPiUrl)) |
34 '<a href="{0}">{0}</a>).' |
34 self.safetyDbMirrorLabel.setText(self.tr( |
35 ).format(Pip.DefaultPyPiUrl) |
35 '<b>Note:</b> Leave empty to use the default Safety DB URL ({0}).' |
36 ) |
36 ).format(Preferences.Prefs.pipDefaults["VulnerabilityDbMirror"])) |
37 self.safetyDbMirrorLabel.setText( |
37 |
38 self.tr( |
|
39 "<b>Note:</b> Leave empty to use the default Safety DB URL ({0})." |
|
40 ).format(Preferences.Prefs.pipDefaults["VulnerabilityDbMirror"]) |
|
41 ) |
|
42 |
38 # set initial values |
43 # set initial values |
39 self.indexEdit.setText(Preferences.getPip("PipSearchIndex")) |
44 self.indexEdit.setText(Preferences.getPip("PipSearchIndex")) |
40 |
45 |
41 safetyDbUrl = Preferences.getPip("VulnerabilityDbMirror") |
46 safetyDbUrl = Preferences.getPip("VulnerabilityDbMirror") |
42 if ( |
47 if safetyDbUrl == Preferences.Prefs.pipDefaults["VulnerabilityDbMirror"]: |
43 safetyDbUrl == |
|
44 Preferences.Prefs.pipDefaults["VulnerabilityDbMirror"] |
|
45 ): |
|
46 safetyDbUrl = "" |
48 safetyDbUrl = "" |
47 self.safetyDbMirrorEdit.setText(safetyDbUrl) |
49 self.safetyDbMirrorEdit.setText(safetyDbUrl) |
48 self.validitySpinBox.setValue( |
50 self.validitySpinBox.setValue( |
49 Preferences.getPip("VulnerabilityDbCacheValidity") // 3600) |
51 Preferences.getPip("VulnerabilityDbCacheValidity") // 3600 |
|
52 ) |
50 # seconds converted to hours |
53 # seconds converted to hours |
51 |
54 |
52 self.noCondaCheckBox.setChecked( |
55 self.noCondaCheckBox.setChecked(Preferences.getPip("ExcludeCondaEnvironments")) |
53 Preferences.getPip("ExcludeCondaEnvironments")) |
56 |
54 |
|
55 def save(self): |
57 def save(self): |
56 """ |
58 """ |
57 Public slot to save the pip configuration. |
59 Public slot to save the pip configuration. |
58 """ |
60 """ |
59 safetyDbUrl = self.safetyDbMirrorEdit.text().strip() |
61 safetyDbUrl = self.safetyDbMirrorEdit.text().strip() |
60 if not safetyDbUrl: |
62 if not safetyDbUrl: |
61 safetyDbUrl = Preferences.Prefs.pipDefaults[ |
63 safetyDbUrl = Preferences.Prefs.pipDefaults["VulnerabilityDbMirror"] |
62 "VulnerabilityDbMirror"] |
|
63 safetyDbUrl = safetyDbUrl.replace("\\", "/") |
64 safetyDbUrl = safetyDbUrl.replace("\\", "/") |
64 if not safetyDbUrl.endswith("/"): |
65 if not safetyDbUrl.endswith("/"): |
65 safetyDbUrl += "/" |
66 safetyDbUrl += "/" |
66 |
67 |
67 Preferences.setPip("PipSearchIndex", |
68 Preferences.setPip("PipSearchIndex", self.indexEdit.text().strip()) |
68 self.indexEdit.text().strip()) |
69 |
69 |
|
70 Preferences.setPip("VulnerabilityDbMirror", safetyDbUrl) |
70 Preferences.setPip("VulnerabilityDbMirror", safetyDbUrl) |
71 Preferences.setPip("VulnerabilityDbCacheValidity", |
71 Preferences.setPip( |
72 self.validitySpinBox.value() * 3600) |
72 "VulnerabilityDbCacheValidity", self.validitySpinBox.value() * 3600 |
|
73 ) |
73 # hours converted to seconds |
74 # hours converted to seconds |
74 |
75 |
75 Preferences.setPip("ExcludeCondaEnvironments", |
76 Preferences.setPip("ExcludeCondaEnvironments", self.noCondaCheckBox.isChecked()) |
76 self.noCondaCheckBox.isChecked()) |
|
77 |
77 |
78 |
78 |
79 def create(dlg): |
79 def create(dlg): |
80 """ |
80 """ |
81 Module function to create the configuration page. |
81 Module function to create the configuration page. |
82 |
82 |
83 @param dlg reference to the configuration dialog |
83 @param dlg reference to the configuration dialog |
84 @return reference to the instantiated page (ConfigurationPageBase) |
84 @return reference to the instantiated page (ConfigurationPageBase) |
85 """ |
85 """ |
86 page = PipPage() |
86 page = PipPage() |
87 return page |
87 return page |