mot de passe compte crans
This commit is contained in:
parent
076d667d34
commit
d76ed2febb
2 changed files with 28 additions and 14 deletions
40
dump.py
40
dump.py
|
@ -13,9 +13,14 @@ import json
|
||||||
CODING='cp437'
|
CODING='cp437'
|
||||||
DEVICE="/dev/ttyUSB0"
|
DEVICE="/dev/ttyUSB0"
|
||||||
SAMPLE_MACHINE = {
|
SAMPLE_MACHINE = {
|
||||||
'login': 'cerveaulent',
|
'login': 'nouille',
|
||||||
'macAddress': '<automatique>',
|
'macAddress': '<automatique>',
|
||||||
'pass': '**********',
|
'secret': '**********',
|
||||||
|
}
|
||||||
|
|
||||||
|
SAMPLE_ACCOUNT = {
|
||||||
|
'login': 'passoir',
|
||||||
|
'pass': 'omgverysecure',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load data
|
# Load data
|
||||||
|
@ -30,18 +35,26 @@ def print_carac(text, value):
|
||||||
printer.println(text + ('.'*pad) + value )
|
printer.println(text + ('.'*pad) + value )
|
||||||
|
|
||||||
|
|
||||||
def show_machine(machine):
|
def show_entry(entry):
|
||||||
printer.justify('C')
|
printer.justify('C')
|
||||||
printer.underlineOn()
|
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.underlineOff()
|
||||||
printer.justify('L')
|
printer.justify('L')
|
||||||
|
|
||||||
print_carac('Login', machine['login'])
|
print_carac('Login', entry['login'])
|
||||||
if machine.has_key('macAddress'):
|
if 'macAddress' in entry:
|
||||||
print_carac('Mac', machine['macAddress'])
|
print_carac('Mac', entry['macAddress'])
|
||||||
if machine.has_key('pass'):
|
if 'secret' in entry:
|
||||||
print_carac('Mot de passe', machine['pass'])
|
print_carac('Mot de passe', entry['secret'])
|
||||||
|
if 'pass' in entry:
|
||||||
|
print_carac('Mot de passe', entry['pass'])
|
||||||
|
|
||||||
printer.feed(1)
|
printer.feed(1)
|
||||||
|
|
||||||
|
@ -54,10 +67,11 @@ def print_liste(liste):
|
||||||
first = True
|
first = True
|
||||||
|
|
||||||
for m in liste:
|
for m in liste:
|
||||||
if not first:
|
#if not first:
|
||||||
print_carac('','')
|
# print_carac('','')
|
||||||
first = False
|
first = False
|
||||||
show_machine(m)
|
|
||||||
|
show_entry(m)
|
||||||
|
|
||||||
printer.println(u'Veuillez conserver ces informations en lieu sûr.'.encode(CODING))
|
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 __name__ == '__main__':
|
||||||
if not sys.argv[1:]:
|
if not sys.argv[1:]:
|
||||||
liste = [SAMPLE_MACHINE]
|
liste = [SAMPLE_ACCOUNT, SAMPLE_MACHINE]
|
||||||
else:
|
else:
|
||||||
with open(sys.argv[1], 'r') as f:
|
with open(sys.argv[1], 'r') as f:
|
||||||
liste = json.load(f)
|
liste = json.load(f)
|
||||||
|
|
|
@ -42,7 +42,7 @@ for machine in m:
|
||||||
login = machine['host'][0].split('.', 1)[0]
|
login = machine['host'][0].split('.', 1)[0]
|
||||||
todo = {'login': login, 'macAddress': machine['macAddress'][0].value}
|
todo = {'login': login, 'macAddress': machine['macAddress'][0].value}
|
||||||
if machine.has_key('ipsec'):
|
if machine.has_key('ipsec'):
|
||||||
todo['pass'] = machine['ipsec'][0].value
|
todo['secret'] = machine['ipsec'][0].value
|
||||||
to_print.append(todo)
|
to_print.append(todo)
|
||||||
|
|
||||||
ch.basic_publish(exchange='', routing_key='CransTicket', body=json.dumps(to_print))
|
ch.basic_publish(exchange='', routing_key='CransTicket', body=json.dumps(to_print))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue