def Verify(self, *args, **kwargs):
if not self.open:
raise NotOpenError('Please, open the port first!')
screen = args[0]
y, x = screen.getmaxyx()
# screen.border(0)
# screen.addstr(0, 1, 'Enter the ID to check, or empty field to exit...'[:x-2], curses.A_STANDOUT)
curses.echo()
ret = [False, None]
while True:
screen.addstr(2, 2, '>>> ')
screen.clrtoeol()
screen.border(0)
screen.addstr(0, 1, 'Enter an ID to verify, or empty field to cancel...'[:x-2], curses.A_STANDOUT)
ID = screen.getstr(2, 6)
if ID.isdigit():
response = self._f.Verify(int(ID))
if response[0]['ACK']:
# screen.addstr(3, 2, 'ID in use!')
# screen.clrtoeol()
ret[0] = 'ID {0:d} verified'.format(ID)
break
else:
screen.addstr(3, 2, response[0]['Parameter'])
screen.clrtoeol()
elif ID.isalnum():
curses.noecho()
raise ValueError('Non-numeric value found!')
else:
break
curses.noecho()
return ret
评论列表
文章目录