Changeset 2043
- Timestamp:
- Jun 28, 2016, 11:53:32 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/usr/share/n4d/python-plugins/MirrorManager.py
r2042 r2043 34 34 self.percentage=(0,None) 35 35 self.webserverprocess = None 36 self.defaultmirrorinfo = {"status_mirror":"Ok","last_mirror_date":None,"mirror_size":0,"progress":0} 36 37 37 38 #def init … … 44 45 if self.variable==None: 45 46 try: 46 self.n4d_vars.add_variable("LLIUREXMIRROR",{ "internal":{}},"","Lliurex Mirror info variable","n4d-lliurex-mirror")47 self.n4d_vars.add_variable("LLIUREXMIRROR",{},"","Lliurex Mirror info variable","n4d-lliurex-mirror") 47 48 except Exception as e: 48 49 pass … … 50 51 if type(self.variable)!=type({}): 51 52 self.variable={} 52 self.variable["internal"]={} 53 54 if self.variable["internal"].has_key("status_mirror") and self.variable["internal"]["status_mirror"] == "Working": 55 if not self.update_thread.isAlive(): 56 self.variable["internal"]['status_mirror'] = "Error" 57 self.n4d_vars.set_variable("LLIUREXMIRROR",self.variable) 58 53 54 try: 55 for repo in self.get_available_mirrors()['msg']: 56 if self.variable.has_key(repo) and self.variable[repo].has_key("status_mirror") and self.variable[repo]["status_mirror"] == "Working": 57 if not self.update_thread.isAlive(): 58 self.variable[repo]["status_mirror"] = "Error" 59 self.n4d_vars.set_variable("LLIUREXMIRROR",self.variable) 60 except Exception as e: 61 pass 59 62 #def startup 60 63 … … 125 128 126 129 def _update(self,distro): 127 130 if not self.variable.has_key(distro): 131 self.variable[distro]=self.defaultmirrorinfo 128 132 # link config debmirror to correct path with distro name 129 self.variable[ "internal"]['status_mirror'] = "Working"133 self.variable[distro]['status_mirror'] = "Working" 130 134 self.n4d_vars.set_variable("LLIUREXMIRROR",self.variable) 131 135 filelog = open('/var/log/lliurex-mirror.log','w') … … 155 159 self.percentage=(self.percentage[0],status) 156 160 157 self.variable[ "internal"]['status_mirror'] = "Ok" if status == 0 else "Error"161 self.variable[distro]['status_mirror'] = "Ok" if status == 0 else "Error" 158 162 self.n4d_vars.set_variable("LLIUREXMIRROR",self.variable) 159 163 break 160 164 except Exception as e: 161 self.variable[ "internal"]['status_mirror'] = "Error"165 self.variable[distro]['status_mirror'] = "Error" 162 166 self.n4d_vars.set_variable("LLIUREXMIRROR",self.variable) 163 167 break … … 192 196 MIRROR_SIZE=self.get_size(mirrorpath) 193 197 194 self.variable[ "internal"]["last_mirror_date"]=MIRROR_DATE195 self.variable[ "internal"]["mirror_size"]=str(MIRROR_SIZE)196 self.variable[ "internal"]["progress"]=self.percentage[0]198 self.variable[distro]["last_mirror_date"]=MIRROR_DATE 199 self.variable[distro]["mirror_size"]=str(MIRROR_SIZE) 200 self.variable[distro]["progress"]=self.percentage[0] 197 201 198 202 print self.n4d_vars.set_variable("LLIUREXMIRROR",self.variable) … … 299 303 #def set_mirror_architecture 300 304 301 def get_percentage(self): 302 if not self.is_alive(): 303 return {'status':True,'msg':self.variable['internal']['progress']}; 304 return {'status':True,'msg':self.percentage} 305 def get_percentage(self,distro): 306 if self.variable.has_key(distro): 307 return {'status':True,'msg':self.variable[distro]['progress']} 308 else: 309 return {'status':False,'msg':'this repo nos has been configured'} 305 310 306 311 def build_debmirror_config(self,distro):
Note: See TracChangeset
for help on using the changeset viewer.