示例#1
0
    def runScripts(self, script_name):
        if self.config['applications']:
            for key in self.config['applications']:
                application_path = self.rootAndResolve(self.config['applications'][key]['path'])
                script = self.config['applications'][key][script_name]
                if script.get('path') is not None:
                    script_path = FileSystem.join(self.config['applications'][key]['path'], script['path'])
                    script_path = self.rootAndResolve(script_path)

                    if FileSystem.fileExists(script_path):
                        print('Running script', script_path)
                        if subprocess.call('cd '+application_path+' && '+script_path+' '+script['parameters'], shell=True):
                            print('Ran script successfully', script_path)
                        else:
                            print('Ran script but unsuccessfully', script_path)
                    else:
                        print('Failed to run a script; unavailable script', script_path)
                elif script.get('commands') is not None:
                    for command in script['commands']:
                        command = command.replace('{path}', application_path)
                        print('Running command "'+command+'"')
                        if subprocess.call('cd '+application_path+' && '+command, shell=True):
                            print('Ran command successfully', command)
                        else:
                            print('Ran command but unsuccessfully', command)
示例#2
0
 def loadCachedConfig(self):
     config_obj = {}
     cached_config_path = FileSystem.join(self.tmpCacheDir, self.configFileName)
     if FileSystem.fileExists(cached_config_path):
         print('File exists load config.')
         config_obj = self.parseConfig(cached_config_path)
         config_obj['init'] = False
     elif self.gitInitUrl:
         print('No cached configuration, download from github')
         if self.clone(self.gitInitUrl):
             config_obj = self.parseConfig(FileSystem.join(self.tmpRepoDir, self.configFileName))
         config_obj['init'] = True
     return config_obj