@@ -65,7 +65,7 @@ def __init__(self, app: QApplication) -> None:
65
65
self .settings = QSettings ("WEEE-Open" , "PESTO" )
66
66
self .client = ReactorThread (self .host , self .port , self .remoteMode )
67
67
68
- " Utilities Widgets "
68
+ """ Utilities Widgets "" "
69
69
self .latest_conf ()
70
70
self .diff_widgets = {}
71
71
self .smart_widgets = {}
@@ -97,6 +97,7 @@ def __init__(self, app: QApplication) -> None:
97
97
self .sleep_action = QAction ("Sleep" , self )
98
98
self .uploadToTarallo_action = QAction ("Upload to TARALLO" , self )
99
99
self .showSmartData_Action = QAction ("Show SMART data" , self )
100
+ self .umount_action = QAction ("Umount disk" , self )
100
101
self .stop_action = QAction ("Stop" , self )
101
102
self .remove_action = QAction ("Remove" , self )
102
103
self .remove_all_action = QAction ("Remove All" , self )
@@ -112,19 +113,15 @@ def __init__(self, app: QApplication) -> None:
112
113
self .setup ()
113
114
114
115
def setup (self ):
115
- """This method must be called in the __init__ function of the Ui class
116
- to initialize the pinolo session"""
116
+ """This method must be called in __init__ function of Ui class
117
+ to initialize pinolo session"""
117
118
118
119
# Check if the host and port field are set
119
120
if self .host is None and self .port is None :
120
121
message = "The host and port combination is not set.\n Please visit the settings section."
121
122
warning_dialog (message , dialog_type = "ok" )
122
123
123
- """
124
- The client try to connect to the BASILICO. If it can't and the client is in remote mode, then
125
- a critical error is shown and the client goes in idle. If the client is in local mode and it cannot reach a
126
- BASILICO server, a new BASILICO process is instantiated.
127
- """
124
+ # Start client thread
128
125
self .client = ReactorThread (self .host , self .port , self .remoteMode )
129
126
self .client .updateEvent .connect (self .gui_update )
130
127
self .client .start ()
@@ -197,6 +194,8 @@ def set_items_functions(self):
197
194
self .showSmartData_Action .triggered .connect (self .show_smart_data )
198
195
self .diskTable .addAction (self .showSmartData_Action )
199
196
self .uploadToTarallo_action .setEnabled (False )
197
+ self .diskTable .addAction (self .umount_action )
198
+ self .umount_action .triggered .connect (self .umount_disk )
200
199
201
200
self .diskTable .selectionModel ().selectionChanged .connect (self .on_table_select )
202
201
@@ -381,18 +380,23 @@ def queue_info(self):
381
380
info_dialog (message )
382
381
self .deselect ()
383
382
383
+ def umount_disk (self ):
384
+ dialog = warning_dialog (
385
+ "Are you really sure you want to umount this disk?\n This is generally not a good idea, proceed only if you are really sure of what are you doing." ,
386
+ "yes_no" ,
387
+ )
388
+
389
+ if dialog == QMessageBox .Yes :
390
+ drives = self .get_multiple_drive_selection ()
391
+ for drive in drives :
392
+ self .client .send ("queued_umount " + drive )
393
+
384
394
def get_multiple_drive_selection (self ):
385
395
"""This method returns a list with the names of the selected drives on disk_table"""
386
396
drives = []
387
- selected_items = self .diskTable .selectedItems ()
388
- columns = self .diskTable .columnCount ()
389
- for idx in range (len (selected_items ) // columns ):
390
- drives .append (
391
- [
392
- selected_items [idx * columns ].text (),
393
- selected_items [(idx * columns ) + 1 ].text (),
394
- ]
395
- )
397
+ selected_rows = self .diskTable .selectionModel ().selectedRows ()
398
+ for row in selected_rows :
399
+ drives .append (row .data ())
396
400
397
401
return drives
398
402
@@ -518,9 +522,7 @@ def show_smart_data(self):
518
522
else :
519
523
self .selected_drive = self .selected_drive .text ()
520
524
if self .selected_drive in self .smart_results :
521
- self .smart_widgets [self .selected_drive ] = SmartWidget (self .selected_drive ,
522
- self .smart_results [self .selected_drive ]
523
- )
525
+ self .smart_widgets [self .selected_drive ] = SmartWidget (self .selected_drive , self .smart_results [self .selected_drive ])
524
526
self .smart_widgets [self .selected_drive ].close_signal .connect (self .remove_smart_widget )
525
527
526
528
except BaseException as exc :
@@ -565,10 +567,10 @@ def cannolo(self, std=False, drives=None):
565
567
566
568
def upload_to_tarallo_selection (self , std : bool = False ):
567
569
# TODO: check if it's really working
568
- #for row in self.get_selected_drive_rows():
569
- # if row[1] == "":
570
- # self.upload_to_tarallo(row[0])
571
- #self.selected_drive = self.selected_drive.text();
570
+ # for row in self.get_selected_drive_rows():
571
+ # if row[1] == "":
572
+ # self.upload_to_tarallo(row[0])
573
+ # self.selected_drive = self.selected_drive.text();
572
574
self .selected_drive = self .diskTable .item (self .diskTable .currentRow (), 0 )
573
575
574
576
if not std :
@@ -581,7 +583,7 @@ def upload_to_tarallo_selection(self, std: bool = False):
581
583
return
582
584
elif self .diskTable .item (self .diskTable .currentRow (), 1 ).text () != "" :
583
585
return
584
- loc , ok = input_dialog ("Location" );
586
+ loc , ok = input_dialog ("Location" )
585
587
586
588
# If no location is provided or cancel is selected,
587
589
# cancel the operation
@@ -834,7 +836,7 @@ def gui_update(self, cmd: str, params: str):
834
836
print (f"GUI: Ignored exception while parsing { cmd } , expected JSON but this isn't: { params } " )
835
837
836
838
match cmd :
837
- case ' queue_status' | ' get_queue' :
839
+ case " queue_status" | " get_queue" :
838
840
if cmd == "queue_status" :
839
841
params = [params ]
840
842
for param in params :
@@ -891,7 +893,7 @@ def gui_update(self, cmd: str, params: str):
891
893
if "text" in param :
892
894
status_cell .setToolTip (param ["text" ])
893
895
894
- case ' get_disks' :
896
+ case " get_disks" :
895
897
drives = params
896
898
if len (drives ) <= 0 :
897
899
self .diskTable .setRowCount (0 )
@@ -903,10 +905,10 @@ def gui_update(self, cmd: str, params: str):
903
905
self .diskTable .resizeColumnToContents (0 )
904
906
self .diskTable .resizeColumnToContents (1 )
905
907
906
- case ' smartctl' | ' queued_smartctl' :
908
+ case " smartctl" | " queued_smartctl" :
907
909
self .smart_results [params ["disk" ]] = {"output" : params ["output" ], "status" : params ["status" ]}
908
910
909
- case ' connection_failed' :
911
+ case " connection_failed" :
910
912
message = params ["reason" ]
911
913
if not self .remoteMode :
912
914
print ("GUI: Connection Failed: Local server not running." )
@@ -917,29 +919,29 @@ def gui_update(self, cmd: str, params: str):
917
919
message = "Cannot find BASILICO server.\n Check if it's running in the " "targeted machine."
918
920
warning_dialog (message , dialog_type = "ok" )
919
921
920
- case ' connection_lost' :
922
+ case " connection_lost" :
921
923
self .statusBar ().showMessage (f"⚠ Connection lost. Press the reload button to reconnect." )
922
924
self .queueTable .setRowCount (0 )
923
925
self .diskTable .setRowCount (0 )
924
926
925
- case ' connection_made' :
927
+ case " connection_made" :
926
928
self .statusBar ().showMessage (f"Connected to { params ['host' ]} :{ params ['port' ]} " )
927
929
928
- case ' list_iso' :
930
+ case " list_iso" :
929
931
self .dialog = CannoloDialog (self .settingsDialog , PATH , params )
930
932
if self .manual_cannolo :
931
933
self .dialog .update .connect (self .use_cannolo_img )
932
934
self .manual_cannolo = False
933
935
else :
934
936
self .dialog .update .connect (self .settingsDialog .set_default_cannolo )
935
937
936
- case ' error' :
938
+ case " error" :
937
939
message = f"{ params ['message' ]} "
938
940
if "command" in params :
939
941
message += f":\n { params ['command' ]} "
940
942
critical_dialog (message , dialog_type = "ok" )
941
943
942
- case ' error_that_can_be_manually_fixed' :
944
+ case " error_that_can_be_manually_fixed" :
943
945
message = params ["message" ]
944
946
warning_dialog (message , dialog_type = "ok" )
945
947
0 commit comments