|
|
|
@ -42,7 +42,6 @@ display_fifo = None
|
|
|
|
|
scroll_line1 = None
|
|
|
|
|
scroll_line2 = None
|
|
|
|
|
|
|
|
|
|
idlemessage = None
|
|
|
|
|
|
|
|
|
|
offset_line1 = 0
|
|
|
|
|
offset_line2 = 0
|
|
|
|
@ -56,19 +55,6 @@ SCREENSAVER_OFF = 2* 10*60
|
|
|
|
|
|
|
|
|
|
lock = allocate_lock()
|
|
|
|
|
|
|
|
|
|
def send_display(s):
|
|
|
|
|
global myDisplay
|
|
|
|
|
# myDisplay.write(s,False)
|
|
|
|
|
|
|
|
|
|
#Front-End Funtion to display a Screen
|
|
|
|
|
# with heading
|
|
|
|
|
def display_screen(title,message):
|
|
|
|
|
myDisplay.display_screen(title,message)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Front-End function to send data to the display.
|
|
|
|
|
def print_display(s):
|
|
|
|
|
myDisplay.write(s,False)
|
|
|
|
|
|
|
|
|
|
def clear():
|
|
|
|
|
os.system('clear')
|
|
|
|
@ -165,7 +151,7 @@ class Status:
|
|
|
|
|
if self.logged_in():
|
|
|
|
|
print('Eingeloggt als: %s%s%s' % (COLOR_SOME, self.login_name, COLOR_RESET))
|
|
|
|
|
print()
|
|
|
|
|
print_display('\x0cHallo %-14s' % (self.login_name[:13]+"!") )
|
|
|
|
|
myDisplay.write('\x0cHallo %-14s' % (self.login_name[:13]+"!") )
|
|
|
|
|
if self.transfers:
|
|
|
|
|
initial_command, initial_balance = self.transfers[0]
|
|
|
|
|
|
|
|
|
@ -197,11 +183,11 @@ class Status:
|
|
|
|
|
mylabel="Pfand "+command.commodity_label()[:9]
|
|
|
|
|
if (mycmd==3):
|
|
|
|
|
mylabel=("%-13s" % (command.commodity_label()[:13]))+"+P"
|
|
|
|
|
print_display('\x0b%-15s %4.2f' % (asciify(mylabel)[:15],abs(command.difference())));
|
|
|
|
|
print_display('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
|
|
|
|
|
myDisplay.write('\x0b%-15s %4.2f' % (asciify(mylabel)[:15],abs(command.difference())));
|
|
|
|
|
myDisplay.write('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
|
|
|
|
|
else:
|
|
|
|
|
print_display('\x0b%-15s %4.2f' % (command.label()[:15],abs(command.difference())));
|
|
|
|
|
print_display('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
|
|
|
|
|
myDisplay.write('\x0b%-15s %4.2f' % (command.label()[:15],abs(command.difference())));
|
|
|
|
|
myDisplay.write('\x0b\nSUMME: {%02i} %8.2f' % ((i-1),initial_balance - self.balance));
|
|
|
|
|
|
|
|
|
|
if len(self.transfers) > 1:
|
|
|
|
|
show_total(self.balance - initial_balance, plus='+')
|
|
|
|
@ -210,13 +196,13 @@ class Status:
|
|
|
|
|
|
|
|
|
|
if self.balance < 0:
|
|
|
|
|
warn_balance()
|
|
|
|
|
print_display('\x0b\nKonto: %5.2f!' % (self.balance) )
|
|
|
|
|
myDisplay.write('\x0b\nKonto: %5.2f!' % (self.balance) )
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
print(COLOR_MUCH + 'Committen nicht vergessen.' + COLOR_RESET)
|
|
|
|
|
else:
|
|
|
|
|
print('Kontostand beträgt: %s%.2f Euro%s' % (COLOR_MUCH, self.balance, COLOR_RESET))
|
|
|
|
|
display_screen("KONTOSTAND","%s: %.2f Euro" % (self.login_name,self.balance))
|
|
|
|
|
myDisplay.display_screen("KONTOSTAND","%s: %.2f Euro" % (self.login_name,self.balance))
|
|
|
|
|
if self.balance < 0:
|
|
|
|
|
print()
|
|
|
|
|
warn_balance()
|
|
|
|
@ -224,7 +210,7 @@ class Status:
|
|
|
|
|
print(COLOR_MUCH + 'Bitte einloggen.' + COLOR_RESET)
|
|
|
|
|
print()
|
|
|
|
|
print('Scanne dazu deine ID-Karte mit dem Barcode-Leser.')
|
|
|
|
|
display_screen("LOGIN","Bitte scanne Deinen login-Token! *** ")
|
|
|
|
|
myDisplay.display_screen("LOGIN","Bitte scanne Deinen login-Token! *** ")
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
def logged_in(self):
|
|
|
|
@ -253,7 +239,7 @@ class Status:
|
|
|
|
|
try:
|
|
|
|
|
command.run(self.login_name)
|
|
|
|
|
except urllib2.HTTPError as e:
|
|
|
|
|
print_display('\x0cFEHLER: Server Error%20s' % str(e)[:20])
|
|
|
|
|
myDisplay.write('\x0cFEHLER: Server Error%20s' % str(e)[:20])
|
|
|
|
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
|
|
|
|
break
|
|
|
|
|
else:
|
|
|
|
@ -336,11 +322,11 @@ class Status:
|
|
|
|
|
error_page(_PRODUCT_FIRST)
|
|
|
|
|
return
|
|
|
|
|
if prev.includes_deposit():
|
|
|
|
|
print_display('\x0cFEHLER: schon Pfand %20s' % prev.item_name()[:20])
|
|
|
|
|
myDisplay.write('\x0cFEHLER: schon Pfand %20s' % prev.item_name()[:20])
|
|
|
|
|
error_page('FEHLER: Pfand für Produkt "%s" bereits aktiviert' % prev.item_name())
|
|
|
|
|
return
|
|
|
|
|
if prev.deposit_value() <= 0:
|
|
|
|
|
print_display('\x0cFEHLER: Pfandfrei! %20s' % prev.item_name()[:20])
|
|
|
|
|
myDisplay.write('\x0cFEHLER: Pfandfrei! %20s' % prev.item_name()[:20])
|
|
|
|
|
error_page('FEHLER: Produkt "%s" hat kein Pfand' % prev.item_name())
|
|
|
|
|
return
|
|
|
|
|
before = prev.difference()
|
|
|
|
@ -382,14 +368,13 @@ def print_prompt():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle(line, status):
|
|
|
|
|
global idlemessage
|
|
|
|
|
if line == 'exit':
|
|
|
|
|
clear()
|
|
|
|
|
print_display("\x0c")
|
|
|
|
|
myDisplay.write("\x0c")
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
if status.logged_in():
|
|
|
|
|
idlemessage=" Comitten nicht vergessen! ***"
|
|
|
|
|
myDisplay.setIdlemessage(" Comitten nicht vergessen! ***")
|
|
|
|
|
if line in CODES:
|
|
|
|
|
call = CODES[line]
|
|
|
|
|
method = call[0]
|
|
|
|
@ -400,27 +385,27 @@ def handle(line, status):
|
|
|
|
|
item = status.find(line)
|
|
|
|
|
except urllib2.HTTPError as e:
|
|
|
|
|
if e.code == 404: # URL not found == item not found with REST
|
|
|
|
|
print_display('\x0cERROR: %13sCode ist unbekannt' % ( line[:13]))
|
|
|
|
|
myDisplay.display_screen("FEHLER","Code ist unbekannt: '%s'" % ( line[:23]))
|
|
|
|
|
error_page('FEHLER: Aktion oder Ware "%s" nicht bekannt' % line)
|
|
|
|
|
else:
|
|
|
|
|
print_display('\x0cERROR: Server Error%20s' % str(e)[:20])
|
|
|
|
|
myDisplay.display_screen("Server error",'%20s' % str(e)[:20])
|
|
|
|
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
|
|
|
|
else:
|
|
|
|
|
status.buy(item)
|
|
|
|
|
else:
|
|
|
|
|
idlemessage="Mir ist langweilig!"
|
|
|
|
|
myDisplay.setIdlemessage("Mir ist langweilig!")
|
|
|
|
|
try:
|
|
|
|
|
status.login(line)
|
|
|
|
|
except urllib2.HTTPError as e:
|
|
|
|
|
if e.code == 404: # URL not found == user unknown
|
|
|
|
|
display_screen("FEHLER","Nutzer ist unbekannt: '%s' *** " % line)
|
|
|
|
|
myDisplay.display_screen("FEHLER","Nutzer ist unbekannt: '%s' *** " % line)
|
|
|
|
|
|
|
|
|
|
error_page('FEHLER: Benutzer "%s" nicht bekannt' % line,
|
|
|
|
|
hint_message='Ist in der WebApp unter "Einstellungen" ' \
|
|
|
|
|
'für Ihren Account Plugin "BarcodePlugin" ' \
|
|
|
|
|
'als erlaubt markiert?')
|
|
|
|
|
else:
|
|
|
|
|
print_display('\x0cFEHLER: Server Error%20s' % str(e)[:20])
|
|
|
|
|
myDisplay.display_screen("FEHLER",'Server Error %20s' % str(e)[:20])
|
|
|
|
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
|
|
|
|
except urllib2.URLError as e:
|
|
|
|
|
error_page('FEHLER bei Kommunikation mit Server "%s"' % str(e))
|
|
|
|
@ -447,14 +432,15 @@ def main():
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
myDisplay.cmd_cursor_show(False)
|
|
|
|
|
|
|
|
|
|
display_screen("HINWEIS","Herzlich willkommen bei der Freitagsrunde! *** ")
|
|
|
|
|
myDisplay.display_screen("HINWEIS","Herzlich willkommen bei der Freitagsrunde! *** ")
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
while True:
|
|
|
|
|
clear()
|
|
|
|
|
status.dump()
|
|
|
|
|
print_prompt()
|
|
|
|
|
line = read_line(sys.stdin, timeout=3*60.0, timeout_func=status.logout)
|
|
|
|
|
if line:
|
|
|
|
|
print_display('\x0cBarcode:\n%20s' % line[:20])
|
|
|
|
|
myDisplay.write('\x0cBarcode:\n%20s' % line[:20])
|
|
|
|
|
handle(line, status)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -463,6 +449,6 @@ if __name__ == '__main__':
|
|
|
|
|
main()
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
|
pass
|
|
|
|
|
print_display("\x1b\x40Goodbye!")
|
|
|
|
|
myDisplay.write("\x1b\x40Goodbye!")
|
|
|
|
|
myDisplay.terminate()
|
|
|
|
|
|
|
|
|
|