Python 3 script as windows service
up vote
0
down vote
favorite
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini
and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB
, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini
:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini
file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
add a comment |
up vote
0
down vote
favorite
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini
and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB
, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini
:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini
file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini
and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB
, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini
:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini
file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
I have a problem running my script as a service.
I don't understand what to do with paths.
What I have:
main.py (main code) service.py (template to install and run main.py
/ |
subdir/ subdir/ config.ini
script1.py script2.py
What in main.py:
1. I read config.ini
and get variables with paths, i.e.:
[XLS]
dir = D:\ExcelToSQL
workbook1 = workbook1.xls
workbook2 = workbook2.xls
workbook3 = workbook3.xls
[SQL]
user = root
password = password
host = localhost
database = database
port = 3306
ssl_ca =
ssl_verify_cert =
ssl_key =
ssl_cert =
encoding =
- script1 for changing values in XLS workbooks just functions with args and params
script2 for importing inMySQL DB
, again just functions.
All variables come fromconfig.ini
Main problem when I debug my service. It can't read config.ini
:
Error 0xC0000003 - The instance's SvcRun() method failed
Traceback (most recent call last):
File "C:Pythonlibsite-packageswin32libwin32serviceutil.py", line 839, in SvcRun
self.SvcDoRun()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 31, in SvcDoRun
self.main()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLservice.py", line 37, in main
app()
File "D:rs_alIdeaProjectsExcelToSQLPyXLSQLpyxlsql.py", line 14, in app
path = config.get ("XLS", "dir")
File "C:Pythonlibconfigparser.py", line 780, in get
d = self._unify_values(section, vars)
File "C:Pythonlibconfigparser.py", line 1146, in _unify_values
raise NoSectionError(section) from None
configparser.NoSectionError: No section: 'XLS'
(null): (null)
I know where is an issue:
in main.py:print(sys.argv[0])
outputC:Pythonlibsite-packageswin32PythonService.exe
Is it possible to run the service as I want? Because now it is looking for ini
file in C:Pythonlibsite-packageswin32PythonService.exe.
python service
python service
edited 21 hours ago
Vineeth Sai
2,04131020
2,04131020
asked 21 hours ago
Rostislav Aleev
94
94
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222233%2fpython-3-script-as-windows-service%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password