.conf file writing added - devnocam mode added
This commit is contained in:
parent
09fd78f425
commit
040e3e9033
@ -1,4 +1,5 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
IFPassdir = \\192.168.1.1\SSIC\04-Projets\IFPass
|
IFPassdir = \\192.168.1.1\ssic\04-Projets\IFPass
|
||||||
printername = XPS card printer
|
printername = XPS Pink Card Printer
|
||||||
AcrobatReader = C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe
|
AcrobatReader = C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe
|
||||||
|
|
||||||
|
44
IFPass.py
44
IFPass.py
@ -22,19 +22,28 @@ from colorama import init
|
|||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
|
|
||||||
|
|
||||||
version = 'dev'
|
version = 'devnocam' # dev/devnocam
|
||||||
|
|
||||||
configfile = 'IFPass.conf'
|
config = 'IFPass.conf'
|
||||||
|
|
||||||
if not os.path.exists(configfile):
|
|
||||||
print('Erreur : Fichier de configuration introuvable !')
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
def initialisation():
|
||||||
config.read(configfile)
|
conf = configparser.ConfigParser()
|
||||||
|
conf.optionxform = str # For case sensitive config file
|
||||||
|
|
||||||
IFPassdir = config['DEFAULT']['IFPassdir']
|
if not os.path.exists(config): # Check if config file exists
|
||||||
printername = config['DEFAULT']['printername']
|
print('Fichier de configuration introuvable.')
|
||||||
|
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 ? : " )
|
||||||
|
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}
|
||||||
|
with open(config, 'w') as configfile:
|
||||||
|
conf.write(configfile)
|
||||||
|
else:
|
||||||
|
conf.read(config)
|
||||||
|
IFPassdir = conf['DEFAULT']['IFPassdir']
|
||||||
|
printername = conf['DEFAULT']['printername']
|
||||||
|
AcrobatReader = conf['DEFAULT']['AcrobatReader']
|
||||||
|
|
||||||
|
|
||||||
clientsfile = os.path.join(IFPassdir, 'Clients_IFPass.csv')
|
clientsfile = os.path.join(IFPassdir, 'Clients_IFPass.csv')
|
||||||
@ -44,14 +53,13 @@ pdftemplate = os.path.join(IFPassdir, 'Templates', 'IFPass_PDF_Template.pdf')
|
|||||||
pngtemplate = os.path.join(IFPassdir, 'Templates', 'IFPass_PNG_Template.png')
|
pngtemplate = os.path.join(IFPassdir, 'Templates', 'IFPass_PNG_Template.png')
|
||||||
fonttemplate = os.path.join(IFPassdir, 'Templates', 'Roboto-Bold.ttf')
|
fonttemplate = os.path.join(IFPassdir, 'Templates', 'Roboto-Bold.ttf')
|
||||||
|
|
||||||
|
if not os.path.exists(imgdir): # Cartes dir creation if it doesn't exist
|
||||||
def initialisation():
|
|
||||||
if not os.path.exists(imgdir):
|
|
||||||
os.makedirs(imgdir)
|
os.makedirs(imgdir)
|
||||||
if not os.path.exists(clientsfile):
|
if not os.path.exists(clientsfile): # Creation Clients_File if it doesn't exist
|
||||||
with open(clientsfile, 'w', newline='', encoding='utf-8') as csvfile:
|
with open(clientsfile, 'w', newline='', encoding='utf-8') as csvfile:
|
||||||
writer = csv.writer(csvfile, delimiter=';')
|
writer = csv.writer(csvfile, delimiter=';')
|
||||||
writer.writerow(['Titre', 'Prénom', 'Nom', 'Numéro de client', "Date d'inscription", "Date d'expiration"])
|
writer.writerow(['Titre', 'Prénom', 'Nom', 'Numéro de client', "Date d'inscription", "Date d'expiration"])
|
||||||
|
return IFPassdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate
|
||||||
|
|
||||||
|
|
||||||
def get_fullname():
|
def get_fullname():
|
||||||
@ -190,6 +198,8 @@ def fillcard(barcode):
|
|||||||
|
|
||||||
# Barcode + picture embedding :
|
# Barcode + picture embedding :
|
||||||
im.paste(barcode,(556, 460))
|
im.paste(barcode,(556, 460))
|
||||||
|
|
||||||
|
if version != 'devnocam':
|
||||||
im.paste(picture,(47, 49))
|
im.paste(picture,(47, 49))
|
||||||
|
|
||||||
# Create PDF :
|
# Create PDF :
|
||||||
@ -221,7 +231,6 @@ 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)
|
||||||
AcrobatReader = config['DEFAULT']['AcrobatReader']
|
|
||||||
subprocess.Popen('"' + AcrobatReader + '"' + ' /h /n /t ' + cartefilename + ' '+ printername, shell=False)
|
subprocess.Popen('"' + AcrobatReader + '"' + ' /h /n /t ' + cartefilename + ' '+ printername, shell=False)
|
||||||
|
|
||||||
|
|
||||||
@ -231,6 +240,8 @@ while "the informations are incorrect": # Loop Filling informations
|
|||||||
f = Figlet(font='big')
|
f = Figlet(font='big')
|
||||||
print(colored(f.renderText('IFPass'), 'cyan', attrs=['bold']))
|
print(colored(f.renderText('IFPass'), 'cyan', attrs=['bold']))
|
||||||
print('Version : ', version)
|
print('Version : ', version)
|
||||||
|
if version in ('dev', 'devnocam'):
|
||||||
|
print(colored("\nATTENTION : Il s'agit d'une version en cours de développement, potentiellement instable !", 'red'))
|
||||||
print('\nLe programme IFPass à été écrit par Jordan ERNST Q1 2018.')
|
print('\nLe programme IFPass à été écrit par Jordan ERNST Q1 2018.')
|
||||||
print('Pour toute question ou problème contactez-moi à pro.ernst@gmail.com.\n')
|
print('Pour toute question ou problème contactez-moi à pro.ernst@gmail.com.\n')
|
||||||
titre, firstname, surname, fullname = get_fullname()
|
titre, firstname, surname, fullname = get_fullname()
|
||||||
@ -259,13 +270,14 @@ while "the informations are incorrect": # Loop Filling informations
|
|||||||
|
|
||||||
if correct:
|
if correct:
|
||||||
os.system('cls')
|
os.system('cls')
|
||||||
initialisation()
|
IFPassdir, printername, AcrobatReader, clientsfile, clientsbkpfile, imgdir, pdftemplate, pngtemplate, fonttemplate = initialisation()
|
||||||
|
if version != 'devnocam':
|
||||||
picture = getpic()
|
picture = getpic()
|
||||||
clientID = getclientID()
|
clientID = getclientID()
|
||||||
barcode = barcode_gen(clientID)
|
barcode = barcode_gen(clientID)
|
||||||
fillcard(barcode)
|
fillcard(barcode)
|
||||||
cartefilename = mergepdf()
|
cartefilename = mergepdf()
|
||||||
if version != 'dev' :
|
if version not in ('dev', 'devnocam'):
|
||||||
bkpdb()
|
bkpdb()
|
||||||
printcard(cartefilename)
|
printcard(cartefilename)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
Loading…
Reference in New Issue
Block a user