Added first Code fragments for external display.
This commit is contained in:
parent
af69d2f16f
commit
7bcc8f0c18
|
@ -30,6 +30,27 @@ COLOR_MUCH = Fore.YELLOW + Style.BRIGHT
|
||||||
|
|
||||||
COLOR_RESET = Style.RESET_ALL
|
COLOR_RESET = Style.RESET_ALL
|
||||||
|
|
||||||
|
display_fifo = None
|
||||||
|
|
||||||
|
|
||||||
|
def print_display(s):
|
||||||
|
global display_fifo
|
||||||
|
"""
|
||||||
|
Comment out this return for now if you dont
|
||||||
|
want to use the display.
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
"""
|
||||||
|
if not display_fifo:
|
||||||
|
try:
|
||||||
|
display_fifo = open('/tmp/display', 'w')
|
||||||
|
except IOError:
|
||||||
|
display_fifo = None
|
||||||
|
return
|
||||||
|
display_fifo.write(s)
|
||||||
|
display_fifo.flush()
|
||||||
|
|
||||||
|
|
||||||
def clear():
|
def clear():
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
|
@ -71,6 +92,7 @@ def delay(what, seconds):
|
||||||
|
|
||||||
def warn_balance():
|
def warn_balance():
|
||||||
print('Kontostand im Minus, bitte Geld aufladen.')
|
print('Kontostand im Minus, bitte Geld aufladen.')
|
||||||
|
print_display('\e\x0cKontostand im Minus, bitte Geld aufladen.')
|
||||||
|
|
||||||
|
|
||||||
def error_page(message):
|
def error_page(message):
|
||||||
|
@ -122,6 +144,7 @@ class Status:
|
||||||
if self.logged_in():
|
if self.logged_in():
|
||||||
print('Eingeloggt als: %s%s%s' % (COLOR_SOME, self.login_name, COLOR_RESET))
|
print('Eingeloggt als: %s%s%s' % (COLOR_SOME, self.login_name, COLOR_RESET))
|
||||||
print()
|
print()
|
||||||
|
print_display('\e\x0cBenutzer: %10s' %self.login_name[:10])
|
||||||
if self.transfers:
|
if self.transfers:
|
||||||
initial_command, initial_balance = self.transfers[0]
|
initial_command, initial_balance = self.transfers[0]
|
||||||
|
|
||||||
|
@ -142,6 +165,7 @@ class Status:
|
||||||
print(COLOR_SOME + 'Committen nicht vergessen.' + COLOR_RESET)
|
print(COLOR_SOME + 'Committen nicht vergessen.' + COLOR_RESET)
|
||||||
else:
|
else:
|
||||||
print('Kontostand beträgt: %s%.2f Euro%s' % (COLOR_MUCH, self.balance, COLOR_RESET))
|
print('Kontostand beträgt: %s%.2f Euro%s' % (COLOR_MUCH, self.balance, COLOR_RESET))
|
||||||
|
print_display('Kontostand: %8.2f' % self.balance)
|
||||||
if self.balance < 0:
|
if self.balance < 0:
|
||||||
print()
|
print()
|
||||||
warn_balance()
|
warn_balance()
|
||||||
|
@ -149,6 +173,7 @@ class Status:
|
||||||
print(COLOR_MUCH + 'Bitte einloggen.' + COLOR_RESET)
|
print(COLOR_MUCH + 'Bitte einloggen.' + COLOR_RESET)
|
||||||
print()
|
print()
|
||||||
print('Scanne dazu deine ID-Karte mit dem Barcode-Leser.')
|
print('Scanne dazu deine ID-Karte mit dem Barcode-Leser.')
|
||||||
|
print_display("\e\x0cAnmeldung: Bitte ID-Karte scannen...")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def logged_in(self):
|
def logged_in(self):
|
||||||
|
@ -173,6 +198,7 @@ class Status:
|
||||||
try:
|
try:
|
||||||
command.run(self.login_name)
|
command.run(self.login_name)
|
||||||
except urllib2.HTTPError as e:
|
except urllib2.HTTPError as e:
|
||||||
|
print_display('\e\x0cFEHLER: Server Error%20s' % str(e)[:20])
|
||||||
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -344,8 +370,10 @@ def handle(line, status):
|
||||||
item = status.find(line)
|
item = status.find(line)
|
||||||
except urllib2.HTTPError as e:
|
except urllib2.HTTPError as e:
|
||||||
if e.code == 404: # URL not found == item not found with REST
|
if e.code == 404: # URL not found == item not found with REST
|
||||||
|
print_display('\e\x0cFEHLER:\nAktion/ware unbekannt')
|
||||||
error_page('FEHLER: Aktion oder Ware "%s" nicht bekannt' % line)
|
error_page('FEHLER: Aktion oder Ware "%s" nicht bekannt' % line)
|
||||||
else:
|
else:
|
||||||
|
print_display('\e\x0cFEHLER: Server Error%20s' % str(e)[:20])
|
||||||
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
||||||
else:
|
else:
|
||||||
status.buy(item)
|
status.buy(item)
|
||||||
|
@ -354,8 +382,10 @@ def handle(line, status):
|
||||||
status.login(line)
|
status.login(line)
|
||||||
except urllib2.HTTPError as e:
|
except urllib2.HTTPError as e:
|
||||||
if e.code == 404: # URL not found == user unknown
|
if e.code == 404: # URL not found == user unknown
|
||||||
|
print_display('\e\x0cFEHLER: Nutzer ist unbekannt: "%7s"' % line[:7])
|
||||||
error_page('FEHLER: Benutzer "%s" nicht bekannt' % line)
|
error_page('FEHLER: Benutzer "%s" nicht bekannt' % line)
|
||||||
else:
|
else:
|
||||||
|
print_display('\e\x0cFEHLER: Server Error%20s' % str(e)[:20])
|
||||||
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
||||||
except urllib2.URLError as e:
|
except urllib2.URLError as e:
|
||||||
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
||||||
|
@ -365,6 +395,8 @@ def main():
|
||||||
colorama.init()
|
colorama.init()
|
||||||
status = Status()
|
status = Status()
|
||||||
|
|
||||||
|
print_display("\x1b\x40Kassensystem \n startet...")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
clear()
|
clear()
|
||||||
status.dump()
|
status.dump()
|
||||||
|
@ -382,3 +414,4 @@ if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
print_display("\x1b\x40Goodbye!")
|
||||||
|
|
Loading…
Reference in New Issue