def search(self, keys, filters, show_newest_only, package_type): ''' @param keys: @param filters: ''' bKeys = pack(keys) bFilters = pack(filters) show_newest_only = pack(show_newest_only) pkgs = self.execute_command('search', [bKeys, bFilters, show_newest_only]) return self.filter_package_list(package_type, pkgs)
def get_update_info(self, ident, obsolete): self._send_command('update-info', [ident, pack(obsolete)]) msgs = self._get_messages() if 'updateinfo' in msgs and 'updated_po' in msgs: return msgs['updateinfo'], msgs['updated_po'] else: return (None, None)
def search_prefix(self, prefix, show_newest_only, package_type): ''' Search for packages with prefix @param prefix prefix to search for ''' show_newest_only = pack(show_newest_only) pkgs = self.execute_command('search-prefix', [prefix, show_newest_only]) return self.filter_package_list(package_type, pkgs)
def run_command(self, cmd, userlist): ''' ''' return self.execute_command('run-command', [cmd, pack(userlist)])
def set_option(self, option, value, on_repos=False): ''' get a list of packages based on pkg_filter ''' self._send_command('set-option', [option, pack(value), pack(on_repos)]) return self._get_return_code()
def search_history(self, pattern): ''' get a list of packages based on pkg_filter ''' self._send_command('search-history', [pack(pattern)]) tids = self._get_packed_list(result_cmd=':hist') return tids
def _launcher_cmd(self, cmd): param = pack(cmd) self._send_command("#run", [param])
def _media_change(self, value): """ media change signal """ (prompt_first, media_id, media_name, media_num) = unpack(value) mp = self.media_change(prompt_first, media_id, media_name, media_num) self.child.sendline(":mountpoint\t%s" % pack(mp))
# Client is not running any more # read messages in buffer and execute commands theend = self.child.read().split("\n") for line in theend: cmd, args = self._parse_command(line) if cmd: self._check_for_message(cmd, args) self.child.close() exitrc = self.child.exitstatus # default error if exitrc in BACKEND_ERRMSG: msg = BACKEND_ERRMSG[exitrc] else: msg = _('Backend not running as expected \n\nYum Extender will terminate\n --> exit code : %s\n') % exitrc args = ['backend-not-running', pack(msg)] #polkit releated errors if self.using_polkit: if exitrc == 127: args = ['polkit-not-autherized', pack(_('Could not get polkit autherisation to start backend \n\nYum Extender will terminate'))] elif exitrc == 126: args = ['polkit-user-cancel', pack(_('User has cancelled polkit autherisation\n\nYum Extender will terminate'))] self.fatal(args) return None,None def _check_for_message(self, cmd, args): ''' check if the command is a message and call the message handler if it is ''' if cmd == ':error':
self._timeout() if cmd: if self._check_for_message(cmd, args): continue else: self.waiting = False return cmd, args else: self.yum_logger(line.strip('\n')) except pexpect.TIMEOUT, e: # lint:ok self._timeout() continue # Client is not running any more exitrc = self.child.exitstatus # default error args = ['backend-not-running', pack(_('Backend not running as expected \n\nYum Extender will terminate\n --> exit code : %s') % exitrc)] #polkit releated errors if self.using_polkit: if exitrc == 127: args = ['backend-not-running', pack(_('Could not get polkit autherisation to start backend \n\nYum Extender will terminate'))] elif exitrc == 126: args = ['backend-not-running', pack(_('User has cancelled polkit autherisation\n\nYum Extender will terminate'))] self.fatal(args) def _check_for_message(self, cmd, args): ''' check if the command is a message and call the message handler if it is ''' if cmd == ':error': self.error(args[0])