def get_groups(self): ''' ''' self._send_command('get-groups', []) msgs = self._get_messages() return unpack(msgs['groups'][0])
def build_transaction(self): ''' ''' self._send_command('build-transaction', []) msgs = self._get_messages() return msgs['return_code'][0], msgs['messages'], unpack(msgs['transaction'][0]), msgs['size']
def get_changelog(self, ident, num): ''' get an attribute of an package ''' self._send_command('get-changelog', [ident, str(num)]) args = self._get_result(':attr') if args: return unpack(args[0]) else: return None
def _gpg_check(self, value): """ yum download action progress message """ (po, userid, hexkeyid) = unpack(value) ok = self.gpg_check(po, userid, hexkeyid) if ok: self.child.sendline(":true") else: self.child.sendline(":false")
def get_attribute(self, ident, attr): ''' get an attribute of an package ''' self._send_command('get-attribute', [ident, attr]) args = self._get_result(':attr') if args: return unpack(args[0]) else: return None
def is_ended(self, cmd, args): ''' @param cmd: @param args: ''' if cmd == ':end': if args: self.end_state = unpack(args[0]) else: # no parameter to :end self.end_state = True return True else: return False
def parse_command(cmd, param): if cmd == "#run": parameters = unpack(param) print ":debug\tLAUNCHER - Starting : %s" % parameters rc = run(parameters) elif cmd == "#testrun": print ":debug\ttest running : %s" % param run(param) rc = True elif cmd == "#exit": rc = False else: print ":error\tunknown launcher command : %s" % cmd rc = False return rc
def _get_messages(self): ''' read a list of :msg commands from the server, until and :end command is received ''' msgs = {} while True: cmd, args = self._readline() if self.is_ended(cmd, args): break elif cmd == ':msg': msg_type = args[0] value = unpack(args[1]) if msg_type in msgs: msgs[msg_type].append(value) else: msgs[msg_type] = [value] return msgs
def _get_packed_list(self, result_cmd): ''' read a list of :hist commands from the server, until and :end command is received ''' data = [] while True: cmd, args = self._readline() if self.is_ended(cmd, args): break if cmd == None: # readline is locked: break elif not cmd == result_cmd: self.warning("_get_list unexpected command : %s (%s)" % (cmd, args)) else: elem = unpack(args[0]) data.append(elem) return data
def _get_history_pkgs(self): ''' read a list of :histpkg commands from the server, until and :end command is received ''' data = [] while True: cmd, args = self._readline() if self.is_ended(cmd, args): break if cmd == None: # readline is locked: break elif cmd == ':histpkg': po = unpack(args[0]) data.append(po) else: data.append(args) return data
def _yum_logger(self, msg): ''' unpack yum messages ''' msg = unpack(msg) self.yum_logger(msg)
def fatal(self, args): """ fatal backend error """ err = args[0] msg = unpack(args[1]) # Trigger the frontend fatal error handler self.frontend.handle_error(err, msg)
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))
def _yum_dnl(self, value): """ yum download action progress message """ (ftype, name, percent, cur, tot, fread, ftotal, ftime) = unpack(value) self.yum_dnl_progress(ftype, name, percent, cur, tot, fread, ftotal, ftime)
def _yum_rpm(self, value): """ yum rpm action progress message """ (action, package, percent, ts_current, ts_total) = unpack(value) self.yum_rpm_progress(action, package, percent, ts_current, ts_total)