Changeset 2957
- Timestamp:
- Nov 30, 2016, 1:46:08 PM (4 years ago)
- Location:
- lliurex-up/trunk/fuentes/lliurex-up-gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-up/trunk/fuentes/lliurex-up-gui/LliurexUpConnect.py
r2945 r2957 17 17 18 18 class LliurexUpConnect(): 19 """docstring for LliurexUpCore""" 19 20 20 def __init__(self): 21 21 self.llxUpCore=LliurexUpCore.LliurexUpCore() 22 22 GObject.threads_init() 23 self.status=True 24 log_msg="LLIUREX-UP STARTING AT: " + datetime.datetime.today().strftime("%d/%m/%y %H:%M:%S") 23 log_msg="------------------------------------------\n"+"LLIUREX-UP STARTING AT: " + datetime.datetime.today().strftime("%d/%m/%y %H:%M:%S") +"\n------------------------------------------" 25 24 self.log(log_msg) 26 25 27 26 #def __init__ 28 27 29 28 def getInitialFlavour(self): 30 29 31 self.init _flavours = [ x.strip() for x in self.llxUpCore.n4d.lliurex_version('','LliurexVersion','-v')[1].split(',') ]30 self.initFlavours = [ x.strip() for x in self.llxUpCore.n4d.lliurex_version('','LliurexVersion','-v')[1].split(',') ] 32 31 log_msg="Initial flavour: " 33 for line in self.init _flavours:32 for line in self.initFlavours: 34 33 log_msg=log_msg + " " + line 35 34 36 35 self.log(log_msg) 37 36 38 return self.init_flavours 39 37 return self.initFlavours 38 39 #def getInitialFlavour 40 40 41 41 def checkFlavour(self): 42 42 43 43 try: 44 targetMetapackage=self.llxupCore.checkFlavour()45 log_msg=" Metapackage to install: " + str(targetMetapackage)44 self.targetMetapackage=self.llxUpCore.checkFlavour() 45 log_msg="Initial check metapackage. Metapackage to install: " + str(self.targetMetapackage) 46 46 self.log(log_msg) 47 return self.targetMetapackage 47 48 48 49 except Exception as e: 49 log_msg=" Metapackage to install. Error: " + str(e)50 log_msg="Initial check metapackage. Metapackage to install. Error: " + str(e) 50 51 self.log(log_msg) 51 52 return None 52 53 54 #def checkFlavoour 55 56 57 def checkFinalFlavour(self): 58 59 self.finalFlavours = [ x.strip() for x in self.llxUpCore.n4d.lliurex_version('','LliurexVersion','-v')[1].split(',') ] 60 61 if self.targetMetapackage==None: 62 if self.initFlavours==self.finalFlavours: 63 log_msg="Final check metapackage. Metapackage to install: None" 64 self.log(log_msg) 65 return None 66 else: 67 log_msg="Final check metapackage. Metapackage to install: " +self.initFlavours 68 self.log(log_msg) 69 return self.initFlavours 70 else: 71 if self.targetMetapackage in self.finalFlavours: 72 log_msg="Final check metapackage. Metapackage to install: None" 73 self.log(log_msg) 74 return True 75 else: 76 log_msg="Final check metapackage. Metapackage to install: " +self.targetMetapackage 77 self.log(log_msg) 78 return self.targetMetapackage 79 80 81 #def checkFinalFlavour 82 53 83 54 84 def canConnectToLliurexNet(self): 85 55 86 try: 56 87 can_connect=self.llxUpCore.canConnectToLliurexNet() … … 62 93 return False 63 94 64 95 #def canConnectToLliurexNet 96 65 97 def isLliurexUpIsUpdated(self): 98 66 99 try: 67 100 is_lliurexup_updated=self.llxUpCore.isLliurexUpIsUpdated() 68 print is_lliurexup_updated69 101 log_msg="Checking lliurex-up. Is lliurex-up updated: "+ str(is_lliurexup_updated) 70 102 self.log(log_msg) … … 76 108 return True 77 109 78 110 #def isLliurexUpIsUpdated 111 79 112 def installLliurexUp(self): 113 80 114 try: 81 115 is_lliurexup_installed=self.llxUpCore.installLliurexUp() … … 89 123 return True 90 124 91 #return self.status125 #def installLliurexUp 92 126 93 127 94 def check_mirror(self): 128 def lliurexMirrorIsUpdated(self): 129 95 130 try: 96 131 is_mirror_updated=self.llxUpCore.lliurexMirrorIsUpdated() … … 101 136 return False 102 137 else: 103 log_msg="Checking mirror. Is mirror update: True"138 log_msg="Checking mirror. Is mirror update: " + is_mirror_updated['action'] 104 139 self.log(log_msg) 105 140 return True … … 110 145 return True 111 146 147 #def lliurexMirrorIsUpdated 112 148 113 149 def lliurexMirrorIsRunning(self): … … 122 158 return False 123 159 160 #def lliurexMirrorIsRunning 124 161 125 162 def getPercentageLliurexMirror(self): 163 126 164 try: 127 165 percentage_mirror=self.llxUpCore.getPercentageLliurexMirror() … … 134 172 return 0 135 173 174 #def getPercentageLliurexMirror 175 136 176 def getPackagesToUpdate(self): 137 177 … … 153 193 return packages_parse 154 194 155 195 #def getPackagesToUpdate 196 156 197 def log(self,msg): 198 157 199 log_file="/var/log/lliurex-up.log" 158 200 f=open(log_file,"a+") 159 201 f.write(msg + '\n') 160 f.close() 202 f.close() 203 204 #def log -
lliurex-up/trunk/fuentes/lliurex-up-gui/lliurex-up.py
r2945 r2957 15 15 from gi.repository import Gtk, Gdk, GdkPixbuf, GObject, GLib, PangoCairo, Pango, Vte 16 16 17 import commands18 import datetime19 from math import pi20 17 21 18 import LliurexUpConnect … … 88 85 #def parse_installed_icon 89 86 87 90 88 class LliurexUp: 91 89 … … 93 91 self.check_root() 94 92 self.llxup_connect=LliurexUpConnect.LliurexUpConnect() 95 self.init ial_flavour=self.llxup_connect.getInitialFlavour()93 self.initFlavours=self.llxup_connect.getInitialFlavour() 96 94 self.targetMetapackage=self.llxup_connect.checkFlavour() 97 self.start_gui()95 #self.start_gui() 98 96 99 97 … … 104 102 105 103 try: 106 print " checking root"104 print "Checking root" 107 105 f=open("/etc/lliurex-up.token","w") 108 106 f.close() … … 196 194 self.terminal_scrolled=builder.get_object("terminalScrolledWindow") 197 195 self.vterminal=Vte.Terminal() 196 self.vterminal.spawn_sync( 197 Vte.PtyFlags.DEFAULT, 198 os.environ['HOME'], 199 #["/usr/sbin/dpkg-reconfigure", "xdm"], 200 ["/bin/sh"], 201 [], 202 GLib.SpawnFlags.DO_NOT_REAP_CHILD, 203 None, 204 None, 205 ) 198 206 font_terminal = Pango.FontDescription("monospace normal 10") 199 207 self.vterminal.set_font(font_terminal) … … 311 319 312 320 self.package_list=[] 321 self.max_seconds=5.0 322 self.current_second=0 313 323 314 324 GObject.threads_init() … … 471 481 472 482 if self.check_lliurexup_t.done: 473 if not self.is_lliurexup_updated:483 if not self.is_lliurexup_updated: 474 484 if not self.install_lliurexup_t.is_alive() and not self.install_lliurexup_t.launched: 475 485 print "Updating lliurex-up" … … 481 491 if self.install_lliurexup_t.done: 482 492 print "Reboot lliurex-up" 483 msg_gather="<span><b>"+_("Lliurex-up is now updated and will be reboot")+"</b></span>" 484 self.gather_label.set_markup(msg_gather) 485 t=threading.Thread(target=self.reboot_me) 486 t.daemon=True 487 t.start() 488 return 493 #msg_gather="<span><b>"+_("Lliurex-up is now updated and will be reboot")+"</b></span>" 494 #self.pbar.hide() 495 #self.gather_label.set_markup(msg_gather) 496 #self.t=threading.Thread(target=self.reboot_lliurexup) 497 #self.pbar.hide() 498 self.msg_wait="<span><b>"+_("Lliurex-up is now updated and will be reboot in %s seconds...")+"</b></span>" 499 GLib.timeout_add(10,self.wait_to_reboot) 500 #self.t.daemon=True 501 #self.t.start() 502 return False 489 503 else: 490 504 if not self.check_mirror_t.is_alive() and not self.check_mirror_t.launched: … … 540 554 #def pulsate_checksystem 541 555 542 def reboot_me(self): 543 544 time.sleep(5) 545 os.execl(sys.executable, sys.executable, *sys.argv) 546 547 #def reboot_me 556 def wait_to_reboot(self): 557 558 csecond=int(self.max_seconds+1-self.current_second) 559 self.gather_label.set_markup(self.msg_wait%csecond) 560 self.pbar.set_fraction(self.current_second/self.max_seconds) 561 562 self.current_second+=0.01 563 564 if self.current_second>=self.max_seconds: 565 os.execl(sys.executable, sys.executable, *sys.argv) 566 return False 567 else: 568 return True 569 570 #def wait_to_reboot 571 572 # def reboot_lliurexup(self): 573 574 # time.sleep(5) 575 # os.execl(sys.executable, sys.executable, *sys.argv) 576 577 # #def reboot_me 548 578 549 579 def check_lliurexup_version(self): 550 580 551 time.sleep( 2)581 time.sleep(3) 552 582 self.is_lliurexup_updated=self.llxup_connect.isLliurexUpIsUpdated() 553 583 self.check_lliurexup_t.done=True … … 566 596 def check_mirror(self): 567 597 568 self.is_mirror_updated=self.llxup_connect. check_mirror()598 self.is_mirror_updated=self.llxup_connect.lliurexMirrorIsUpdated() 569 599 self.check_mirror_t.done=True 570 600 … … 589 619 self.pbar.show() 590 620 self.pbar_label.show() 591 print ("Updating mirror")621 print "Updating mirror" 592 622 self.updated_percentage(0) 593 623 #self.spinner.start() … … 688 718 print "System nor update" 689 719 720 self.requires_installing_metapackage() 690 721 self.parse_packages_updated() 691 722 self.populate_packages_tv() … … 718 749 719 750 self.version_available=None 720 if 'client' in self.init ial_flavouror self.targetMetapackage=='client':751 if 'client' in self.initFlavours or self.targetMetapackage=='client': 721 752 #self.version_available=_("Info not available for clients") 722 753 msg_version_available_info="<span foreground='#3366cc'><b>"+_("Info not available for clients")+"</b></span>" … … 803 834 def execute_scripts(self): 804 835 805 self.vterminal.spawn_sync(806 Vte.PtyFlags.DEFAULT,807 os.environ['HOME'],808 #["/usr/sbin/dpkg-reconfigure", "xdm"],809 ["/bin/sh"],810 [],811 GLib.SpawnFlags.DO_NOT_REAP_CHILD,812 None,813 None,814 )815 816 self.command='apt-get dist-upgrade -sV | tee /tmp/prueba999.txt\n'836 # self.vterminal.spawn_sync( 837 # Vte.PtyFlags.DEFAULT, 838 # os.environ['HOME'], 839 # #["/usr/sbin/dpkg-reconfigure", "xdm"], 840 # ["/bin/sh"], 841 # [], 842 # GLib.SpawnFlags.DO_NOT_REAP_CHILD, 843 # None, 844 # None, 845 # ) 846 847 self.command='apt-get dist-upgrade -sV\n' 817 848 print self.command 818 849 length=len(self.command) 819 850 self.vterminal.feed_child(self.command, length) 820 851 852 self.check_final_metapackage() 821 853 self.update_installed_icon("epoptes-client") 822 854 823 855 #def execute 824 856 … … 866 898 867 899 #def pulsate_pbar 900 901 902 def requires_installing_metapackage(self): 903 904 if self.targetMetapackage !=None: 905 print "Check Initial Metapackage. Instalation of metapackage is required" 906 907 else: 908 print "Check Initital Metapackage. Nothing to do" 909 910 911 def check_final_metapackage(self): 912 913 self.isMetapackageCorrect=self.llxup_connect.checkFinalFlavour() 914 915 if self.isMetapackageCorrect !=None: 916 print "Check Final Metapackage: Instalation of meta is required" 917 else: 918 print "Check Final Metapackage: Nothing to do" 919 920 868 921 869 922 def view_packages_clicked(self,widget,event): … … 985 1038 #class LliurexMirror 986 1039 987 at=LliurexUp() 1040 lup=LliurexUp() 1041 lup.start_gui() 1042 -
lliurex-up/trunk/fuentes/lliurex-up-gui/rsrc/lliurex-up.ui
r2945 r2957 256 256 <property name="visible">True</property> 257 257 <property name="can_focus">False</property> 258 <property name="margin_left"> 5</property>259 <property name="margin_right"> 5</property>258 <property name="margin_left">15</property> 259 <property name="margin_right">15</property> 260 260 <property name="margin_bottom">5</property> 261 261 </object> … … 548 548 <property name="opacity">0.97999999999999998</property> 549 549 <property name="halign">start</property> 550 <property name="margin_left"> 20</property>550 <property name="margin_left">10</property> 551 551 <property name="margin_top">5</property> 552 552 <property name="margin_bottom">5</property> … … 563 563 <property name="can_focus">False</property> 564 564 <property name="halign">start</property> 565 <property name="margin_left"> 20</property>565 <property name="margin_left">10</property> 566 566 <property name="margin_top">5</property> 567 567 <property name="margin_bottom">5</property> … … 579 579 <property name="can_focus">False</property> 580 580 <property name="halign">start</property> 581 <property name="margin_left"> 20</property>581 <property name="margin_left">10</property> 582 582 <property name="margin_top">5</property> 583 583 <property name="margin_bottom">5</property> … … 594 594 <property name="can_focus">False</property> 595 595 <property name="halign">start</property> 596 <property name="margin_left"> 20</property>596 <property name="margin_left">10</property> 597 597 <property name="margin_top">5</property> 598 598 <property name="margin_bottom">5</property> … … 649 649 <property name="halign">end</property> 650 650 <property name="valign">end</property> 651 <property name="margin_left"> 5</property>651 <property name="margin_left">15</property> 652 652 <property name="margin_right">10</property> 653 653 <property name="orientation">vertical</property>
Note: See TracChangeset
for help on using the changeset viewer.