dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/38884?usp=email )
Change subject: pySim-shell: change Prompt character to "#" after "verify_adm" ......................................................................
pySim-shell: change Prompt character to "#" after "verify_adm"
Let's change the prompt from ">" to "#" when the user gains admin privilegs using verify_adm.
Related: OS#6640 Change-Id: I957b9df7b5069b6fce5bf958c94e8ffda833c77f --- M pySim-shell.py 1 file changed, 13 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/84/38884/1
diff --git a/pySim-shell.py b/pySim-shell.py index 08f00f9..c05e552 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -109,6 +109,7 @@ self.py_locals = {'card': self.card, 'rs': self.rs, 'lchan': self.lchan} self.sl = sl self.ch = ch + self.adm_verified = False
self.numeric_path = False self.conserve_write = True @@ -218,18 +219,23 @@ self.cmd2.poutput("<- %s: %s" % (sw, resp))
def update_prompt(self): + if self.adm_verified: + prompt_char = '#' + else: + prompt_char = '>' + if self.lchan: path_str = self.lchan.selected_file.fully_qualified_path_str(not self.numeric_path) scp = self.lchan.scc.scp if scp: - self.prompt = 'pySIM-shell (%s:%02u:%s)> ' % (str(scp), self.lchan.lchan_nr, path_str) + self.prompt = 'pySIM-shell (%s:%02u:%s)%c ' % (str(scp), self.lchan.lchan_nr, path_str, prompt_char) else: - self.prompt = 'pySIM-shell (%02u:%s)> ' % (self.lchan.lchan_nr, path_str) + self.prompt = 'pySIM-shell (%02u:%s)%c ' % (self.lchan.lchan_nr, path_str, prompt_char) else: if self.card: - self.prompt = 'pySIM-shell (no card profile)> ' + self.prompt = 'pySIM-shell (no card profile)%c ' % prompt_char else: - self.prompt = 'pySIM-shell (no card)> ' + self.prompt = 'pySIM-shell (no card)%c ' % prompt_char
@cmd2.with_category(CUSTOM_CATEGORY) def do_intro(self, _): @@ -292,6 +298,7 @@ else: atr = self.rs.reset(self) self.poutput('Card ATR: %s' % atr) + self.adm_verified = False self.update_prompt()
class InterceptStderr(list): @@ -854,6 +861,8 @@ self._cmd.lchan.scc.verify_chv(adm_chv_num, h2b(pin_adm)) else: raise ValueError("error: cannot authenticate, no adm-pin!") + self._cmd.adm_verified = True + self._cmd.update_prompt()
def do_cardinfo(self, opts): """Display information about the currently inserted card"""