Skip to content

Instantly share code, notes, and snippets.

@vvvhung
Created July 12, 2018 09:32
Show Gist options
  • Save vvvhung/188c8a0ddf575f69aab357e1190bec04 to your computer and use it in GitHub Desktop.
Save vvvhung/188c8a0ddf575f69aab357e1190bec04 to your computer and use it in GitHub Desktop.
Window service python
import os
config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "config.txt")
config = {}
f = open(config_file, 'r')
for line in f:
if line.strip()[0] != '#':
sep = line.find(":")
key = line[:sep].strip()
val = line[sep+1:].strip()
config[key] = val
print(config)
f.close()
#allow_extensions: pdf, tif
allow_extensions: pdf
ai_api : http://192.168.99.100:5000/ocr/
card_type_file : C:\Users\vieth\Downloads\Card Type Master_20180628.xlsx
search_method : ExcelDirect
#search_method : ElasticSearch
printer_name : FUJI XEROX ApeosPort-VI C4471
#print_tool : FoxitReader
#tool_file : C:\Program Files (x86)\Foxit Software\Foxit Reader\FoxitReader.exe
#print_tool : SumatraPDF
#tool_file : C:\Program Files\SumatraPDF\SumatraPDF.exe
print_tool : GhostScript
tool_file : C:\Program Files\gs\gs9.23\bin\gswin64c.exe
@echo off
set /p PASSWORD=Enter Password:
nssm.exe install SERVICE_NAME api_wrapper.exe Start Automatic AppDirectory %CD% AppStdout %CD%\log.txt AppStderr %CD%\log.txt && nssm.exe set SERVICE_NAME ObjectName .\%USERNAME% %PASSWORD% && nssm.exe start SERVICE_NAME
pyinstaller api_wrapper.py
nssm.exe restart SERVICE_NAME
nssm.exe stop SERVICE_NAME & nssm.exe remove SERVICE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment