|
@@ -20,7 +20,7 @@
|
|
|
daemon: Daemon control interface for the MMGen suite
|
|
|
"""
|
|
|
|
|
|
-import os,time,importlib
|
|
|
+import sys,os,time,importlib
|
|
|
from subprocess import run,PIPE,CompletedProcess
|
|
|
from collections import namedtuple
|
|
|
|
|
@@ -54,8 +54,8 @@ class Daemon(Lockable):
|
|
|
def __init__(self,cfg,opts=None,flags=None):
|
|
|
|
|
|
self.cfg = cfg
|
|
|
- self.platform = gc.platform
|
|
|
- if self.platform == 'win':
|
|
|
+ self.platform = sys.platform
|
|
|
+ if self.platform == 'win32':
|
|
|
self.use_pidfile = False
|
|
|
self.use_threads = True
|
|
|
|
|
@@ -65,11 +65,11 @@ class Daemon(Lockable):
|
|
|
|
|
|
def exec_cmd_thread(self,cmd):
|
|
|
import threading
|
|
|
- tname = ('exec_cmd','exec_cmd_win_console')[self.platform == 'win' and self.new_console_mswin]
|
|
|
+ tname = ('exec_cmd','exec_cmd_win_console')[self.platform == 'win32' and self.new_console_mswin]
|
|
|
t = threading.Thread(target=getattr(self,tname),args=(cmd,))
|
|
|
t.daemon = True
|
|
|
t.start()
|
|
|
- if self.platform == 'win':
|
|
|
+ if self.platform == 'win32':
|
|
|
Msg_r(' \b') # blocks w/o this...crazy
|
|
|
return True
|
|
|
|
|
@@ -119,7 +119,7 @@ class Daemon(Lockable):
|
|
|
if self.use_pidfile:
|
|
|
with open(self.pidfile) as fp:
|
|
|
return fp.read().strip()
|
|
|
- elif self.platform == 'win':
|
|
|
+ elif self.platform == 'win32':
|
|
|
# Assumes only one running instance of given daemon. If multiple daemons are running,
|
|
|
# the first PID in the list is returned and self.pids is set to the PID list.
|
|
|
ss = f'{self.exec_fn}.exe'
|
|
@@ -155,7 +155,7 @@ class Daemon(Lockable):
|
|
|
@property
|
|
|
def stop_cmd(self):
|
|
|
return (
|
|
|
- ['kill','-Wf',self.pid] if self.platform == 'win' else
|
|
|
+ ['kill','-Wf',self.pid] if self.platform == 'win32' else
|
|
|
['kill','-9',self.pid] if self.force_kill else
|
|
|
['kill',self.pid] )
|
|
|
|
|
@@ -486,7 +486,7 @@ class CoinDaemon(Daemon):
|
|
|
assert self.test_suite, 'datadir removal restricted to test suite'
|
|
|
if self.state == 'stopped':
|
|
|
run([
|
|
|
- ('rm' if gc.platform == 'win' else '/bin/rm'),
|
|
|
+ ('rm' if self.platform == 'win32' else '/bin/rm'),
|
|
|
'-rf',
|
|
|
self.datadir ])
|
|
|
set_vt100()
|