Skip to content

Commit

Permalink
fix: split command before feeding to Popen object
Browse files Browse the repository at this point in the history
fix: split command before feeding to Popen object
  • Loading branch information
Anurag810 authored May 25, 2020
2 parents e25bcd7 + d675d53 commit ed741e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions erpnext_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,11 @@ def _safe_get_error_str(res):
def infinite_loop(sleep_time=15):
print("Service Running...")
while True:
main()
time.sleep(sleep_time)
try:
main()
time.sleep(sleep_time)
except BaseException as e:
print(e)

if __name__ == "__main__":
infinite_loop()
6 changes: 4 additions & 2 deletions gui.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
import json
import os
import shlex
import sys
import subprocess

Expand Down Expand Up @@ -206,13 +207,14 @@ def integrate_biometric(self):

if not hasattr(self, 'p'):
print("Starting Service...")
self.p = subprocess.Popen('python -c "from erpnext_sync import infinite_loop; infinite_loop()"', stdout=subprocess.PIPE)
command = shlex.split('python -c "from erpnext_sync import infinite_loop; infinite_loop()"')
self.p = subprocess.Popen(command, stdout=subprocess.PIPE)
print("Process running at {}".format(self.p.pid))
button.setText("Stop Service")
create_message_box("Service status", "Service has been started")
else:
print("Stopping Service...")
self.p.terminate()
self.p.kill()
del self.p
button.setText("Start Service")
create_message_box("Service status", "Service has been stoped")
Expand Down

0 comments on commit ed741e5

Please sign in to comment.