Changeset 2261
- Timestamp:
- Jul 25, 2016, 1:35:51 PM (5 years ago)
- Location:
- lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/etc/n4d/conf.d/MirrorManager
r2036 r2261 20 20 get_available_mirrors=anonymous,* 21 21 stopupdate=adm,admins 22 is_mirror_update=anonymous,* -
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/usr/share/lliurex-mirror/conf/llx13.json
r1957 r2261 1 1 { 2 "LLIUREX_ORIG":"lliurex.net/pandora" 2 3 "URL": "lliurex.net/pandora", 3 4 "ARCHITECTURES": [ "amd64", "i386"], -
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/usr/share/lliurex-mirror/conf/llx14.json
r2036 r2261 1 1 { 2 "LLIUREX_ORIG":"lliurex.net/platinum" 2 3 "URL": "lliurex.net/platinum", 3 4 "ARCHITECTURES": [ "amd64", "i386"], -
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/usr/share/lliurex-mirror/conf/llx15.json
r2036 r2261 1 1 { 2 "LLIUREX_ORIG":"lliurex.net/trusty" 2 3 "URL": "lliurex.net/trusty", 3 4 "ARCHITECTURES": [ "amd64", "i386"], -
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/usr/share/lliurex-mirror/conf/llx16.json
r2036 r2261 1 1 { 2 "LLIUREX_ORIG":"lliurex.net/xenial" 2 3 "URL": "lliurex.net/xenial", 3 4 "ARCHITECTURES": [ "amd64", "i386"], -
lliurex-mirror/trunk/fuentes/n4d-lliurex-mirror.install/usr/share/n4d/python-plugins/MirrorManager.py
r2137 r2261 16 16 from multiprocessing import Process 17 17 import socket 18 from urllib2 import urlopen 19 20 from datetime import datetime, date 18 21 19 22 … … 172 175 break 173 176 filelog.close() 177 178 self.download_time_file(distro) 179 174 180 self.set_mirror_info(distro) 175 181 … … 393 399 return {'status':False,'msg':str(e)} 394 400 401 402 def download_time_file(self,distro): 403 404 configpath = os.path.join(self.configpath,distro + ".json") 405 config = json.load(open(configpath,'r')) 406 path=config["MIRRORPATH"] 407 file="time-of-last-update" 408 dest=os.path.join(path,file) 409 410 orig_mirror=self.get_mirror_orig(distro) 411 url_mirror="http://"+os.path.join(orig_mirror['msg'],file) 412 413 return self.get_time_file(url_mirror,dest) 414 415 # def download_time_file 416 417 418 def get_time_file(self,url,dest): 419 420 try: 421 r=urlopen(url) 422 f=open(dest,"wb") 423 f.write(r.read()) 424 f.close() 425 r.close() 426 return {'status':True,'msg':dest + 'download sucessfull.'} 427 428 except Exception as e: 429 return {'status':False,'msg':'Error downloading' + dest + str(e)} 430 431 # def get_time_file 432 433 def is_mirror_update(self,distro): 434 435 configpath = os.path.join(self.configpath,distro + ".json") 436 config = json.load(open(configpath,'r')) 437 path=config["MIRRORPATH"] 438 file_time_name="time-of-last-update" 439 file_local_mirror=os.path.join(path,file_time_name) 440 441 442 if os.path.isfile(file_local_mirror): 443 url_pool="http://"+os.path.join(config["LLIUREX_ORIG"],file_time_name) 444 file_pool=os.path.join("/tmp",file_time_name) 445 446 exist_file_pool=self.get_time_file(url_pool,file_pool) 447 if exist_file_pool['status']: 448 file_local_mirror_content=open(file_miror,"r") 449 file_local_miror_datetime=(file_local_mirror_content.readline().strip()).split("_") 450 file_pool_content=open(file_pool,'r') 451 file_pool_datetime=(file_pool_content.readline().strip()).split("_") 452 file_local_mirror_content.close() 453 file_pool_content.close() 454 455 date_local_mirror=datetime.strptime(file_local_miror_datetime[0],"%Y/%m/%d") 456 date_pool=datetime.strptime(file_pool_datetime[0],"%Y/%m/%d") 457 458 if date_local_mirror==date_pool: 459 time_local_mirror=datetime.strptime(file_local_miror_datetime[1],"%H:%M") 460 time_pool=datetime.strptime(file_pool_datetime[1],"%H:%M") 461 462 if time_local_mirror<time_pool: 463 return {'status':False,'msg':'Mirror is not update','action': 'update'} 464 elif : 465 return {'status':True,'msg':'Mirror is update','action':'nothing'} 466 467 elif date_local_mirror<date_pool: 468 return {'status':False,'msg':'Mirror is not update','action': 'update'} 469 else: 470 return {'status':True,'msg':'Mirror is update','action':'nothing'} 471 else: 472 return {'status':False,'msg':exist_file_pool['msg'],'action':'nothing'} 473 474 else: 475 return {'status':False,'msg':file_local_mirror + 'dont exists.','action':'nothing'} 476 477 # def is_mirror_update
Note: See TracChangeset
for help on using the changeset viewer.