~andreserl/testdrive-gtk/before-merge-2.7

« back to all changes in this revision

Viewing changes to bin/testdrivegtk

  • Committer: Andres Rodriguez
  • Date: 2010-07-03 02:24:57 UTC
  • Revision ID: andreserl@ubuntu.com-20100703022457-k6efn7cdvik9agq0
 * Preferences: Improvements on validating changes, and saving them. Only
   save when there are changes
 * Main UI: Minor improvements on interaction on syncing/launching. Others

Show diffs side-by-side

added added

removed removed

Lines of Context:
132
132
        def create_isos_interface(self):
133
133
                self.obtain_virt()
134
134
                isos = self.obtain_isos_list()
135
 
                self.td.set_ubuntu_release_codename(isos)
 
135
                if not self.td.r:
 
136
                        self.td.set_ubuntu_release_codename(isos)
136
137
                ISO = self.td.list_isos(isos)
137
138
                self.create_iso_menu(ISO)
138
139
 
148
149
                response = prefs.run()
149
150
                if response == gtk.RESPONSE_OK:
150
151
                        # Make any updates based on changed preferences here.
151
 
                        #TODO - TODO - TODO
152
 
                        # 1. If CACHE's variables are changed, need to call set_defaults to create new data paths.
153
 
                        #self.td.set_defaults()
154
 
                        # 2. If variables were unchanged, no need to recreate the UI
155
152
                        self.td = prefs.get_preferences()
156
153
                        self.notebook.destroy()
 
154
                        self.td.set_defaults()
157
155
                        self.create_isos_interface()
158
156
                        pass
159
157
                prefs.destroy()
160
158
 
161
159
        def open_file(self, widget, data=None):
 
160
                if commands.getstatusoutput("which testdrive")[0] != 0:
 
161
                        self.on_error_dialog(   "Unable to open because 'testdrive' is not installed.\n"
 
162
                                                "Please install testdrive: \n\n"
 
163
                                                "sudo apt-get install testdrive")
 
164
                        return
162
165
                title = 'TestDrive an ISO or Disk Image'
163
166
                filename = None
164
167
                testdrives = gtk.FileFilter()
497
500
                                        self.isos_to_run.remove(t)
498
501
        
499
502
        def on_sync_iso_clicked(self, widget, data=None):
 
503
                if not self.isos_to_run:
 
504
                        """
 
505
                        self.on_error_dialog(   "Unable to Sync. No ISOs has been selected.\n"
 
506
                                                "\n"
 
507
                                                "Please select an ISO to start syncing.")
 
508
                        """
 
509
                        return
500
510
                for t in self.isos_to_run:
501
 
                        if t[3] == None or t[3] != "launch":
 
511
                        #if t[3] == None or t[3] != "launch":
 
512
                        if t[0].p is None and t[1].p is None:
502
513
                                t[3] = "sync"
503
514
                                #t[1] = None
504
515
                                try:
506
517
                                        t[0].start()
507
518
                                except:
508
519
                                        pass
 
520
                        else:
 
521
                                print "@@@@@@@@@@@@@@@@@@@@@2Ya se esta ejecutando"
509
522
                """
510
523
                for iso in self.isos_to_run:
511
524
                        if iso["type"] != "launch" and iso["status"] != "running":
520
533
                """
521
534
 
522
535
        def on_launch_button_clicked(self, widget, data=None):
 
536
                if not self.isos_to_run:
 
537
                        """
 
538
                        self.on_error_dialog(   "Unable to Launch. No ISOs has been selected.\n"
 
539
                                                "\n"
 
540
                                                "Please select an ISO or ISOs to TestDrive!!")
 
541
                        """
 
542
                        return
523
543
                if self.td.VIRT == 'kvm':
524
544
                        for t in self.isos_to_run:
525
 
                                if t[3] == None or t[3] != "sync":
 
545
                                #if t[3] == None or t[3] != "sync":
 
546
                                if t[0].p is None and t[1].p is None:
526
547
                                        t[3] = "launch"
527
548
                                        #t[0] = None
528
549
                                        try:
529
550
                                                t[1].start()
530
551
                                        except:
531
552
                                                pass
 
553
                                else:
 
554
                                        print "@@@@@@@@@@2@@ Ya se esta ejecutando o esta syncronizando"
532
555
                else:
533
556
                        self.launch_vm()
534
557
                """
550
573
                """
551
574
 
552
575
        def on_create_iso_disk_clicked(self, widget, data=None):
553
 
                self.td.launch_usb_creator()
 
576
                if not self.isos_to_run:
 
577
                        """
 
578
                        self.on_error_dialog(   "Unable to Launch USB Creator. No ISO has been selected.\n"
 
579
                                                "\n"
 
580
                                                "Please select an ISO to create an USB Startup Disk.")
 
581
                        """
 
582
                        return
 
583
                self.p = subprocess.Popen(["usb-creator-gtk", "-i", self.td.PATH_TO_ISO])
 
584
                #self.td.launch_usb_creator()
554
585
 
555
586
        def launch_vm(self):
556
587
                # Launch the VM
589
620
                self.previous_text = label.get_text()
590
621
                self.command = cmd
591
622
                self.stopthread = threading.Event()
 
623
                self.p = None
592
624
 
593
625
        def run(self):
594
626
                i = 0
609
641
                        if self.p.poll() != None:
610
642
                                #self.pbar.hide()
611
643
                                self.status_label.set_text(self.previous_text)
 
644
                                self.p = None
612
645
                                break
613
646
                        text = "Downloading..."
614
647
                        gtk.gdk.threads_enter()
626
659
                                self.status_label.set_text(self.previous_text)
627
660
                except:
628
661
                        pass
 
662
                self.p = None
629
663
                self.stopthread.set()
630
664
 
631
665
class LaunchThread(threading.Thread):
635
669
                self.previous_text = label.get_text()
636
670
                self.command = cmd
637
671
                self.stopthread = threading.Event()
 
672
                self.p = None
638
673
 
639
674
        def run(self):
640
675
                i = 0
655
690
                        if self.p.poll() != None:
656
691
                                #self.pbar.hide()
657
692
                                self.status_label.set_text(self.previous_text)
 
693
                                self.p = None
658
694
                                break
659
695
                        text = "Running VM..."
660
696
                        gtk.gdk.threads_enter()
672
708
                                self.status_label.set_text(self.previous_text)
673
709
                except:
674
710
                        pass
 
711
                self.p = None
675
712
                self.stopthread.set()
676
713
 
677
714
if __name__ == "__main__":