@@ -44,72 +44,83 @@ def update_handler(self):
44
44
45
45
# if n == 0:
46
46
print ("update handler started.." )
47
- if self .start_update_handler == True :
47
+ # if self.start_update_handler == True:
48
48
49
- while True :
50
- if len (self .processing ) == 0 :
51
- self .start_update_handler = False
52
- break
49
+ while True :
50
+ if len (self .processing ) == 0 :
51
+ self .start_update_handler = False
52
+ return
53
53
54
- msg = {"type" :"WRITE_QUERY" , "username" :self .username , "processing" :self .processing }
54
+ msg = {"type" :"WRITE_QUERY" , "username" :self .username , "processing" :self .processing }
55
55
56
- s = socket .socket ()
56
+ s = socket .socket ()
57
+
58
+ ip = MDS_IPs ["primary" ]["ip" ]
59
+ port = MDS_IPs ["primary" ]["port" ]
60
+ # print(s.gethostname())
61
+ s .bind (('' , 9090 ))
62
+
63
+ try :
64
+ s .connect ((ip , port ))
65
+
66
+ _send_msg (s , msg )
57
67
58
- ip = MDS_IPs ["primary" ]["ip" ]
59
- port = MDS_IPs ["primary" ]["port" ]
60
- # print(s.gethostname())
61
- s .bind (('' , 9090 ))
62
-
63
- try :
64
- s .connect ((ip , port ))
65
-
66
- _send_msg (s , msg )
68
+ response = _wait_recv_msg (s , MSG_SIZE )
69
+
70
+ s .close ()
71
+ if response ["status" ] == "SUCCESS" : # here check response from mds
72
+ print (response ["msg" ])
73
+ file_written = response ["file_written" ]
67
74
68
- response = _wait_recv_msg (s , MSG_SIZE )
69
-
70
- s .close ()
71
- if response ["status" ] == "SUCCESS" : # here check response from mds
72
- print (response ["msg" ])
73
- file_written = response ["file_written" ]
74
-
75
- for filename in file_written : #populate listbox again
76
- self .listbox .insert (END , filename )
77
- # listbox.insert(END, percent)
78
- self .listbox .update_idletasks ()
79
-
80
- for file in file_written :
81
- self ._popup ("Update" , str (file )+ " UPLOADED SUCCESSFULLY" )
82
-
83
- tree = response ["tree" ]
84
- self .dir_tree = tree ["dir_tree" ]
85
- self .processing = tree ["processing" ]
86
- # update on GUI
87
-
88
- # self._update_canvas()
89
-
90
- for filename in file_written : #populate listbox again
91
- self .listbox .insert (END , filename )
92
- # listbox.insert(END, percent)
93
- self .listbox .update_idletasks ()
94
-
95
- # tk.mainloop()
96
- # self.window.mainloop()
97
- elif response ["status" ] == "NO_UPD" :
98
- print (response ["msg" ])
99
- time .sleep (self .update_interval )
100
-
75
+ for file in file_written : #populate listbox again
76
+ filename = file [0 ]
77
+ file_id = file [1 ]
78
+ file_path = file [2 ]
79
+ self .file_id_map [filename ] = file_id
80
+ self .listbox .insert (tk .END , file_path )
81
+ # listbox.insert(END, percent)
82
+ self .listbox .update_idletasks ()
83
+
84
+ tree = response ["tree" ]
85
+ self .dir_tree = tree ["dir_tree" ]
86
+ self .processing = tree ["processing" ]
87
+ print (self .processing )
88
+ if len (self .processing ) == 0 :
89
+ self .start_update_handler = False
90
+ print ("Exiting update handler" )
91
+
92
+ for file in file_written :
93
+ self ._popup ("Update" , str (file [2 ])+ " UPLOADED SUCCESSFULLY" )
94
+
95
+
96
+ # return
97
+ # update on GUI
101
98
102
- except Exception as e :
103
- s .close ()
104
- print ("Update (write) from MDS failed" )
105
- print (e )
106
- time .sleep (self .update_interval )
107
-
99
+ # self._update_gui()
108
100
109
- finally :
101
+ # for filename in file_written: #populate listbox again
102
+ # self.listbox.insert(END, filename)
103
+ # # listbox.insert(END, percent)
104
+ # self.listbox.update_idletasks()
110
105
111
- time .sleep (self .update_interval )
106
+ # tk.mainloop()
107
+ # self.window.mainloop()
108
+ elif response ["status" ] == "NO_UPD" :
109
+ print (response ["msg" ])
110
+ time .sleep (self .update_interval )
111
+
112
+
113
+ except Exception as e :
114
+ s .close ()
115
+ print ("Update (write) from MDS failed" )
116
+ print (e )
117
+ time .sleep (self .update_interval )
118
+
119
+
120
+ finally :
112
121
122
+ time .sleep (self .update_interval )
123
+
113
124
114
125
115
126
def upload (self , file_path ):
@@ -258,10 +269,10 @@ def _write(self, pg, pg_data):
258
269
if osd_response ["status" ] == "RECEIVED" :
259
270
print ("file sent to OSD" )
260
271
self .processing [pg .pg_id ] = pg_data
261
- if self .start_update_handler == False :
262
- self .start_update_handler = True
263
- self .update_handler ()
264
- # threading.Thread(target=self.update_handler())
272
+ # if self.start_update_handler == False:
273
+ # self.start_update_handler = True
274
+ # self.update_handler()
275
+ threading .Thread (target = self .update_handler ())
265
276
s .close ()
266
277
return 0
267
278
@@ -403,7 +414,7 @@ def _update_gui(self):
403
414
404
415
405
416
scrollbar .config ( command = self .listbox .yview )
406
-
417
+ tk . mainloop ()
407
418
408
419
def browseFiles (self ):
409
420
filename = filedialog .askopenfilename (initialdir = "/" ,
@@ -563,7 +574,7 @@ def login():
563
574
564
575
print ("[ERROR] login failed" )
565
576
print (e )
566
- _popup ("Login Failed" , response [ "msg" ] )
577
+ _popup ("Login Failed" , str ( e ) )
567
578
568
579
finally :
569
580
print ("Exiting login.." )
0 commit comments