Changeset 6539
- Timestamp:
- Dec 22, 2017, 9:11:27 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-remote-installer/trunk/fuentes/lliurex-remote-installer-client.install/usr/share/n4d/python-plugins/LliurexRemoteInstallerClient.py
r6503 r6539 34 34 35 35 def __init__(self): 36 self.dbg= 136 self.dbg=0 37 37 if self.dbg==1: 38 38 print ("-----------------------------------------------------" ) … … 66 66 67 67 def startup(self,options): 68 68 69 if os.path.exists(self.file_sources): 69 70 os.remove(self.file_sources) 70 71 71 if options["boot"]: 72 if options["controlled"]: 73 if os.system("host server")==0: 74 try: 75 t=threading.Thread(target=self.test_system) 76 t.daemon=True 77 t.start() 78 except Exception as e: 79 print e 72 return True 73 # update process moved to lliurex-remote-installer-client.service in systemd 80 74 81 75 #def startup … … 102 96 try: 103 97 #Installed apps dict 104 dic t={}98 dic={} 105 99 for mod in mode: 106 dict[mod]=[] 107 COMMENT="[LLXRemoteInstallerClient] (create_dict) Dictionary is created %s"%(dict) 108 print COMMENT 100 dic[mod]=[] 101 COMMENT="[LLXRemoteInstallerClient] (create_dict) Dictionary is created %s"%(dic) 109 102 self._debug(COMMENT) 110 return [True,str(COMMENT),dict] 111 except Exception as e: 112 print e 103 return [True,str(COMMENT),dic] 104 except Exception as e: 113 105 return[False,str(e)] 114 106 #def_create_dict … … 116 108 def read_var (self,namevar=None,localhost=None): 117 109 try: 118 # if localhost in ["",None]:119 110 if not localhost: 120 111 proxy="https://server:9779" … … 134 125 self._debug("FNC: initialize_n4dvar") 135 126 try: 136 dic t={}127 dic={} 137 128 for x in list_dict: 138 dic t[x]={}129 dic[x]={} 139 130 if x == self.APT: 140 131 self._debug("Apt mode") 141 dic t[x]['lliurex']={}142 dic t[x]['lliurex'][self.LIST]=[]143 dic t[x]['lliurex'][self.URL]=[]144 else: 145 dic t[x][self.URL]=[]146 dic t[x][self.LIST]=[]132 dic[x]['lliurex']={} 133 dic[x]['lliurex'][self.LIST]=[] 134 dic[x]['lliurex'][self.URL]=[] 135 else: 136 dic[x][self.URL]=[] 137 dic[x][self.LIST]=[] 147 138 COMMENT=("[LLXRemoteInstallerClient] (initialize_n4dvar) Dict initialized") 148 139 self._debug(COMMENT) 149 print COMMENT 150 return [True,str(COMMENT),dict] 140 return [True,str(COMMENT),dic] 151 141 except Exception as e: 152 142 return [False,str(e)] … … 242 232 #def_add_list 243 233 244 def download(self, apps=[],url=None, dir=None):234 def download(self, apps=[],url=None,source_dir=None): 245 235 try: 246 236 #CREATE AUX_SOURCES IF IT'S NECESSARY 247 if not os.path.exists( dir):248 os.makedirs( dir)237 if not os.path.exists(source_dir): 238 os.makedirs(source_dir) 249 239 for app in apps: 250 file_app=str( dir)+"/"+app240 file_app=str(source_dir)+"/"+app 251 241 url_complete=str(url)+str(app) 252 if os.path.exists(file ):253 self._debug("(download) The FILE: "+file +" has been donwloaded before, it will be deleted now.")254 os.remove(file )242 if os.path.exists(file_app): 243 self._debug("(download) The FILE: "+file_app+" has been donwloaded before, it will be deleted now.") 244 os.remove(file_app) 255 245 self._debug("(download) The FILE: "+app+" is downloading now to directory "+file_app+" .....") 256 246 urllib.urlretrieve(url_complete,file_app) 257 247 os.chmod(file_app,0755) 258 248 259 COMMENT="Your FILES: %s has been downloaded in %s"%(apps, dir)249 COMMENT="Your FILES: %s has been downloaded in %s"%(apps,source_dir) 260 250 return [True,str(COMMENT)] 261 251 except Exception as e: … … 278 268 #NOW READ THE NEW SOURCES.LIST 279 269 sources=[] 280 file=open(self.file_sources)281 f= file.read().splitlines()270 sfile=open(self.file_sources) 271 f=sfile.read().splitlines() 282 272 for line in f: 283 273 sources.append(line) 284 file.close()274 sfile.close() 285 275 286 276 COMMENT="[LLXRemoteInstallerClient](repo_add) Your repo LLXRemoteInstallerClient has new lines %s"%sources … … 293 283 #def_repo_add 294 284 295 def repo_restore (self,f ile=None):285 def repo_restore (self,f=None): 296 286 self._debug("repo_restore") 297 287 try: 298 288 299 COMMENT="(repo_restore) Repo %s to test APT Aplications is deleted and restore to initial state"%f ile289 COMMENT="(repo_restore) Repo %s to test APT Aplications is deleted and restore to initial state"%f 300 290 self._debug(COMMENT) 301 if os.path.exists(f ile):302 os.remove(f ile)291 if os.path.exists(f): 292 os.remove(f) 303 293 self.repo_update() 304 294 #Delete proxy settings … … 372 362 #def repo_restore_config 373 363 374 def deb_solvedDependency (self,deb=None,l ist=[]):375 try: 376 for s in l ist:364 def deb_solvedDependency (self,deb=None,l=[]): 365 try: 366 for s in l: 377 367 name_deb=s[0] 378 368 version_deb=s[1] … … 491 481 #deb_install 492 482 493 def sh_install(self,list_sh=[], dir=""):483 def sh_install(self,list_sh=[],file_dir=""): 494 484 try: 495 485 list_ok=[] … … 497 487 for app in list_sh: 498 488 self._debug("(sh_install) Working with SCRIPT: "+app) 499 file_app=str( dir)+"/"+app489 file_app=str(file_dir)+"/"+app 500 490 if os.path.exists(file_app): 501 491 self._debug("(sh_install) Executing it, please wait..........") … … 963 953 #def test_system 964 954 965 def _manage_indicator_token(self, type,action):966 967 if type=="deb":968 f ile=os.path.join(self.dir_tmp,"llxremote_deb_token")969 elif type=="sh":970 f ile=os.path.join(self.dir_tmp,"llxremote_sh_token")971 elif type=="apt":972 f ile=os.path.join(self.dir_tmp,"llxremote_apt_token")955 def _manage_indicator_token(self,action_type,action): 956 957 if action_type=="deb": 958 f=os.path.join(self.dir_tmp,"llxremote_deb_token") 959 elif action_type=="sh": 960 f=os.path.join(self.dir_tmp,"llxremote_sh_token") 961 elif action_type=="apt": 962 f=os.path.join(self.dir_tmp,"llxremote_apt_token") 973 963 974 964 if action=="create": 975 965 self._debug("Create token to indicator") 976 966 try: 977 if not os.path.exists(f ile):978 tmp=open(f ile,'w')967 if not os.path.exists(f): 968 tmp=open(f,'w') 979 969 tmp.close() 980 970 except Exception as e: … … 984 974 self._debug("Delete token to indicator") 985 975 try: 986 if os.path.exists(f ile):987 os.remove(f ile)976 if os.path.exists(f): 977 os.remove(f) 988 978 except Exception as e: 989 979 self._debug("ERROR: "+str(e))
Note: See TracChangeset
for help on using the changeset viewer.