beremiz

IDE: Enhancements in PSK management.
py2compat
15 months ago, Edouard Tisserant
e98a14ff2cc4
Parents 6f6e60862296
Children 9c11a55ab550
IDE: Enhancements in PSK management.

- move secret reading code from eRPC connector to PSK management
- fix browser window not showing last connection date properly
--- a/PSKManagement.py Fri Feb 28 16:43:36 2025 +0100
+++ b/PSKManagement.py Fri Feb 28 16:48:28 2025 +0100
@@ -104,13 +104,21 @@
dataForID[COL_URI] = URI
# FIXME : could store time instead os a string and use DVC model's cmp
# then date display could be smarter, etc - sortable sting hack for now
- dataForID[COL_LAST] = time.strftime('%y/%M/%d-%H:%M:%S')
+ dataForID[COL_LAST] = time.strftime('%y/%m/%d-%H:%M:%S')
if _is_new_ID:
data.append(dataForID)
SaveData(project_path, data)
+def GetSecret(project_path, ID):
+ # load PSK from project
+ secpath = os.path.join(project_path, 'psk', ID + '.secret')
+ if not os.path.exists(secpath):
+ raise ValueError(
+ 'Error: Pre-Shared-Key Secret in %s is missing!\n' % secpath)
+ secret = open(secpath).read().partition(':')[2].rstrip('\n\r')
+ return secret
def ExportIDs(project_path, export_zip):
with ZipFile(export_zip, 'w') as zf:
--- a/controls/IDBrowser.py Fri Feb 28 16:43:36 2025 +0100
+++ b/controls/IDBrowser.py Fri Feb 28 16:48:28 2025 +0100
@@ -11,12 +11,12 @@
from dialogs.IDMergeDialog import IDMergeDialog
-class IDBrowserModel(dv.PyDataViewIndexListModel):
+class IDBrowserModel(dv.DataViewIndexListModel):
def __init__(self, project_path, columncount):
self.project_path = project_path
self.columncount = columncount
self.data = PSK.GetData(project_path)
- dv.PyDataViewIndexListModel.__init__(self, len(self.data))
+ dv.DataViewIndexListModel.__init__(self, len(self.data))
def _saveData(self):
PSK.SaveData(self.project_path, self.data)