Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.56 KB | None | 0 0
  1. import os.path
  2.  
  3. PRINTER_MODELS_DRIVERS = {
  4.     "615": "Hasar",
  5.     "715v1": "Hasar",
  6.     "715v2": "Hasar",
  7.     "320": "Hasar",
  8.     "PT-1000F": "Hasar2Gen",
  9.     "PT-250F": "Hasar2Gen",
  10.     "P-HAS-5100-FAR": "Hasar2Gen",
  11.     "epsonlx300+": "Epson",
  12.     "tm-220-af": "Epson",
  13.     "tm-t900fa": "Epson",
  14.     "tickeadoras": "Epson"
  15. }
  16.  
  17. PRINTER_MODELS_VENDOR = {
  18.     "615": "Hasar",
  19.     "715v1": "Hasar",
  20.     "715v2": "Hasar",
  21.     "320": "Hasar",
  22.     "PT-1000F": "Hasar",
  23.     "PT-250F": "Hasar",
  24.     "P-HAS-5100-FAR": "Hasar",
  25.     "epsonlx300+": "Epson",
  26.     "tm-220-af": "Epson",
  27.     "tm-t900fa": "Epson",
  28.     "tickeadoras": "Epson"
  29. }
  30.  
  31. MAX_PORTS = 8
  32.  
  33. if __name__ == "__main__":
  34.     config_server = "[SERVIDOR]\npuerto = 12000\ndiscover_url = \nip_privada = \nuuid = \n\n"
  35.     config_str = "[{0}]\ndriver = {1}\nmarca = {2}\nmodelo = {3}\npath = /dev/ttyUSB{4}\n\n"
  36.     config = ""
  37.  
  38.     for port in range(1, MAX_PORTS+1):
  39.         for key, value in PRINTER_MODELS_DRIVERS.items():
  40.             name = "PUERTO_" + str(port).upper() + "_" + PRINTER_MODELS_DRIVERS[key].upper() + "_" + key.upper().replace("-", "")
  41.             driver = PRINTER_MODELS_DRIVERS[key]
  42.             vendor = PRINTER_MODELS_VENDOR[key]
  43.             model = key
  44.             tty = str(port-1)
  45.             config += config_str.format(name, driver, vendor, model, tty)
  46.  
  47.     print(config_server+config)
  48.  
  49.     config_path = '../../fiscalberry/config.ini'
  50.  
  51.     file = open(config_path, 'w')
  52.     file.write(config_server+config)
  53.     file.close()
  54.  
  55.     print(config_path + " updated.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement