| 60 | | def on_openvolumecontrol_button_click(self, widget, ip): |
| 61 | | print_debug ( "on_openvolumecontrol_button_click() ip=%s" %(ip) ) |
| 62 | | cmd="PULSE_SERVER=\"%s\" pavucontrol" %(ip) |
| 63 | | if os.path.isdir("/dev/shm"): |
| 64 | | self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| 65 | | else: |
| 66 | | shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| 67 | | |
| 68 | | def on_openvolumemeter_button_click(self, widget, ip): |
| 69 | | print_debug ( "on_openvolumemeter_button_click() ip=%s" %(ip) ) |
| 70 | | cmd="PULSE_SERVER=\"%s\" pavumeter" %(ip) |
| 71 | | if os.path.isdir("/dev/shm"): |
| 72 | | self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| 73 | | else: |
| 74 | | shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| 75 | | |
| 76 | | def on_volumemanager_button_click(self, widget, ip): |
| 77 | | print_debug ( "on_volumemanager_button_click() ip=%s" %(ip) ) |
| 78 | | cmd="PULSE_SERVER=\"%s\" paman" %(ip) |
| 79 | | if os.path.isdir("/dev/shm"): |
| 80 | | self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| 81 | | else: |
| 82 | | shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| | 62 | # def on_openvolumecontrol_button_click(self, widget, ip): |
| | 63 | # print_debug ( "on_openvolumecontrol_button_click() ip=%s" %(ip) ) |
| | 64 | # cmd="PULSE_SERVER=\"%s\" pavucontrol" %(ip) |
| | 65 | # if os.path.isdir("/dev/shm"): |
| | 66 | # self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| | 67 | # else: |
| | 68 | # shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| | 69 | # |
| | 70 | # def on_openvolumemeter_button_click(self, widget, ip): |
| | 71 | # print_debug ( "on_openvolumemeter_button_click() ip=%s" %(ip) ) |
| | 72 | # cmd="PULSE_SERVER=\"%s\" pavumeter" %(ip) |
| | 73 | # if os.path.isdir("/dev/shm"): |
| | 74 | # self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| | 75 | # else: |
| | 76 | # shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| | 77 | # |
| | 78 | # def on_volumemanager_button_click(self, widget, ip): |
| | 79 | # print_debug ( "on_volumemanager_button_click() ip=%s" %(ip) ) |
| | 80 | # cmd="PULSE_SERVER=\"%s\" paman" %(ip) |
| | 81 | # if os.path.isdir("/dev/shm"): |
| | 82 | # self.main.common.exe_cmd( cmd, verbose=0, background=True ) |
| | 83 | # else: |
| | 84 | # shared.error_msg ( _("PulseAudio apps need /dev/shm.") ) |
| 227 | | def on_drag_data_received( self, widget, context, x, y, selection, targetType, dtime): |
| 228 | | files = selection.data.split('\n',1) |
| 229 | | start1=time() |
| 230 | | print_debug("on_drag_data_received() files=%s dtime=%s"%(files,dtime)) |
| 231 | | for f in files: |
| 232 | | if f: |
| 233 | | desktop = f.strip().replace('%20', ' ') |
| 234 | | break |
| 235 | | |
| 236 | | if desktop.startswith('file:///') and desktop.lower().endswith('.desktop') and os.path.isfile(desktop[7:]): |
| 237 | | print_debug("open_file() reading data from \"%s\"..." \ |
| 238 | | %(desktop[7:]) ) |
| 239 | | fd=file(desktop[7:], 'r') |
| 240 | | data=fd.readlines() |
| 241 | | fd.close() |
| 242 | | |
| 243 | | # try to load gnome theme with gconf |
| 244 | | mytheme=[] |
| 245 | | theme=self.main.common.get_icon_theme() |
| 246 | | print_debug("on_drag_data_received() gconf theme=%s"%theme) |
| 247 | | |
| 248 | | """ |
| 249 | | icons_path=["/usr/share/app-install/icons/", |
| 250 | | "/usr/share/icons/hicolor/48x48/apps/", |
| 251 | | "/usr/share/icons/hicolor/32x32/apps/", |
| 252 | | "/usr/share/icons/hicolor/24x24/apps/", |
| 253 | | "/usr/share/icons/gnome/48x48/apps/", |
| 254 | | "/usr/share/icons/gnome/32x32/apps/", |
| 255 | | "/usr/share/pixmaps/", |
| 256 | | "/usr/share/icons/gnome/32x32/devices/"] |
| 257 | | icons_extensions=[".png", "", ".xpm"] |
| 258 | | """ |
| 259 | | str_image="" |
| 260 | | files=[] |
| 261 | | |
| 262 | | if theme and os.path.isdir("/usr/share/icons/%s"%theme): |
| 263 | | files+=glob.glob("/usr/share/icons/%s/48x48/*.png"%(theme)) |
| 264 | | |
| 265 | | files+=glob.glob("/usr/share/icons/hicolor/48x48/*/*.png") + \ |
| 266 | | glob.glob("/usr/share/icons/gnome/48x48/*/*.png") + \ |
| 267 | | glob.glob("/usr/share/pixmaps/*png") +\ |
| 268 | | glob.glob("/usr/share/pixmaps/*xpm") |
| 269 | | |
| 270 | | for line in data: |
| 271 | | if line != '\n': |
| 272 | | if line.startswith("Exec="): |
| 273 | | line=line.replace('\n', '') |
| 274 | | action, str_exec=line.split("=",1) |
| 275 | | str_exec=str_exec.replace("%U","").replace("%u","").replace("%F","").replace("%f","").replace("%c","").replace("%i","").replace("%m","") |
| 276 | | elif line.startswith("Icon="): |
| 277 | | line=line.replace('\n', '') |
| 278 | | action, image_name=line.split("=",1) |
| 279 | | if not os.path.isfile(image_name): |
| 280 | | start2=time() |
| 281 | | for f in files: |
| 282 | | if image_name in f or image_name.replace('_', '-') in f: |
| 283 | | str_image=f |
| 284 | | crono(start2, "on_drag_data_received() ICON FOUND AT %s"%f ) |
| 285 | | break |
| 286 | | |
| 287 | | """ |
| 288 | | for ipath in icons_path: |
| 289 | | for ext in icons_extensions: |
| 290 | | print_debug("searching icon=%s in %s extension=%s" %(image_name, ipath, ext)) |
| 291 | | if os.path.isfile(ipath+image_name+ext): |
| 292 | | str_image=ipath+image_name+ext |
| 293 | | print_debug("image_name=%s found at %s, extension %s" %(image_name, ipath, ext)) |
| 294 | | break |
| 295 | | if str_image != "": break |
| 296 | | str_image="" |
| 297 | | """ |
| 298 | | else: |
| 299 | | str_image=image_name |
| 300 | | |
| 301 | | if len(str_exec) <1: |
| 302 | | shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| 303 | | else: |
| 304 | | if len(str_image) <1: |
| 305 | | print_debug("on_drag_data_received() image '%s' not found"%image_name) |
| 306 | | self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| 307 | | else: |
| 308 | | self.main.image_entry.set_from_file(str_image) |
| 309 | | self.main.ask_entry.set_text(str_exec) |
| 310 | | else: |
| 311 | | shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| 312 | | crono(start1, "on_drag_data_received() end" ) |
| 313 | | return True |
| | 231 | # def on_drag_data_received( self, widget, context, x, y, selection, targetType, dtime): |
| | 232 | # files = selection.data.split('\n',1) |
| | 233 | # start1=time() |
| | 234 | # print_debug("on_drag_data_received() files=%s dtime=%s"%(files,dtime)) |
| | 235 | # for f in files: |
| | 236 | # if f: |
| | 237 | # desktop = f.strip().replace('%20', ' ') |
| | 238 | # break |
| | 239 | # |
| | 240 | # if desktop.startswith('file:///') and desktop.lower().endswith('.desktop') and os.path.isfile(desktop[7:]): |
| | 241 | # print_debug("open_file() reading data from \"%s\"..." \ |
| | 242 | # %(desktop[7:]) ) |
| | 243 | # fd=file(desktop[7:], 'r') |
| | 244 | # data=fd.readlines() |
| | 245 | # fd.close() |
| | 246 | # |
| | 247 | # # try to load gnome theme with gconf |
| | 248 | # mytheme=[] |
| | 249 | # theme=self.main.common.get_icon_theme() |
| | 250 | # print_debug("on_drag_data_received() gconf theme=%s"%theme) |
| | 251 | # |
| | 252 | # """ |
| | 253 | # icons_path=["/usr/share/app-install/icons/", |
| | 254 | # "/usr/share/icons/hicolor/48x48/apps/", |
| | 255 | # "/usr/share/icons/hicolor/32x32/apps/", |
| | 256 | # "/usr/share/icons/hicolor/24x24/apps/", |
| | 257 | # "/usr/share/icons/gnome/48x48/apps/", |
| | 258 | # "/usr/share/icons/gnome/32x32/apps/", |
| | 259 | # "/usr/share/pixmaps/", |
| | 260 | # "/usr/share/icons/gnome/32x32/devices/"] |
| | 261 | # icons_extensions=[".png", "", ".xpm"] |
| | 262 | # """ |
| | 263 | # str_image="" |
| | 264 | # files=[] |
| | 265 | # |
| | 266 | # if theme and os.path.isdir("/usr/share/icons/%s"%theme): |
| | 267 | # files+=glob.glob("/usr/share/icons/%s/48x48/*.png"%(theme)) |
| | 268 | # |
| | 269 | # files+=glob.glob("/usr/share/icons/hicolor/48x48/*/*.png") + \ |
| | 270 | # glob.glob("/usr/share/icons/gnome/48x48/*/*.png") + \ |
| | 271 | # glob.glob("/usr/share/pixmaps/*png") +\ |
| | 272 | # glob.glob("/usr/share/pixmaps/*xpm") |
| | 273 | # |
| | 274 | # for line in data: |
| | 275 | # if line != '\n': |
| | 276 | # if line.startswith("Exec="): |
| | 277 | # line=line.replace('\n', '') |
| | 278 | # action, str_exec=line.split("=",1) |
| | 279 | # str_exec=str_exec.replace("%U","").replace("%u","").replace("%F","").replace("%f","").replace("%c","").replace("%i","").replace("%m","") |
| | 280 | # elif line.startswith("Icon="): |
| | 281 | # line=line.replace('\n', '') |
| | 282 | # action, image_name=line.split("=",1) |
| | 283 | # if not os.path.isfile(image_name): |
| | 284 | # start2=time() |
| | 285 | # for f in files: |
| | 286 | # if image_name in f or image_name.replace('_', '-') in f: |
| | 287 | # str_image=f |
| | 288 | # crono(start2, "on_drag_data_received() ICON FOUND AT %s"%f ) |
| | 289 | # break |
| | 290 | # |
| | 291 | # """ |
| | 292 | # for ipath in icons_path: |
| | 293 | # for ext in icons_extensions: |
| | 294 | # print_debug("searching icon=%s in %s extension=%s" %(image_name, ipath, ext)) |
| | 295 | # if os.path.isfile(ipath+image_name+ext): |
| | 296 | # str_image=ipath+image_name+ext |
| | 297 | # print_debug("image_name=%s found at %s, extension %s" %(image_name, ipath, ext)) |
| | 298 | # break |
| | 299 | # if str_image != "": break |
| | 300 | # str_image="" |
| | 301 | # """ |
| | 302 | # else: |
| | 303 | # str_image=image_name |
| | 304 | # |
| | 305 | # if len(str_exec) <1: |
| | 306 | # shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| | 307 | # else: |
| | 308 | # if len(str_image) <1: |
| | 309 | # print_debug("on_drag_data_received() image '%s' not found"%image_name) |
| | 310 | # self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| | 311 | # else: |
| | 312 | # self.main.image_entry.set_from_file(str_image) |
| | 313 | # self.main.ask_entry.set_text(str_exec) |
| | 314 | # else: |
| | 315 | # shared.error_msg( _("%s is not application") %(os.path.basename(desktop[7:])) ) |
| | 316 | # crono(start1, "on_drag_data_received() end" ) |
| | 317 | # return True |
| 321 | | def on_ask_cancel_click(self, widget): |
| 322 | | self.main.ask.hide() |
| 323 | | self.main.ask_entry.set_text("") |
| 324 | | #desactivar arrastrar y soltar |
| 325 | | self.main.ask_fixed.hide() |
| 326 | | self.main.image_entry.hide() |
| 327 | | self.main.ask_dragdrop.hide() |
| 328 | | return |
| | 334 | # def askfor(self, mode="mess", msg="", users=[]): |
| | 335 | # self.ask_usernames=[] |
| | 336 | # if len(users) == 0 or users[0] == shared.NO_LOGIN_MSG: |
| | 337 | # shared.error_msg( _("Clients not connected") ) |
| | 338 | # return |
| | 339 | # else: |
| | 340 | # self.ask_usernames=users |
| | 341 | |
| | 342 | # users_txt="" |
| | 343 | # counter=1 |
| | 344 | # for user in self.ask_usernames: |
| | 345 | # users_txt+="%s, " %(user) |
| | 346 | # print_debug("askfor() counter=%s" %(counter) ) |
| | 347 | # if counter % 4 == 0: |
| | 348 | # users_txt+="\n" |
| | 349 | # counter=int(counter+1) |
| | 350 | |
| | 351 | # if users_txt[-2:] == "\n": users_txt=users_txt[:-2] |
| | 352 | # if users_txt[-2:] == ", ": users_txt=users_txt[:-2] |
| | 353 | # |
| | 354 | # if mode == "exec": |
| | 355 | # #activar arrastrar y soltar |
| | 356 | # self.main.ask_fixed.show() |
| | 357 | # self.main.ask_dragdrop.show() |
| | 358 | # self.main.image_entry.show() |
| | 359 | # self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| | 360 | # self.main.ask_label.set_markup( _("<b>Exec app in user(s) screen(s):</b>\n%s" ) %( users_txt ) ) |
| | 361 | # elif mode == "mess": |
| | 362 | # self.main.ask_label.set_markup( _("<b>Send a message to:</b>\n%s" ) %( users_txt ) ) |
| | 363 | # elif mode == "any": |
| | 364 | # self.main.ask_label.set_markup( msg ) |
| | 365 | # self.ask_mode=mode |
| | 366 | # self.main.ask.show() |
| | 367 | # return True |
| | 368 | |
| | 369 | # def exe_app_in_client(self, mode, timeout=0, msg="", users=[], connected_users=[]): |
| | 370 | # remote_cmd=("/usr/lib/tcos/session-cmd-send %s %s %s" %(mode.upper(), timeout, msg.replace("'", "´"))) |
| | 371 | # action="down-controller %s %s" %(mode, timeout) |
| | 372 | # print_debug("exe_app_in_client() usernames=%s" %users) |
| | 373 | # |
| | 374 | # if len(connected_users) != 0 and connected_users[0] != shared.NO_LOGIN_MSG: |
| | 375 | # newusernames=[] |
| | 376 | # for user in connected_users: |
| | 377 | # if user.find(":") != -1: |
| | 378 | # # we have a standalone user... |
| | 379 | # usern, ip = user.split(":") |
| | 380 | # self.main.xmlrpc.newhost(ip) |
| | 381 | # self.main.xmlrpc.DBus("exec", remote_cmd ) |
| | 382 | # else: |
| | 383 | # newusernames.append(user) |
| | 384 | # |
| | 385 | # result = self.main.dbus_action.do_exec( newusernames ,remote_cmd ) |
| | 386 | # |
| | 387 | # if not result: |
| | 388 | # shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) ) |
| | 389 | # |
| | 390 | # self.main.worker=shared.Workers(self.main, None, None) |
| | 391 | # self.main.worker.set_for_all_action(self.action_for_clients,\ |
| | 392 | # users, action ) |
| | 393 | # return |
| 330 | | def askfor(self, mode="mess", msg="", users=[]): |
| 331 | | self.ask_usernames=[] |
| 332 | | if len(users) == 0 or users[0] == shared.NO_LOGIN_MSG: |
| 333 | | shared.error_msg( _("Clients not connected") ) |
| 334 | | return |
| 335 | | else: |
| 336 | | self.ask_usernames=users |
| 337 | | |
| 338 | | users_txt="" |
| 339 | | counter=1 |
| 340 | | for user in self.ask_usernames: |
| 341 | | users_txt+="%s, " %(user) |
| 342 | | print_debug("askfor() counter=%s" %(counter) ) |
| 343 | | if counter % 4 == 0: |
| 344 | | users_txt+="\n" |
| 345 | | counter=int(counter+1) |
| 346 | | |
| 347 | | if users_txt[-2:] == "\n": users_txt=users_txt[:-2] |
| 348 | | if users_txt[-2:] == ", ": users_txt=users_txt[:-2] |
| 349 | | |
| 350 | | if mode == "exec": |
| 351 | | #activar arrastrar y soltar |
| 352 | | self.main.ask_fixed.show() |
| 353 | | self.main.ask_dragdrop.show() |
| 354 | | self.main.image_entry.show() |
| 355 | | self.main.image_entry.set_from_stock(gtk.STOCK_DIALOG_QUESTION, 4) |
| 356 | | self.main.ask_label.set_markup( _("<b>Exec app in user(s) screen(s):</b>\n%s" ) %( users_txt ) ) |
| 357 | | elif mode == "mess": |
| 358 | | self.main.ask_label.set_markup( _("<b>Send a message to:</b>\n%s" ) %( users_txt ) ) |
| 359 | | elif mode == "any": |
| 360 | | self.main.ask_label.set_markup( msg ) |
| 361 | | self.ask_mode=mode |
| 362 | | self.main.ask.show() |
| 363 | | return True |
| 364 | | |
| 365 | | def exe_app_in_client(self, mode, timeout=0, msg="", users=[], connected_users=[]): |
| 366 | | remote_cmd=("/usr/lib/tcos/session-cmd-send %s %s %s" %(mode.upper(), timeout, msg.replace("'", "´"))) |
| 367 | | action="down-controller %s %s" %(mode, timeout) |
| 368 | | print_debug("exe_app_in_client() usernames=%s" %users) |
| 369 | | |
| 370 | | if len(connected_users) != 0 and connected_users[0] != shared.NO_LOGIN_MSG: |
| 371 | | newusernames=[] |
| 372 | | for user in connected_users: |
| 373 | | if user.find(":") != -1: |
| 374 | | # we have a standalone user... |
| 375 | | usern, ip = user.split(":") |
| 376 | | self.main.xmlrpc.newhost(ip) |
| 377 | | self.main.xmlrpc.DBus("exec", remote_cmd ) |
| 378 | | else: |
| 379 | | newusernames.append(user) |
| 380 | | |
| 381 | | result = self.main.dbus_action.do_exec( newusernames ,remote_cmd ) |
| 382 | | |
| 383 | | if not result: |
| 384 | | shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) ) |
| 385 | | |
| 386 | | self.main.worker=shared.Workers(self.main, None, None) |
| 387 | | self.main.worker.set_for_all_action(self.action_for_clients,\ |
| 388 | | users, action ) |
| 389 | | return |
| 390 | | |
| 391 | | def exe_app_in_client_display(self, arg): |
| 392 | | usernames=self.ask_usernames |
| 393 | | newusernames=[] |
| 394 | | print_debug("exe_app_in_client_display() usernames=%s" %usernames) |
| 395 | | |
| 396 | | if arg.startswith('rm ') or arg.find(" rm ") != -1 \ |
| 397 | | or arg.startswith('mv ') or arg.find(" mv ") != -1 \ |
| 398 | | or arg.startswith('cp ') or arg.find(" cp ") != -1: |
| 399 | | arg="" |
| 400 | | |
| 401 | | if self.ask_mode == "mess": |
| 402 | | arg=arg.replace("'", "´") |
| 403 | | |
| 404 | | for user in usernames: |
| 405 | | if user.find(":") != -1: |
| 406 | | # we have a standalone user... |
| 407 | | usern, ip = user.split(":") |
| 408 | | print_debug("exe_app_in_client_display() STANDALONE username=%s ip=%s" %(usern, ip)) |
| 409 | | self.main.xmlrpc.newhost(ip) |
| 410 | | self.main.xmlrpc.DBus(self.ask_mode, arg) |
| 411 | | else: |
| 412 | | newusernames.append(user) |
| 413 | | |
| 414 | | # we have a thin client user |
| 415 | | if self.ask_mode == "exec": |
| 416 | | result = self.main.dbus_action.do_exec( newusernames , arg ) |
| 417 | | if not result: |
| 418 | | shared.error_msg ( _("Error while exec remote app:\nReason: %s") %( self.main.dbus_action.get_error_msg() ) ) |
| 419 | | else: |
| 420 | | self.main.ask.hide() |
| 421 | | self.main.ask_entry.set_text("") |
| 422 | | elif self.ask_mode == "mess": |
| 423 | | result = self.main.dbus_action.do_message( newusernames , arg) |
| 424 | | if not result: |
| 425 | | shared.error_msg ( _("Error while send message:\nReason: %s") %( self.main.dbus_action.get_error_msg() ) ) |
| 426 | | self.main.ask_dragdrop.hide() |
| 427 | | self.main.ask_fixed.hide() |
| 428 | | self.main.image_entry.hide() |
| 429 | | self.main.ask.hide() |
| 430 | | self.main.ask_entry.set_text("") |
| 431 | | dbus_action=None |
| 432 | | self.ask_mode=None |
| 433 | | return |
| | 395 | # def exe_app_in_client_display(self, arg): |
| | 396 | # usernames=self.ask_usernames |
| | 397 | # newusernames=[] |
| | 398 | # print_debug("exe_app_in_client_display() usernames=%s" %usernames) |
| | 399 | # |
| | 400 | # if arg.startswith('rm ') or arg.find(" rm ") != -1 \ |
| | 401 | # or arg.startswith('mv ') or arg.find(" mv ") != -1 \ |
| | 402 | # or arg.startswith('cp ') or arg.find(" cp ") != -1: |
| | 403 | # arg="" |
| | 404 | # |
| | 405 | # if self.ask_mode == "mess": |
| | 406 | # arg=arg.replace("'", "´") |
| | 407 | # |
| | 408 | # for user in usernames: |
| | 409 | # if user.find(":") != -1: |
| | 410 | # # we have a standalone user... |
| | 411 | # usern, ip = user.split(":") |
| | 412 | # print_debug("exe_app_in_client_display() STANDALONE username=%s ip=%s" %(usern, ip)) |
| | 413 | # self.main.xmlrpc.newhost(ip) |
| | 414 | # self.main.xmlrpc.DBus(self.ask_mode, arg) |
| | 415 | # else: |
| | 416 | # newusernames.append(user) |
| | 417 | # |
| | 418 | # # we have a thin client user |
| | 419 | # if self.ask_mode == "exec": |
| | 420 | # result = self.main.dbus_action.do_exec( newusernames , arg ) |
| | 421 | # if not result: |
| | 422 | # shared.error_msg ( _("Error while exec remote app:\nReason: %s") %( self.main.dbus_action.get_error_msg() ) ) |
| | 423 | # else: |
| | 424 | # self.main.ask.hide() |
| | 425 | # self.main.ask_entry.set_text("") |
| | 426 | # elif self.ask_mode == "mess": |
| | 427 | # result = self.main.dbus_action.do_message( newusernames , arg) |
| | 428 | # if not result: |
| | 429 | # shared.error_msg ( _("Error while send message:\nReason: %s") %( self.main.dbus_action.get_error_msg() ) ) |
| | 430 | # self.main.ask_dragdrop.hide() |
| | 431 | # self.main.ask_fixed.hide() |
| | 432 | # self.main.image_entry.hide() |
| | 433 | # self.main.ask.hide() |
| | 434 | # self.main.ask_entry.set_text("") |
| | 435 | # dbus_action=None |
| | 436 | # self.ask_mode=None |
| | 437 | # return |
| 449 | | |
| 450 | | def populate_datatxt(self, ip): |
| 451 | | start1=time() |
| 452 | | print_debug ("populate_datatxt() INIT ip %s"%ip) |
| 453 | | |
| 454 | | if not self.main.xmlrpc.connected: |
| 455 | | print_debug ( "populate_datatxt(%s) NO CONNECTION" %(ip) ) |
| 456 | | crono(start1, "populate_datatxt(%s)" %(ip) ) |
| 457 | | return |
| 458 | | |
| 459 | | # dictionary with all data |
| 460 | | tcos_vars={} |
| 461 | | |
| 462 | | self.datatxt = self.main.datatxt |
| 463 | | |
| 464 | | # clear datatxt |
| 465 | | self.main.common.threads_enter("TcosActions:populate_datatxt clean datatxt") |
| 466 | | self.datatxt.clean() |
| 467 | | self.main.common.threads_leave("TcosActions:populate_datatxt clean datatxt") |
| 468 | | tcos_vars["get_client"] = self.main.xmlrpc.ReadInfo("get_client") |
| 469 | | print_debug ( "Client type=%s" %(tcos_vars["get_client"]) ) |
| 470 | | |
| 471 | | # print into statusbar |
| 472 | | self.main.common.threads_enter("TcosActions:populate_datatxt show progressbar") |
| 473 | | |
| 474 | | if shared.disable_textview_on_update and self.main.iconview.isactive(): |
| 475 | | self.main.tabla.set_sensitive(True) |
| 476 | | |
| 477 | | #self.main.write_into_statusbar( _("Connecting with %s to retrieve some info..." ) %(ip) ) |
| 478 | | |
| 479 | | self.main.progressbar.show() |
| 480 | | #self.main.progressbutton.show() |
| 481 | | self.set_progressbar( _("Connecting with %s to retrieve some info..." ) %(ip) , 0 ,show_percent=False) |
| 482 | | |
| 483 | | self.main.common.threads_leave("TcosActions:populate_datatxt show progressbar") |
| 484 | | |
| 485 | | |
| 486 | | info_percent=0.0 |
| 487 | | info_items=0 |
| 488 | | for elem in self.main.config.vars: |
| 489 | | # elem can have 2 or 3 elements (don't use key,value in for) |
| 490 | | key=elem[0] |
| 491 | | value=elem[1] |
| 492 | | if self.main.config.GetVar(key) == 1: |
| 493 | | info_items +=1 |
| 494 | | if info_items != 0: |
| 495 | | percent_step=float((100/info_items)) |
| 496 | | percent_step=percent_step/100 |
| 497 | | |
| 498 | | |
| 499 | | |
| 500 | | if self.main.config.GetVar("tcosinfo") == 1: |
| 501 | | info_percent+=percent_step |
| 502 | | self.main.common.threads_enter("TcosActions:populate_datatxt update progressbar") |
| 503 | | self.update_progressbar( info_percent ) |
| 504 | | self.main.common.threads_leave("TcosActions:populate_datatxt update progressbar") |
| 505 | | |
| 506 | | if tcos_vars["get_client"] == "tcos": |
| 507 | | self.datatxt.insert_block( _("Tcos info") , image=shared.IMG_DIR + "tcos-icon-32x32.png" ) |
| 508 | | |
| 509 | | elif tcos_vars["get_client"] == "pxes": |
| 510 | | self.datatxt.insert_block( _("PXES info") , image="/usr/share/pixmaps/pxesconfig/2X.png" ) |
| 511 | | |
| 512 | | elif tcos_vars["get_client"] == "ltsp": |
| 513 | | self.datatxt.insert_block( _("LTSP info") , image=shared.IMG_DIR + "ltsp_logo.png" ) |
| 514 | | |
| 515 | | elif tcos_vars["get_client"] == "standalone": |
| 516 | | self.datatxt.insert_block( _("Standalone info") , image=shared.IMG_DIR + "standalone.png" ) |
| 517 | | |
| 518 | | else: |
| 519 | | self.datatxt.insert_block( _("Unknow client info") ) |
| 520 | | |
| 521 | | tcos_vars["hostname"]=self.main.localdata.GetHostname(ip) |
| 522 | | tcos_vars["version"]=self.main.xmlrpc.GetVersion() |
| 523 | | |
| 524 | | if not tcos_vars["version"]: |
| 525 | | tcos_vars["version"]=_("unknow") |
| 526 | | |
| 527 | | self.datatxt.insert_list( [ |
| 528 | | [ _("Hostname: "), tcos_vars["hostname"] ] , \ |
| 529 | | [ _("Ip address: "), ip ] , \ |
| 530 | | [ _("TcosXmlRpc version: "), tcos_vars["version"] ] |
| 531 | | ] ) |
| 532 | | |
| 533 | | tcos_vars["tcos_version"]=self.main.xmlrpc.ReadInfo("tcos_version") |
| 534 | | tcos_vars["tcos_generation_date"]=self.main.xmlrpc.ReadInfo("tcos_generation_date") |
| 535 | | tcos_vars["tcos_date"]=self.main.xmlrpc.ReadInfo("tcos_date") |
| 536 | | tcos_vars["tcos_uptime"]=self.main.xmlrpc.ReadInfo("tcos_uptime") |
| 537 | | |
| 538 | | self.datatxt.insert_list( [ \ |
| 539 | | [_("Tcos image version: "), tcos_vars["tcos_version"] ], \ |
| 540 | | [_("Tcos image date: "), tcos_vars["tcos_generation_date"] ], \ |
| 541 | | [_("Date of thin client: "), tcos_vars["tcos_date"] ], |
| 542 | | [_("Uptime: "), tcos_vars["tcos_uptime"] ] |
| 543 | | ] ) |
| 544 | | |
| 545 | | |
| 546 | | |
| 547 | | if self.main.config.GetVar("kernelmodulesinfo") == 1: |
| 548 | | info_percent+=percent_step |
| 549 | | self.main.common.threads_enter("TcosActions:populate_datatxt update progressbar") |
| 550 | | self.update_progressbar( in |