Sun, 06 Nov 2016 18:09:23 +0100
Fixed a few issues in the new code.
5264
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
3 | # Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de> |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to edit a host fingerprint. |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | from __future__ import unicode_literals |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
5292
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
12 | from PyQt5.QtCore import pyqtSlot |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
13 | from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
5264
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from .Ui_HgUserConfigHostFingerprintDialog import \ |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | Ui_HgUserConfigHostFingerprintDialog |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | class HgUserConfigHostFingerprintDialog( |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | QDialog, Ui_HgUserConfigHostFingerprintDialog): |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | Class implementing a dialog to edit a host fingerprint. |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | """ |
5292
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
24 | supportedHashes = ("sha1", "sha256", "sha512") |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
25 | fingerprintLength = { |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
26 | "sha1": 40, |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
27 | "sha256": 64, |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
28 | "sha512": 128, |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
29 | } |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
30 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
31 | def __init__(self, parent=None, host="", fingerprint="", |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
32 | version=(0, 0, 0)): |
5264
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | Constructor |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | @param parent reference to the parent widget |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | @type QWidget |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | @param host host name |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | @type str |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | @param fingerprint fingerprint for the host |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | @type str |
5292
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
42 | @param version Mercurial version info |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
43 | @type tuple of three integers |
5264
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | """ |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | super(HgUserConfigHostFingerprintDialog, self).__init__(parent) |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | self.setupUi(self) |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | |
5292
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
48 | self.__version = version |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
49 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
50 | self.hashComboBox.addItem("") |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
51 | self.hashComboBox.addItems( |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
52 | HgUserConfigHostFingerprintDialog.supportedHashes) |
5295
87f1f8056814
Fixed a few issues in the new code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5292
diff
changeset
|
53 | if self.__version < (3, 9, 0): |
5292
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
54 | self.hashLabel.setEnabled(False) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
55 | self.hashComboBox.setEnabled(False) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
56 | hash = "sha1" |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
57 | else: |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
58 | if fingerprint and fingerprint.startswith("sha"): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
59 | hash, fingerprint = fingerprint.split(":", 1) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
60 | else: |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
61 | hash = "" |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
62 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
63 | index = self.hashComboBox.findText(hash) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
64 | self.hashComboBox.setCurrentIndex(index) |
5264
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | self.hostEdit.setText(host) |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | self.fingerprintEdit.setText(fingerprint) |
5292
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
67 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
68 | msh = self.minimumSizeHint() |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
69 | self.resize(max(self.width(), msh.width()), msh.height()) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
70 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
71 | self.__updateOkButton() |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
72 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
73 | def __updateOkButton(self): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
74 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
75 | Private method to update the status of the Ok button. |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
76 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
77 | enabled = ( |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
78 | bool(self.hostEdit.text()) and |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
79 | bool(self.fingerprintEdit.text()) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
80 | ) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
81 | if self.__version >= (3, 9, 0): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
82 | hash = self.hashComboBox.currentText() |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
83 | enabled &= bool(hash) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
84 | if hash: |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
85 | enabled &= ( |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
86 | len(self.fingerprintEdit.text().replace(":", "")) == |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
87 | HgUserConfigHostFingerprintDialog.fingerprintLength[hash] |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
88 | ) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
89 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
90 | self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
91 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
92 | @pyqtSlot(str) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
93 | def on_hostEdit_textChanged(self, txt): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
94 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
95 | Private slot to handle changes of the host edit. |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
96 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
97 | @param txt current text |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
98 | @type str |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
99 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
100 | self.__updateOkButton() |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
101 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
102 | @pyqtSlot(str) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
103 | def on_hashComboBox_currentIndexChanged(self, txt): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
104 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
105 | Private slot to handle changes of the hash combo. |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
106 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
107 | @param txt current text |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
108 | @type str |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
109 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
110 | self.__updateOkButton() |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
111 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
112 | @pyqtSlot(str) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
113 | def on_fingerprintEdit_textChanged(self, txt): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
114 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
115 | Private slot to handle changes of the fingerprint edit. |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
116 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
117 | @param txt current text |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
118 | @type str |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
119 | """ |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
120 | if txt.startswith(tuple( |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
121 | [h + ":" for h in |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
122 | HgUserConfigHostFingerprintDialog.supportedHashes])): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
123 | parts = txt.split(":", 1) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
124 | if len(parts) == 2: |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
125 | self.fingerprintEdit.setText(parts[1]) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
126 | self.__updateOkButton() |
5264
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | def getData(self): |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | """ |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | Public method to retrieve the data. |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | @return tuple containig the host name and the fingerprint |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | @rtype tuple of two str |
8bc23ecb4ea3
Finished the refactoring of the Mercurial user config management code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | """ |
5292
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
135 | if self.__version < (3, 9, 0): |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
136 | fingerprint = self.fingerprintEdit.text() |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
137 | else: |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
138 | fingerprint = "{0}:{1}".format( |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
139 | self.hashComboBox.currentText(), |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
140 | self.fingerprintEdit.text() |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
141 | ) |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
142 | |
ac8b476ba122
Added support for host fingerprints in the hostsecurity section of the Mercurial configuration file (as of hg 3.9.0).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5264
diff
changeset
|
143 | return self.hostEdit.text(), fingerprint |