예제 #1
0
 def execute_maint_script(self, script_name):
     '''
     execute a user-defined function
     script_name -- name of the function to run
     '''
     Package.execute_maint_script(self)
     script_path = "%s/%s.py" % (self.maint_dir, script_name)
     start_dir = get_slash_cwd()
     os.chdir(self.maint_dir)
     if not os.path.isfile(script_path):
         msg = "%s does not exist" % script_path
         raise BadPackage, (self.name, msg)
     sys.path.append(self.maint_dir )
     import_string = 'import %s' % script_name
     cmd = 'status = %s.execute(self.config, Logger)' % script_name
     job = Job(import_string, cmd, self.config)
     status = job.execute()
     sys.path.remove(self.maint_dir)
     os.chdir(start_dir)
     if status == None:
         status = OK
     if type(status) != type(1):
         msg = "Invalid status type (%s: '%s')"
         Logger.warning(msg % (type(status), status))
         status = FAIL
     return status
예제 #2
0
 def execute_maint_script(self, script_name, arguments):
     '''
     execute a user-defined function
     script_name -- name of the function to run
     arguments -- arguments to the script to be run
     '''
     Package.execute_maint_script(self, script_name)
     self.status = self._find_cmd(script_name, arguments=arguments)
     msg = "%s result for %s : %s"
     Logger.info(msg % (script_name, self.full_name, self.status))
     return self.status