Code formatting
This commit is contained in:
parent
437015589f
commit
56d3b27ef9
22
IFPass.py
22
IFPass.py
@ -22,7 +22,7 @@ from colorama import init
|
|||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
|
|
||||||
|
|
||||||
version = 'devnocam' # dev/devnocam
|
version = 'devnocam' # dev/devnocam
|
||||||
|
|
||||||
config = 'IFPass.conf'
|
config = 'IFPass.conf'
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ def initialisation():
|
|||||||
if not os.path.exists(config): # Check if config file exists
|
if not os.path.exists(config): # Check if config file exists
|
||||||
print('Fichier de configuration introuvable.')
|
print('Fichier de configuration introuvable.')
|
||||||
IFPassdir = input(r'Quel est le répertoire IFPass ? (Ex : \\192.168.1.1\IFPass) : ')
|
IFPassdir = input(r'Quel est le répertoire IFPass ? (Ex : \\192.168.1.1\IFPass) : ')
|
||||||
printername = input("Quel est le nom de l'imprimante à cartes ? : " )
|
printername = input("Quel est le nom de l'imprimante à cartes ? : ")
|
||||||
AcrobatReader = input(r"Quel est le chemain vers Acrobat Reader ? ( Ex : C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe) : ")
|
AcrobatReader = input(r"Quel est le chemain vers Acrobat Reader ? ( Ex : C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe) : ")
|
||||||
conf['DEFAULT'] = {'IFPassdir': IFPassdir, 'printername': printername, 'AcrobatReader': AcrobatReader}
|
conf['DEFAULT'] = {'IFPassdir': IFPassdir, 'printername': printername, 'AcrobatReader': AcrobatReader}
|
||||||
with open(config, 'w') as configfile:
|
with open(config, 'w') as configfile:
|
||||||
@ -45,7 +45,6 @@ def initialisation():
|
|||||||
printername = conf['DEFAULT']['printername']
|
printername = conf['DEFAULT']['printername']
|
||||||
AcrobatReader = conf['DEFAULT']['AcrobatReader']
|
AcrobatReader = conf['DEFAULT']['AcrobatReader']
|
||||||
|
|
||||||
|
|
||||||
clientsfile = os.path.join(IFPassdir, 'Clients_IFPass.csv')
|
clientsfile = os.path.join(IFPassdir, 'Clients_IFPass.csv')
|
||||||
clientsbkpfile = os.path.join(IFPassdir, 'Clients_IFPass_backup.csv')
|
clientsbkpfile = os.path.join(IFPassdir, 'Clients_IFPass_backup.csv')
|
||||||
imgdir = os.path.join(IFPassdir, 'Cartes')
|
imgdir = os.path.join(IFPassdir, 'Cartes')
|
||||||
@ -108,7 +107,7 @@ def getclientID():
|
|||||||
|
|
||||||
def barcode_gen(clientID):
|
def barcode_gen(clientID):
|
||||||
print("Génération du code barre... ", end='')
|
print("Génération du code barre... ", end='')
|
||||||
barcode = code128.image(clientID, thickness=4) # .save(imgdir + clientID + '.png')
|
barcode = code128.image(clientID, thickness=4) # .save(imgdir + clientID + '.png')
|
||||||
print(colored('[OK]', 'green'))
|
print(colored('[OK]', 'green'))
|
||||||
return barcode
|
return barcode
|
||||||
|
|
||||||
@ -161,7 +160,6 @@ def getpic():
|
|||||||
picture = Image.fromarray(cropped)
|
picture = Image.fromarray(cropped)
|
||||||
return picture
|
return picture
|
||||||
|
|
||||||
|
|
||||||
elif k & 0xFF == ord('q'): # Q or q to quit
|
elif k & 0xFF == ord('q'): # Q or q to quit
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
@ -186,21 +184,21 @@ def fillcard(barcode):
|
|||||||
|
|
||||||
# Name embedding :
|
# Name embedding :
|
||||||
font = ImageFont.truetype(fonttemplate, 45)
|
font = ImageFont.truetype(fonttemplate, 45)
|
||||||
draw.text((401, 310), fullname, fill=(0,0,0), font=font)
|
draw.text((401, 310), fullname, fill=(0, 0, 0), font=font)
|
||||||
|
|
||||||
# Date embedding :
|
# Date embedding :
|
||||||
font = ImageFont.truetype(fonttemplate, 30)
|
font = ImageFont.truetype(fonttemplate, 30)
|
||||||
draw.text((401, 390), dateexp, fill=(0,0,0), font=font)
|
draw.text((401, 390), dateexp, fill=(0, 0, 0), font=font)
|
||||||
|
|
||||||
# ID embedding :
|
# ID embedding :
|
||||||
font = ImageFont.truetype('arial.ttf', 30)
|
font = ImageFont.truetype('arial.ttf', 30)
|
||||||
draw.text((693, 560), clientID, fill=(0,0,0), font=font)
|
draw.text((693, 560), clientID, fill=(0, 0, 0), font=font)
|
||||||
|
|
||||||
# Barcode + picture embedding :
|
# Barcode + picture embedding :
|
||||||
im.paste(barcode,(556, 460))
|
im.paste(barcode, (556, 460))
|
||||||
|
|
||||||
if version != 'devnocam':
|
if version != 'devnocam':
|
||||||
im.paste(picture,(47, 49))
|
im.paste(picture, (47, 49))
|
||||||
|
|
||||||
# Create PDF :
|
# Create PDF :
|
||||||
im = im.convert("RGB")
|
im = im.convert("RGB")
|
||||||
@ -231,7 +229,7 @@ def mergepdf():
|
|||||||
|
|
||||||
def printcard(cartefilename):
|
def printcard(cartefilename):
|
||||||
# Working : subprocess.Popen('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /n /t ' + cartefilename + ' '+ printername, shell=False)
|
# Working : subprocess.Popen('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /h /n /t ' + cartefilename + ' '+ printername, shell=False)
|
||||||
subprocess.Popen('"' + AcrobatReader + '"' + ' /h /n /t ' + cartefilename + ' '+ printername, shell=False)
|
subprocess.Popen('"' + AcrobatReader + '"' + ' /h /n /t ' + cartefilename + ' ' + printername, shell=False)
|
||||||
|
|
||||||
|
|
||||||
def membersearch():
|
def membersearch():
|
||||||
@ -280,7 +278,7 @@ def membersearch():
|
|||||||
if diff > 0:
|
if diff > 0:
|
||||||
print(colored(f"L'abonnement est encore valable {diff} jours.", 'green', attrs=['bold']))
|
print(colored(f"L'abonnement est encore valable {diff} jours.", 'green', attrs=['bold']))
|
||||||
elif diff < 0:
|
elif diff < 0:
|
||||||
print(colored("L'abonnement est expiré depuis {abs(diff)} jours.", 'red', attrs=['bold'])) # abs() to remove minus sign
|
print(colored("L'abonnement est expiré depuis {abs(diff)} jours.", 'red', attrs=['bold'])) # abs() to remove minus sign
|
||||||
elif diff == 0:
|
elif diff == 0:
|
||||||
print(colored("Il s'agit du dernier jour de l'abonnement, il expirera demain.", 'yellow', attrs=['bold']))
|
print(colored("Il s'agit du dernier jour de l'abonnement, il expirera demain.", 'yellow', attrs=['bold']))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user