diff --git a/dump.py b/dump.py index 7ed2924..c3719e0 100755 --- a/dump.py +++ b/dump.py @@ -13,9 +13,14 @@ import json CODING='cp437' DEVICE="/dev/ttyUSB0" SAMPLE_MACHINE = { - 'login': 'cerveaulent', + 'login': 'nouille', 'macAddress': '', - 'pass': '**********', + 'secret': '**********', +} + +SAMPLE_ACCOUNT = { + 'login': 'passoir', + 'pass': 'omgverysecure', } # Load data @@ -30,18 +35,26 @@ def print_carac(text, value): printer.println(text + ('.'*pad) + value ) -def show_machine(machine): +def show_entry(entry): printer.justify('C') printer.underlineOn() - printer.println(u'Détails machine'.encode(CODING)) + if 'secret' in entry: + title = u'Détails machine' + if 'type' in entry: + title += u' ' + entry['type'] + printer.println(title.encode(CODING)) + else: + printer.println(u'Compte Crans'.encode(CODING)) printer.underlineOff() printer.justify('L') - print_carac('Login', machine['login']) - if machine.has_key('macAddress'): - print_carac('Mac', machine['macAddress']) - if machine.has_key('pass'): - print_carac('Mot de passe', machine['pass']) + print_carac('Login', entry['login']) + if 'macAddress' in entry: + print_carac('Mac', entry['macAddress']) + if 'secret' in entry: + print_carac('Mot de passe', entry['secret']) + if 'pass' in entry: + print_carac('Mot de passe', entry['pass']) printer.feed(1) @@ -54,10 +67,11 @@ def print_liste(liste): first = True for m in liste: - if not first: - print_carac('','') + #if not first: + # print_carac('','') first = False - show_machine(m) + + show_entry(m) printer.println(u'Veuillez conserver ces informations en lieu sûr.'.encode(CODING)) @@ -65,7 +79,7 @@ def print_liste(liste): if __name__ == '__main__': if not sys.argv[1:]: - liste = [SAMPLE_MACHINE] + liste = [SAMPLE_ACCOUNT, SAMPLE_MACHINE] else: with open(sys.argv[1], 'r') as f: liste = json.load(f) diff --git a/dump_creds.py b/dump_creds.py index d2e4f84..a61b659 100755 --- a/dump_creds.py +++ b/dump_creds.py @@ -42,7 +42,7 @@ for machine in m: login = machine['host'][0].split('.', 1)[0] todo = {'login': login, 'macAddress': machine['macAddress'][0].value} if machine.has_key('ipsec'): - todo['pass'] = machine['ipsec'][0].value + todo['secret'] = machine['ipsec'][0].value to_print.append(todo) ch.basic_publish(exchange='', routing_key='CransTicket', body=json.dumps(to_print))