Changeset 2557
- Timestamp:
- Oct 5, 2016, 10:11:11 AM (4 years ago)
- Location:
- lliurex-mirror/trunk/fuentes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-mirror/trunk/fuentes/lliurex-mirror-gui/lliurex_mirror_connect.py
r2517 r2557 13 13 self.localport = None 14 14 self.remoteport = None 15 16 self.key_list=["NAME","ARCHITECTURES","CURRENT_UPDATE_OPTION","BANNER","DISTROS","SECTIONS","MIRROR_PATH","ORIGS","CHK_MD5","IGN_GPG","IGN_RELEASE"] 17 18 15 19 #def __init__ 20 16 21 17 22 def connect(self,server): … … 45 50 46 51 def mirror_list(self): 47 if type(self.client) == type(None): 52 try: 53 if type(self.client) == type(None): 54 return {} 55 result = self.client.get_all_configs(self.credentials,'MirrorManager') 56 if not result['status']: 57 return {} 58 return result['msg'] 59 except: 48 60 return {} 49 result = self.client.get_all_configs(self.credentials,'MirrorManager') 50 if not result['status']: 51 return {} 52 return result['msg'] 61 53 62 #def mirror_list 54 63 … … 58 67 except: 59 68 return {'status':False,'msg':None} 69 60 70 #def is_alive 61 71 62 72 def save_config(self,mirror,config): 63 result = self.client.update_mirror_config(self.credentials,'MirrorManager',mirror,config) 73 74 parsed_mirror={} 75 76 for key in self.key_list: 77 parsed_mirror[key]=config[key] 78 79 80 result = self.client.update_mirror_config(self.credentials,'MirrorManager',mirror,parsed_mirror) 64 81 return result 82 65 83 #def save_config 66 84 67 def create_conf (self,config):85 def create_config(self,config): 68 86 print config 69 87 if type(self.client) == type(None): … … 139 157 def is_alive_export(self): 140 158 result = self.localclient.is_alive_get_mirror(self.localcredentials,'MirrorManager') 141 printresult142 return result['status']159 return result 160 143 161 144 162 … … 148 166 return result['msg'] 149 167 #def get_percentage 168 169 def get_status(self,mirror): 170 171 try: 172 var=self.client.get_variable(self.credentials,"VariablesManager","LLIUREXMIRROR") 173 if var[mirror]["status_mirror"]=="Ok": 174 return {"status": True, "msg": None} 175 else: 176 return {"status": False, "msg": var[mirror]["exception_msg"]} 177 178 except Exception as e: 179 return {"status": False, "msg": str(e) } 180 181 #def get_status 150 182 151 183 def is_update_available(self,mirror): -
lliurex-mirror/trunk/fuentes/lliurex-mirror2/lliurex-mirror.py
r2518 r2557 13 13 import time 14 14 import math 15 import sys 15 16 from math import pi 17 import lliurex_mirror_connect 16 18 17 19 from gi.repository import Gtk, Gdk, GObject, GLib, PangoCairo, Pango,GdkPixbuf … … 33 35 ADD_IMAGE="rsrc/a1.png" 34 36 ADD_IMAGE_OVER="rsrc/a2.png" 37 TOKEN_FILE="/run/lliurex-mirror.pid" 35 38 36 39 class MirrorButton: … … 160 163 161 164 #def init 165 166 def check_root(self): 167 168 try: 169 170 f=open(TOKEN_FILE,"w") 171 f.write(str(os.getpid())) 172 f.close() 173 174 return True 175 176 except: 177 178 dialog = Gtk.MessageDialog(self.window, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.CANCEL, "Lliurex Mirror") 179 dialog.format_secondary_text("You need administration privileges to run this application.") 180 dialog.run() 181 sys.exit(1) 182 183 #def check_root 162 184 163 185 def start_gui(self): … … 397 419 398 420 399 400 401 421 self.window.add(self.stack) 422 423 self.check_root() 424 402 425 self.window.show_all() 403 426 self.ib.hide() … … 412 435 413 436 414 self.set_previous_values()415 416 self.parse_mirrors()437 #self.set_previous_values() 438 439 417 440 GObject.threads_init() 418 441 Gtk.main() … … 626 649 def set_mirror_info(self,mirror_button): 627 650 628 self.url_entry.set_text(mirror_button.info["LAST_URL"]) 651 652 ''' 653 "NAME": "", 654 "BANNER": "", 655 "ORIGS" : {"1":"lliruex.net/xenial","2":"","3":""}, 656 "ARCHITECTURES": [ "amd64", "i386"], 657 "SECTIONS": ["main", "main/debian-installer", "universe", "restricted", "multiverse", "partner"], 658 "MIRROR_PATH": "/net/mirror/llx16", 659 "DISTROS": ["xenial","xenial-updates","xenial-security"], 660 "IGN_GPG":1, 661 "IGN_RELEASE":0, 662 "CHK_MD5":0, 663 "CURRENT_UPDATE_OPTION":"1" 664 ''' 665 666 self.url_entry.set_text(mirror_button.info["ORIGS"]["3"]) 629 667 if len(mirror_button.info["NAME"]) < 22 : 630 668 self.mirror_name_label.set_text(mirror_button.info["NAME"]) … … 643 681 self.arch_label.set_text(", ".join(mirror_button.info["ARCHITECTURES"])) 644 682 645 if mirror_button.info["LAST_UPDATE_OPTION"]==1: 646 self.internet_rb.set_active(True) 647 648 if mirror_button.info["LAST_UPDATE_OPTION"]==2: 649 self.local_folder_rb.set_active(True) 650 651 if mirror_button.info["LAST_UPDATE_OPTION"]==3: 683 self.internet_rb.set_active(True) 684 685 #if mirror_button.info["CURRENT_UPDATE_OPTION"]=="2": 686 # self.local_folder_rb.set_active(True) 687 688 if mirror_button.info["CURRENT_UPDATE_OPTION"]=="3": 652 689 self.url_rb.set_active(True) 653 690 … … 665 702 666 703 667 self.origin_entry.set_text(mirror_button.info[" LLIUREX_ORIG"])704 self.origin_entry.set_text(mirror_button.info["ORIGS"]["1"]) 668 705 self.distributions_entry.set_text(", ".join(mirror_button.info["DISTROS"])) 669 706 self.sections_entry.set_text(", ".join(mirror_button.info["SECTIONS"])) 670 707 self.i386_cb.set_active("i386" in mirror_button.info["ARCHITECTURES"]) 671 708 self.amd64_cb.set_active("amd64" in mirror_button.info["ARCHITECTURES"]) 672 self.mirror_path_entry.set_text(mirror_button.info["MIRROR PATH"])709 self.mirror_path_entry.set_text(mirror_button.info["MIRROR_PATH"]) 673 710 674 711 self.check_md5_cb.set_active(mirror_button.info["CHK_MD5"]==1) … … 679 716 680 717 self.current_mirror=mirror_button 718 681 719 682 720 … … 701 739 self.export_label_box.set_name("CANCEL_BUTTON") 702 740 703 741 742 ''' 743 if "2.5" in self.current_mirror.info["ORIGS"]: 744 745 if self.current_mirror.info["ORIGS"]["2.5"]!="": 746 self.folder_fcb.set_filename(self.current_mirror.info["ORIGS"]["2.5"]) 747 self.local_folder_label.set_text(self.current_mirror.info["ORIGS"]["2.5"]) 748 else: 749 self.folder_fcb.set_filename(os.environ["HOME"]) 750 self.local_folder_label.set_text(os.environ["HOME"]) 751 ''' 752 753 754 self.destination_fcb.set_filename(os.environ["HOME"]) 755 self.destination_label.set_text(os.environ["HOME"]) 756 757 704 758 705 759 return True … … 709 763 710 764 def parse_mirrors(self): 711 765 ''' 712 766 self.mirrors={} 713 767 … … 741 795 742 796 return True 797 ''' 798 799 self.mirrors=self.llx_conn.mirror_list() 800 801 print self.mirrors["mippa"] 802 803 mirror_key=self.llx_conn.is_alive() 804 805 for key in self.mirrors: 806 807 m=MirrorButton(self.mirrors[key]) 808 m.info["KEY"]=key 809 if key==mirror_key["msg"] and mirror_key["status"]: 810 m.info["executing"]=True 811 m.info["updating"]=True 812 self.updating_mirror=m 813 814 GLib.timeout_add(20,self.update_ys) 815 GLib.timeout_add(10000,self.update_percentage) 816 GLib.timeout_add(10,self.update_degree) 817 818 GLib.timeout_add(5,self.update_mirror_button_animation,self.updating_mirror) 819 self.export_label_box.set_name("DISABLED_BUTTON") 820 821 822 823 self.add_mirror_button(m) 824 825 return True 826 743 827 744 828 #def parse_mirrors … … 812 896 info={} 813 897 814 info["LAST_URL"]=""815 898 info["NAME"]="" 816 899 info["ARCHITECTURES"]="" 817 info[" LAST_UPDATE_OPTION"]=""900 info["CURRENT_UPDATE_OPTION"]="" 818 901 info["BANNER"]="" 819 info["LLIUREX_ORIG"]=""820 902 info["DISTROS"]="" 821 903 info["SECTIONS"]="" 822 info["MIRRORPATH"]="" 904 info["MIRROR_PATH"]="" 905 info["ORIGS"]={} 906 info["ORIGS"]["1"]="" 907 info["ORIGS"]["2"]="" 908 info["ORIGS"]["3"]="" 823 909 info["CHK_MD5"]="" 824 910 info["IGN_GPG"]="" … … 954 1040 print "Update clicked" 955 1041 1042 mode="1" 1043 data=None 1044 956 1045 self.current_mirror.info["cancelled"]=False 957 1046 … … 970 1059 if self.local_folder_rb.get_active(): 971 1060 print "LOCAL_FOLDER: %s"%self.folder_fcb.get_filename() 1061 mode="2" 1062 data=self.folder_fcb.get_filename() 1063 self.current_mirror.info["ORIGS"]["2"]=data 1064 972 1065 973 1066 if self.url_rb.get_active(): 974 1067 print "URL: %s"%self.url_entry.get_text() 975 1068 mode="3" 1069 data=self.url_entry.get_text() 1070 self.current_mirror.info["ORIGS"]["3"]=data 1071 1072 self.current_mirror.info["CURRENT_UPDATE_OPTION"]=mode 976 1073 977 1074 if not self.current_mirror.info["executing"]: 978 1075 979 1076 self.percentage=0 1077 self.progress_label.set_text("") 1078 GLib.idle_add(self.ib.hide) 980 1079 self.updating_mirror=self.current_mirror 981 1080 self.current_mirror.info["updating"]=True … … 983 1082 self.current_mirror.info["cancelled"]=False 984 1083 GLib.timeout_add(20,self.update_ys) 985 GLib.timeout_add(100 ,self.update_percentage)1084 GLib.timeout_add(10000,self.update_percentage) 986 1085 GLib.timeout_add(10,self.update_degree) 987 1086 1087 #print c.update('mippa','3','172.20.8.6/mirror/ppa-xenial') 1088 #print c.update('mippa','2','/home/mirror-ppa-otracarpeta') 1089 #print c.update('mippa','1') 1090 1091 self.llx_conn.update(self.current_mirror.info["KEY"],mode,data) 988 1092 989 1093 GLib.timeout_add(5,self.update_mirror_button_animation,self.updating_mirror) … … 994 1098 995 1099 else: 1100 1101 self.llx_conn.stop_update() 996 1102 997 1103 self.updating_mirror.info["updating"]=False … … 1074 1180 GLib.timeout_add(10,self.update_degree) 1075 1181 1182 self.llx_conn.export(self.current_mirror.info["KEY"],self.destination_fcb.get_filename()) 1183 1184 GLib.timeout_add(5,self.update_mirror_button_animation,self.updating_mirror) 1185 1076 1186 1077 1187 GLib.timeout_add(5,self.update_mirror_button_animation,self.updating_mirror) … … 1155 1265 self.label_image1.queue_draw() 1156 1266 1157 1158 self.current_mirror.info["LLIUREX_ORIG"]=self.origin_entry.get_text() 1267 self.current_mirror.info["ORIGS"]={} 1268 self.current_mirror.info["ORIGS"]["1"]=self.origin_entry.get_text() 1269 self.current_mirror.info["ORIGS"]["2"]="" 1270 self.current_mirror.info["ORIGS"]["3"]="" 1159 1271 1160 1272 self.current_mirror.info["DISTROS"]=[] … … 1176 1288 self.current_mirror.info["ARCHITECTURES"].append("amd64") 1177 1289 1178 self.current_mirror.info["MIRROR PATH"]=self.mirror_path_entry.get_text()1290 self.current_mirror.info["MIRROR_PATH"]=self.mirror_path_entry.get_text() 1179 1291 1180 1292 self.current_mirror.info["IGN_GPG"]=0 … … 1201 1313 1202 1314 self.add_flag=False 1315 1316 key=self.llx_conn.create_config(self.current_mirror.info) 1317 self.current_mirror.info["KEY"]=key 1318 1319 else: 1320 1321 self.llx_conn.save_config(self.current_mirror.info["KEY"],self.current_mirror.info) 1322 1203 1323 1204 1324 #def save_button_clicked … … 1298 1418 self.server_ip="localhost" 1299 1419 1420 1421 self.user="kbut" 1422 self.password="lliurex" 1423 1300 1424 self.login_animation_r=60 1301 1425 self.login_form_sensitive() … … 1324 1448 self.stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE) 1325 1449 self.stack.set_visible_child_name("main") 1450 self.llx_conn=lliurex_mirror_connect.LliurexMirrorN4d(self.server_ip,(self.user,self.password)) 1451 self.parse_mirrors() 1326 1452 1327 1453 def update_mirror_button_animation(self,mirror_button): … … 1330 1456 1331 1457 if self.updating_mirror.info["executing"]: 1458 mirror_button.info["da"].queue_draw() 1332 1459 return True 1333 1460 … … 1349 1476 1350 1477 return True 1478 1479 1351 1480 1352 1481 … … 1357 1486 def update_percentage(self): 1358 1487 1359 if self.updating_mirror.info["executing"]: 1360 1361 if self.percentage<99: 1362 self.percentage+=0.5 1363 else: 1364 self.percentage=0 1365 1366 if self.current_mirror==self.updating_mirror and self.updating_mirror.info["executing"]: 1367 1368 self.progress_label.set_text(str(self.percentage) + "%") 1369 1488 if self.updating_mirror.info["updating"]: 1489 ret=self.llx_conn.is_alive() 1490 self.percentage=self.llx_conn.get_percentage(self.updating_mirror.info["KEY"]) 1491 if self.updating_mirror.info["exporting"]: 1492 ret=self.llx_conn.is_alive_export() 1493 self.percentage=self.llx_conn.get_percentage_export() 1494 1495 print ret 1496 1497 self.progress_label.set_text(str(self.percentage) + "%") 1498 1499 if self.percentage>=100: 1500 1501 self.updating_mirror.info["executing"]=False 1502 self.updating_mirror.info["updating"]=False 1503 self.updating_mirror.info["exporting"]=False 1504 self.export_label_box.set_name("BUTTON_COLOR") 1505 self.update_label_box.set_name("BUTTON_COLOR") 1506 1507 self.update_label.set_text("Update") 1508 self.export_label.set_text("Export") 1509 1510 1511 if ret["status"]: 1370 1512 return True 1513 else: 1514 if not self.updating_mirror.info["cancelled"]: 1515 ret=self.llx_conn.get_status(self.updating_mirror.info["KEY"]) 1516 if ret["status"]: 1517 pass 1518 else: 1519 error="Error:\n" 1520 1521 error+=ret["msg"].lstrip().rstrip() 1522 self.set_info_text(error,Gtk.MessageType.ERROR) 1523 1524 self.updating_mirror.info["executing"]=False 1525 self.updating_mirror.info["updating"]=False 1526 self.updating_mirror.info["exporting"]=False 1527 self.updating_mirror.info["cancelled"]=True 1528 self.export_label_box.set_name("BUTTON_COLOR") 1529 self.update_label_box.set_name("BUTTON_COLOR") 1530 self.update_label.set_text("Update") 1531 self.export_label.set_text("Export") 1532 1371 1533 1372 1534 #def update_percentage … … 1749 1911 1750 1912 lm=LliurexMirror() 1751 1752 1913 lm.start_gui()
Note: See TracChangeset
for help on using the changeset viewer.