card close command

git-svn-id: svn+ssh://localhost/home/henryk/svn/cyberflex-shell/trunk@72 f711b948-2313-0410-aaa9-d29f33439f0b
This commit is contained in:
hploetz 2006-05-22 03:26:13 +00:00
parent ef5ff028a5
commit 8e845292bb
2 changed files with 17 additions and 1 deletions

View File

@ -154,3 +154,7 @@ class Card:
def get_protocol(self):
return ((self.card.status()["Protocol"] == pycsc.SCARD_PROTOCOL_T0) and (0,) or (1,))[0]
def close_card(self):
"Disconnect from a card"
del self.card # FIXME: anything else to do?

View File

@ -9,8 +9,20 @@ def cmd_atr(card, *args):
"""Print the ATR of the currently inserted card."""
print "ATR: %s" % utils.hexdump(card.card.status()['ATR'], short=True)
def cmd_close(card, *args):
"Close the connection to the currently inserted card"
shell.unregister_post_hook(_print_sw)
shell.fallback = None
shell.unregister_pre_hook(_clear_sw)
shell.unregister_pre_hook(_update_prompt)
shell.unregister_commands(card)
shell.unregister_commands(card, COMMANDS)
card.close_card()
shell.set_prompt("(No card) ")
COMMANDS = {
"atr": cmd_atr
"atr": cmd_atr,
"close_card": cmd_close,
}
def list_readers():