initial commit
This commit is contained in:
commit
a3185bdce4
7 changed files with 74 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
*.pyc
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "printlib"]
|
||||||
|
path = printlib
|
||||||
|
url = https://github.com/adafruit/Python-Thermal-Printer.git
|
1
AdafruitThermal.py
Symbolic link
1
AdafruitThermal.py
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
printlib/Adafruit_Thermal.py
|
0
__init__.py
Normal file
0
__init__.py
Normal file
68
dump.py
Executable file
68
dump.py
Executable file
|
@ -0,0 +1,68 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
import sys
|
||||||
|
# Bad namming: change namming
|
||||||
|
from AdafruitThermal import Adafruit_Thermal as AdafruitThermal
|
||||||
|
import subprocess, time, Image, socket
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
#
|
||||||
|
CODING='cp437'
|
||||||
|
DEVICE="/dev/ttyUSB0"
|
||||||
|
SAMPLE_MACHINE = {
|
||||||
|
'login': 'cerveaulent',
|
||||||
|
'macAddress': '<automatique>',
|
||||||
|
'pass': '**********',
|
||||||
|
}
|
||||||
|
|
||||||
|
# Load data
|
||||||
|
crans_logo = Image.open(os.path.join(os.path.dirname(__file__), 'logo_crans.png'))
|
||||||
|
|
||||||
|
if not sys.argv[1:]:
|
||||||
|
liste = [SAMPLE_MACHINE]
|
||||||
|
else:
|
||||||
|
with open(sys.argv[1], 'r') as f:
|
||||||
|
liste = json.load(f)
|
||||||
|
|
||||||
|
printer = AdafruitThermal(DEVICE, 19200, timeout=5)
|
||||||
|
|
||||||
|
printer.setDefault() # Restore printer to defaults
|
||||||
|
printer.printImage(crans_logo, True)
|
||||||
|
|
||||||
|
def print_carac(text, value):
|
||||||
|
printer.justify('L')
|
||||||
|
pad = 384/12 - len(text) - len(value)
|
||||||
|
printer.println(text + ('.'*pad) + value )
|
||||||
|
|
||||||
|
|
||||||
|
def show_machine(machine):
|
||||||
|
printer.justify('C')
|
||||||
|
printer.underlineOn()
|
||||||
|
printer.println(u'Détails machine'.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'])
|
||||||
|
|
||||||
|
printer.feed(1)
|
||||||
|
|
||||||
|
|
||||||
|
# Do print
|
||||||
|
first = True
|
||||||
|
|
||||||
|
for m in liste:
|
||||||
|
if not first:
|
||||||
|
print_carac('','')
|
||||||
|
first = False
|
||||||
|
show_machine(m)
|
||||||
|
|
||||||
|
printer.println(u'Veuillez conserver ces informations en lieu sûr.'.encode(CODING))
|
||||||
|
|
||||||
|
printer.feed(2)
|
BIN
logo_crans.png
Normal file
BIN
logo_crans.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
1
printlib
Submodule
1
printlib
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 027f158ddfdcaa9395bb5704dcd6a12436a1a302
|
Loading…
Add table
Add a link
Reference in a new issue