|
TheSaint |
at May 21, 2011 at 12:50 pm
|
⇧ |
| |
Kushal Kumaran wrote:
That's how it is able to give you the status. So, if you
are using getstatusoutput, you will have only one instance of your
command running.
My intent is to launch only one program instance, which will goes as daemon.
To avoid a second call I'd like rather to use Python than
==============================code=========================================
def start(self):
'''try to start aria2c as a daemon and return its handle to where it
can
proceed to issue commands'''
# aria2c is running, then don't try it again
if (chkout('ps -A |grep aria2c')[0] > 0):
try:
chkout(self.ARIA_CMD)
except:
raise SystemExit('aria2c is not working as deamon')
elif self.handle: return self.handle
# everything is good, it will return an handle
self.handle= \
xmlrpclib.ServerProxy('http://localhost:%s/rpc' %int(self.numport))
return self.handle
==============================code=========================================
Here I've named subprocess.getstatusoutput as chkout, I'm calling 2 more
programs to find whether there's a running instance of aria2c. I think it's
not nice, python libraries should get the matter done.
--
goto /dev/null