forked from reingart/pyfiscalprinter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
epsonFiscalDriver_service.py
33 lines (23 loc) · 1.12 KB
/
epsonFiscalDriver_service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Creado siguiendo ejemplo en http://essiene.blogspot.com/2005/04/python-windows-services.html
# Seguir los pasos de ese post para hacerlo funcionar
import win32service
import win32serviceutil
class EpsonFiscalDriverService(win32serviceutil.ServiceFramework):
_svc_name_ = "epsonFiscalDriver"
_svc_display_name_ = "Servidor de Impresora Fiscal"
def __init__(self,args):
win32serviceutil.ServiceFramework.__init__(self,args)
def SvcDoRun(self):
import servicemanager
from epsonFiscalDriver import socketServer
servicemanager.LogInfoMsg("epsonFiscalDriver - Iniciando Servidor")
self.server = socketServer("Hasar", "", 12345, "COM1", 9600, 60, True)
servicemanager.LogInfoMsg("epsonFiscalDriver - Servidor Construido, sirviendo eternamente")
self.server.serve_forever()
def SvcStop(self):
import servicemanager
servicemanager.LogInfoMsg("epsonFiscalDriver - Deteniendo el servicio")
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
self.server.shutdown()
if __name__ == '__main__':
win32serviceutil.HandleCommandLine(EpsonFiscalDriverService)