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