Changeset 6001
- Timestamp:
- Oct 6, 2017, 1:02:05 PM (2 years ago)
- Location:
- lliurex-remote-installer/trunk/fuentes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lliurex-remote-installer/trunk/fuentes/lliurex-remote-installer-client.install/usr/share/n4d/python-plugins/LliurexRemoteInstallerClient.py
r4765 r6001 35 35 def __init__(self): 36 36 self.dbg=0 37 37 38 pass 38 39 #def __init__ … … 42 43 43 44 def _debug(self,message): 45 self._log(message) 44 46 if self.dbg==1: 45 47 print("RemoteInstallerClient: "+str(message)) … … 51 53 f=open (logFile,"a") 52 54 else: 55 #os.system(touch /tmp/remoteInstall.log) 53 56 f=open (logFile,"w") 54 57 f.write(str(message)+"\n") … … 78 81 dict[mod]=[] 79 82 COMMENT="[LLXRemoteInstallerClient] (create_dict) Dictionary is created %s"%(dict) 83 print COMMENT 80 84 self._debug(COMMENT) 81 85 return [True,str(COMMENT),dict] … … 118 122 COMMENT=("[LLXRemoteInstallerClient] (initialize_n4dvar) Dict initialized") 119 123 self._debug(COMMENT) 124 print COMMENT 120 125 return [True,str(COMMENT),dict] 121 126 except Exception as e: … … 643 648 date=datetime.datetime.now() 644 649 date_update=date.strftime("%d-%m-%Y %H:%M:%S") 645 print("[LLXRemoteInstallerClient](update_test) Actualizacion terminada...... %s"%date_update)650 self._debug("[LLXRemoteInstallerClient](update_test) Actualizacion terminada...... %s"%date_update) 646 651 if proc.returncode == 1: 647 print "[LLXRemoteInstallerClient](update_test) Fallo actulalizacion"652 self._debug("[LLXRemoteInstallerClient](update_test) Fallo actulalizacion") 648 653 else: 649 654 proc = subprocess.Popen('http_proxy=http://proxy:3128 /usr/sbin/lliurex-upgrade -u', shell=True, stdin=None, stdout=open("/dev/null", "w"), stderr=None, executable="/bin/bash") … … 651 656 date=datetime.datetime.now() 652 657 date_update=date.strftime("%d-%m-%Y %H:%M:%S") 653 print("[LLXRemoteInstallerClient](update_test) Actualizacion terminada...... %s"%date_update)658 self._debug("[LLXRemoteInstallerClient](update_test) Actualizacion terminada...... %s"%date_update) 654 659 if proc.returncode == 1: 655 print "[LLXRemoteInstallerClient](update_test) Fallo actulalizacion"660 self._debug("[LLXRemoteInstallerClient](update_test) Fallo actulalizacion") 656 661 657 662 updated="True" … … 686 691 url=appDict[source][self.URL] 687 692 apt_aux=[] 688 self._debug("( test_system) Checking if apt list is installed "+str(aux_list_apt))693 self._debug("(_refine_apt_repoList) Checking if apt list is installed "+str(aux_list_apt)) 689 694 for apt in aux_list_apt: 690 695 if apt not in dictOrig: 691 self._debug("( test_system) Must install APT: "+apt)696 self._debug("(_refine_apt_repoList) Must install APT: "+apt) 692 697 apt_aux.append(apt) 693 698 else: 694 self._debug("( test_system) "+apt+" is installed")699 self._debug("(_refine_apt_repoList) "+apt+" is installed") 695 700 #Add non installed debs to list 696 701 list_apt.extend(apt_aux) … … 725 730 self._debug("(test_system) New REPO has been added to your system") 726 731 if self.repo_update(): 727 self._debug("[LLXRemoteInstallerClient]( test_system) Your CACHE has been updated")732 self._debug("[LLXRemoteInstallerClient](apt_test) Your CACHE has been updated") 728 733 else: 729 734 # return [False,"failed repo_update"] … … 733 738 return result_apt 734 739 #Proceed with the list, repos are updated 735 self._debug("[LLXRemoteInstallerClient]( test_system) Calling apt_install with "+str(list_apt))740 self._debug("[LLXRemoteInstallerClient](apt_test) Calling apt_install with "+str(list_apt)) 736 741 result_apt=self.apt_install(list_apt)[2] 737 742 if result_apt: … … 742 747 self.repo_restore(self.file_sources) 743 748 else: 744 self._debug( "[LLXRemoteInstallerClient]( test_system) No apps installed")749 self._debug( "[LLXRemoteInstallerClient](apt_test) No apps installed") 745 750 result_apt=["","","","",""] 746 751 … … 755 760 if not dict_orig: 756 761 #Create dict if doesn't exists 757 self._debug("[LLXRemoteInstallerClient]( test_system) Creando el diccionario.......")762 self._debug("[LLXRemoteInstallerClient](_update_results) Creando el diccionario.......") 758 763 dict_new=self.create_dict ([self.APT,self.DEB,self.SH,self.UPDATE])[2] 759 764 dict_new[self.APT]=list(result_apt) … … 776 781 777 782 dict_new=dict_orig 778 log="[LLXRemoteInstallerClient]( test_system) Will add APT: %s ** DEBS: %s ** SH: %s ** UPDATE: %s "%(result_apt,result_deb[2],result_sh[2],result_update)783 log="[LLXRemoteInstallerClient](_update_results) Will add APT: %s ** DEBS: %s ** SH: %s ** UPDATE: %s "%(result_apt,result_deb[2],result_sh[2],result_update) 779 784 self._debug(log) 780 785 #Check the dict against a tuple … … 787 792 #Check values 788 793 if updated == 'True': 789 log="[LLXRemoteInstallerClient]( test_system) System has been updated to version: %s"%result_update['version']794 log="[LLXRemoteInstallerClient](_update_results) System has been updated to version: %s"%result_update['version'] 790 795 self._debug(log) 791 796 dict_new[self.UPDATE]=result_update 792 797 for valor_dict in dict_help: 793 self._debug("[LLXRemoteInstallerClient]( test_system) Test APP from: "+valor_dict)798 self._debug("[LLXRemoteInstallerClient](_update_results) Test APP from: "+valor_dict) 794 799 try: 795 800 for app_installed in dict_help[valor_dict]: 796 801 ok=False 797 self._debug("[LLXRemoteInstallerClient]( test_system) Check if app is installed: "+str(app_installed))802 self._debug("[LLXRemoteInstallerClient](_update_results) Check if app is installed: "+str(app_installed)) 798 803 for app_history in dict_orig[valor_dict]: 799 log="[LLXRemoteInstallerClient]( test_system) APP Installed: %s -- TESTING -- APP System: %s"%(app_installed,app_history)804 log="[LLXRemoteInstallerClient](_update_results) APP Installed: %s -- TESTING -- APP System: %s"%(app_installed,app_history) 800 805 self._debug(log) 801 806 if app_history == app_installed: 802 self._debug("[LLXRemoteInstallerClient]( test_system) App exists, don't add to dict")807 self._debug("[LLXRemoteInstallerClient](_update_results) App exists, don't add to dict") 803 808 ok=True 804 809 if not ok: 805 log="[LLXRemoteInstallerClient]( test_system) Adding app to list: %s"%app_installed810 log="[LLXRemoteInstallerClient](_update_results) Adding app to list: %s"%app_installed 806 811 self._debug(log) 807 812 dict_new[valor_dict].append(app_installed) 808 813 else: 809 log="[LLXRemoteInstallerClient]( test_system) App hasn't been added to dict: %s"%app_installed814 log="[LLXRemoteInstallerClient](_update_results) App hasn't been added to dict: %s"%app_installed 810 815 self._debug(log) 811 816 except Exception as e: … … 816 821 def test_system(self): 817 822 try: 818 823 logFile="/tmp/remoteInstall.log" 824 if os.path.exists(logFile): 825 f=open (logFile,"a") 826 f.write("\n") 827 f.write("\n") 828 f.write("-----------------------INIT--------------------\n") 829 f.close() 819 830 #Get installed apps dict 820 831 self.test_var(self.N4D_INSTALLED,"localhost") 821 832 dict_orig=self.read_var(self.N4D_INSTALLED,"localhost")[2] 822 833 #print dict_orig 823 834 #Get server dict 824 835 appDict=self.read_var(self.N4D_VAR)[2] 825 836 #Check the server's dict for install 826 # if appDict in ["",None,"None"]: 837 #if appDict in ["",None,"None"]: 838 #print appDict 827 839 if not appDict: 828 840 COMMENT="[LLXRemoteInstallerClient](test_system) Variable %s do not exist in your server, do nothing"%self.N4D_VAR 829 841 self._debug(COMMENT) 830 842 return [True,str(COMMENT)] 831 832 self._debug("[LLXRemoteInstallerClient] (test_system) The DICTIONARY to use is: "+str(dict)) 843 self._debug("[LLXRemoteInstallerClient] (test_system) The DICTIONARY to use is: "+str(appDict)) 833 844 self._debug("[LLXRemoteInstallerClient] (test_system) The DICTIONARY installed in your system is: "+str(dict_orig)) 845 834 846 dict_orig_aux=dict_orig 835 847 848 836 849 #TEST Debs 837 self._debug("Call deb_test") 850 self._debug("------------------------------------------------------------------") 851 self._debug("[LLXRemoteInstallerClient] (test_system) -----> call DEB_test") 838 852 result_deb=self.deb_test(appDict[self.DEB],dict_orig[self.DEB]) 853 self._debug("[LLXRemoteInstallerClient] (test_system) -----> end DEB_test <-----") 839 854 #TEST SH 840 self._debug("Call sh_test") 855 self._debug("------------------------------------------------------------------") 856 self._debug("[LLXRemoteInstallerClient] (test_system) -----> call SH_test") 841 857 result_sh=self.sh_test(appDict[self.SH],dict_orig[self.SH]) 858 self._debug("[LLXRemoteInstallerClient] (test_system) -----> end SH_test <-----") 842 859 #TEST Apt 843 self._debug("Call apt_test") 860 self._debug("------------------------------------------------------------------") 861 self._debug("[LLXRemoteInstallerClient] (test_system) -----> call APT_test") 844 862 result_apt=self.apt_test(appDict,dict_orig) 863 self._debug("[LLXRemoteInstallerClient] (test_system) -----> end APT_test <-----") 845 864 #TEST UPDATE 846 self._debug("Call update_test") 865 self._debug("------------------------------------------------------------------") 866 self._debug("[LLXRemoteInstallerClient] (test_system) -----> call UPDATE_test") 847 867 if appDict[self.UPDATE]['activate']=="True": 848 868 try: 849 869 result_update_vector=self.update_test(appDict,dict_orig) 870 #print result_update_vector 850 871 result_update=result_update_vector[0] 872 #print result_update 851 873 updated=result_update_vector[1] 874 #print updated 852 875 except Exception as e: 853 print e 876 print e,"appDict" 854 877 else: 855 878 result_update={'version':dict_orig[self.UPDATE]['version'],'url':dict_orig[self.UPDATE]['url'],'datetime':dict_orig[self.UPDATE]['datetime']} 856 879 updated="False" 857 self._debug("Updated is %s"%updated) 858 880 self._debug("[LLXRemoteInstallerClient] (test_system) Updated is necessary??? : %s"%updated) 881 print "Updated is %s"%updated 882 self._debug("[LLXRemoteInstallerClient] (test_system) -----> end UPDATE_test <---") 859 883 #Check that it's a list 860 884 sh_installed=list(result_sh[2]) … … 862 886 dict_new=self._update_results(dict_orig,result_deb,result_sh,result_apt,result_update,updated) 863 887 # if dict_orig in ["",None,{}]: 864 log="Dict now is %s"%dict_new 888 log="[LLXRemoteInstallerClient] (test_system) Dict now is %s"%dict_new 889 #print log 865 890 self._debug(log) 866 self._debug(" Updating N4D Variable.......")891 self._debug("[LLXRemoteInstallerClient] (test_system) Updating N4D Variable.......") 867 892 #Add installed apps to N4D 868 893 self.update_var_dict (self.N4D_INSTALLED,dict_new,"localhost") … … 872 897 COMMENT="The system has been configured with the APPS: %s * has executed the scripts: %s * Installed new DEBS: %s * Updated to: %s"%(result_apt,sh_installed,result_deb[2],result_update['version']) 873 898 self._debug(COMMENT) 899 #print COMMENT 874 900 return [True,str(COMMENT),result_apt,result_sh[2],result_deb[2],updated,dict_new] 875 901 except Exception as e: -
lliurex-remote-installer/trunk/fuentes/lliurex-remote-installer-server.install/usr/share/n4d/python-plugins/LliureXRemoteInstaller.py
r4752 r6001 241 241 exist=subprocess.Popen(["LANGUAGE=en_EN; apt-cache policy %s | grep -i candidate" %app],shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0] 242 242 print ("[LLXRemoteInstaller] (app_repo_exist) APP candidate in your repo is: %s"%exist) 243 if exist == None or exist == "":243 if exist in [ None, "None",none,"none",""]: 244 244 COMMENT="[LLXRemoteInstaller] (app_repo_exist) APP: %s doesn't exist in your repository, you can't add it to install list" %app 245 245 print ("%s" %COMMENT)
Note: See TracChangeset
for help on using the changeset viewer.