Index: drone/module01.py
===================================================================
--- drone/module01.py	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
+++ drone/module01.py	(revision 35fb6a283b9fc123d8e7eb5d3e3963e57c10f235)
@@ -1,14 +1,16 @@
-#!/usr/bin/env python
-# -*- coding:utf-8 -*-
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
 # author: H.L. TIAN 2017
 
-#import Sniper
+# import Sniper
+
 import DroNECore
-import DroNECore.PyIncident       as PI
+import DroNECore.PyIncident as PI
 import CtrlSvc.PushMatrixIncident as PMI
-import CtrlSvc.PushHistIncident   as PHI
-import CtrlSvc.HeartBeatIncident  as HBI
-import CtrlSvc.NeonRPCIncident    as NRI
-import CtrlSvc.NeonRPCTask        as NRT
+import CtrlSvc.PushHistIncident as PHI
+import CtrlSvc.HeartBeatIncident as HBI
+import CtrlSvc.NeonRPCIncident as NRI
+import CtrlSvc.NeonRPCTask as NRT
 import CtrlSvc.NeonUpdateDataTask as NUT
 import NEON
@@ -18,10 +20,13 @@
 import os
 
+
 class RedisRemoteData:
+
     def __init__(self, ip, path):
         from redis.sentinel import Sentinel
-        sentinel=Sentinel(ip, socket_timeout=10)
-        self.server = sentinel.master_for('neonmaster', socket_timeout=200, password='sanlie;123', db=0)
-        self.path   = path
+        sentinel = Sentinel(ip, socket_timeout=10)
+        self.server = sentinel.master_for('neonmaster',
+                socket_timeout=200, password='sanlie;123', db=0)
+        self.path = path
 
     def setData(self, data):
@@ -37,89 +42,108 @@
         self.data = self.server.get(self.path)
 
+
 def App(in_module='', in_redisip='', in_cron=1):
-    m_modulename = in_module#'module131'
-    m_redisip    = in_redisip#'10.1.33.141'
-    m_cron       = in_cron#15
+    m_modulename = in_module  # 'module131'
+    m_redisip = in_redisip  # '10.1.33.141'
+    m_cron = in_cron  # 15
 
-    #from xml.etree import ElementTree as ET
-    #root = ET.parse('/home/drone/workspace/drone/daqrun/cockpit/configure.xml')
-    #tof  = root.find('tofInformation')
-    #m_tofstart= int(tof.attrib['tofstart'])*factor
-    #m_tofstep = int(tof.attrib['tofstep'])*factor 
-    #m_tofbins = int(tof.attrib['tofbin'])
-    #factor = 40  # 25ns to 1us
+    # from xml.etree import ElementTree as ET
+    # root = ET.parse('/home/drone/workspace/drone/daqrun/cockpit/configure.xml')
+    # tof  = root.find('tofInformation')
+    # m_tofstart= int(tof.attrib['tofstart'])*factor
+    # m_tofstep = int(tof.attrib['tofstep'])*factor
+    # m_tofbins = int(tof.attrib['tofbin'])
+    # factor = 40  # 25ns to 1us
+
     factor = 80  # 12.5ns to 1us
-    m_tofstart= 0*factor
-    m_tofstep = 16*factor # indeed 16 
+    m_tofstart = 0 * factor
+    m_tofstep = 16 * factor  # indeed 16
     m_tofbins = 2500
-    
-    m_moduleinfo={}
-    m_moduleinfo['num']='0'
-    m_moduleinfo['idstart']=100001
-    m_moduleinfo['idsize']=1200
-        
-    path  = '/MR/workspace/detector/'+m_modulename
 
-    m_taskMatrix = RedisRemoteData(m_redisip, path+"/value")
-    m_taskTOF    = RedisRemoteData(m_redisip, path+"/tof")
-    m_taskPID    = RedisRemoteData(m_redisip, path+"/pid")
-    toflist = [m_tofstep+i*m_tofstep for i in xrange(m_tofbins+1)]
+    m_moduleinfo = {}
+    m_moduleinfo['num'] = '0'
+    m_moduleinfo['idstart'] = 100001
+    m_moduleinfo['idsize'] = 1200
+
+    path = '/MR/workspace/detector/' + m_modulename
+
+    m_taskMatrix = RedisRemoteData(m_redisip, path + '/value')
+    m_taskTOF = RedisRemoteData(m_redisip, path + '/tof')
+    m_taskPID = RedisRemoteData(m_redisip, path + '/pid')
+    toflist = [m_tofstep + i * m_tofstep for i in xrange(m_tofbins + 1)]
     m_taskTOF.setData(json.dumps(toflist))
     m_taskTOF.dump()
 
     idstart = int(m_moduleinfo['idstart'])
-    idsize  = int(m_moduleinfo['idsize'])
-    pidlist = [i+idstart for i in xrange(idsize)]
+    idsize = int(m_moduleinfo['idsize'])
+    pidlist = [i + idstart for i in xrange(idsize)]
     m_taskPID.setData(json.dumps(pidlist))
     m_taskPID.dump()
-    
-    m_taskheartbeat = RedisRemoteData(m_redisip, \
-                    '/MR/heartbeat/detector/'+m_modulename)
-    m_taskheartbeat.setData(HBI.HeartBeatCronIncident.encodeHeartBeat(status='running', \
-                                    hit = 0, event = 0, pulse = 0, idx = os.getpid()))
+
+    m_taskheartbeat = RedisRemoteData(m_redisip,
+            '/MR/heartbeat/detector/' + m_modulename)
+    m_taskheartbeat.setData(HBI.HeartBeatCronIncident.encodeHeartBeat(status='running'
+                            , hit=0, event=0, pulse=0, idx=os.getpid()))
     m_taskheartbeat.dump()
 
-    m_configure = {"pidstart":idstart,"pidsize":idsize}
-    task = DroNECore.DroNEOnline("task")
+    m_configure = {'pidstart': idstart, 'pidsize': idsize}
+    task = DroNECore.DroNEOnline('task')
     task.asTop()
     task.setLogLevel(2)
-   
-    ## ===========================
-    m_neonRedis = NEON.Neon.NeonRedisSentinel(m_redisip, i_socket_timeout=0.1, \
-                                           master_name='neonmaster', master_timeout = 120, master_password='sanlie;123', \
-                                           idb = 0, isWritable = True) # server mode, set msgs to Redis
-    servpob = NEON.Neon.NeonService.POBox(m_neonRedis, '/MR/process/detector', 'server:'+m_modulename)
-    servrpc = NEON.Neon.NeonService.NeonRPC(sendPOBox = servpob, recvPOBox = servpob, isServer=True)
-    nr = NRT.NeonRPCTask("NeonRPC", servrpc, remotedata = m_taskheartbeat)
+
+    # # ===========================
+
+    m_neonRedis = NEON.Neon.NeonRedisSentinel(  # server mode, set msgs to Redis
+        m_redisip,
+        i_socket_timeout=0.1,
+        master_name='neonmaster',
+        master_timeout=120,
+        master_password='sanlie;123',
+        idb=0,
+        isWritable=True,
+        )
+    servpob = NEON.Neon.NeonService.POBox(m_neonRedis,
+            '/MR/process/detector', 'server:' + m_modulename)
+    servrpc = NEON.Neon.NeonService.NeonRPC(sendPOBox=servpob,
+            recvPOBox=servpob, isServer=True)
+    nr = NRT.NeonRPCTask('NeonRPC', servrpc, remotedata=m_taskheartbeat)
 
     import CtrlSvc
-    ct = DroNECore.CtrlTask("ctrl")
-    pi = PMI.PushMatrixCronIncident("PushMatrix", cron = m_cron, \
-                                    repeatable = True, remotedata = m_taskMatrix,\
-                                    configure = m_configure)
-    hi = HBI.HeartBeatCronIncident("HeartBeat", cron = 2, repeatable = True, remotedata = m_taskheartbeat)
-    ni = NRI.NeonRPCCronIncident("NeonRPC", cron = 1, repeatable = True)
+    ct = DroNECore.CtrlTask('ctrl')
+    pi = PMI.PushMatrixCronIncident('PushMatrix', cron=m_cron,
+                                    repeatable=True,
+                                    remotedata=m_taskMatrix,
+                                    configure=m_configure)
+    hi = HBI.HeartBeatCronIncident('HeartBeat', cron=2,
+                                   repeatable=True,
+                                   remotedata=m_taskheartbeat)
+    ni = NRI.NeonRPCCronIncident('NeonRPC', cron=1, repeatable=True)
     ct.add(hi)
     ct.add(ni)
     ct.add(pi)
- 
-    ## ===========================
-    nu = NUT.NeonUpdateDataTask("UpdateRemoteData", remotedata = m_taskMatrix, configure=m_configure)
-    ## ===========================
+
+    # # ===========================
+
+    nu = NUT.NeonUpdateDataTask('UpdateRemoteData',
+                                remotedata=m_taskMatrix,
+                                configure=m_configure)
+
+    # # ===========================
+
     import DataSvc
-    task.property("svcs").append("MRDataSvc/DataSvc")
-    task.property("svcs").append("CtrlSvc")
-    task.property("svcs").append("He3TRawDataInputSvc/DataInputSvc")
-    task.property("svcs").append("DimRecvSvc/DataProvideSvc")
+    task.property('svcs').append('MRDataSvc/DataSvc')
+    task.property('svcs').append('CtrlSvc')
+    task.property('svcs').append('He3TRawDataInputSvc/DataInputSvc')
+    task.property('svcs').append('DimRecvSvc/DataProvideSvc')
 
-    iDat = task.find("DataSvc")
-    iSvc = task.find("DataInputSvc")
-    iPvd = task.find("DataProvideSvc")
+    iDat = task.find('DataSvc')
+    iSvc = task.find('DataInputSvc')
+    iPvd = task.find('DataProvideSvc')
 
-    dimsrvname = "dimserver/TEST_SWAP_"+m_moduleinfo['num']
-    
-    iPvd.property("DataSize").set(1000000)
-    iPvd.property("DimServerName").set(dimsrvname)
-    iSvc.property("BuffSize").set(1000000)
+    dimsrvname = 'dimserver/TEST_SWAP_' + m_moduleinfo['num']
+
+    iPvd.property('DataSize').set(1000000)
+    iPvd.property('DimServerName').set(dimsrvname)
+    iSvc.property('BuffSize').set(1000000)
 
     iSvc.show()
@@ -127,16 +151,19 @@
 
     import Algorithms
-    task.property("algs").append("MRHe3TRecAlg")
-    task.property("algs").append("MRHe3TMapAlg")
-    task.property("algs").append("RunningInfAlg")
-    #task.property("algs").append("DumpAlg")
+    task.property('algs').append('MRHe3TRecAlg')
+    task.property('algs').append('MRHe3TMapAlg')
+    task.property('algs').append('RunningInfAlg')
 
-    iRun = task.find("RunningInfAlg")
-    iRun.property("TofStart").set(m_tofstart)
-    iRun.property("TofBins").set(m_tofbins)
-    iRun.property("TofStep").set(m_tofstep)
+    # task.property("algs").append("DumpAlg")
 
-    iMap = task.find("MRHe3TMapAlg")
-    #iMap.property("ConfigFileName").set("configure.xml")
+    iRun = task.find('RunningInfAlg')
+    iRun.property('TofStart').set(m_tofstart)
+    iRun.property('TofBins').set(m_tofbins)
+    iRun.property('TofStep').set(m_tofstep)
+
+    iMap = task.find('MRHe3TMapAlg')
+
+    # iMap.property("ConfigFileName").set("configure.xml")
+
     iMap.show()
 
@@ -145,4 +172,6 @@
     task.run()
 
-if __name__ == "__main__":
-    App(in_module='module01', in_redisip=[('10.1.31.116', 9001)], in_cron=10)
+
+if __name__ == '__main__':
+    App(in_module='module01', in_redisip=[('10.1.31.116', 9001)],
+        in_cron=10)
Index: drone/monitor1.py
===================================================================
--- drone/monitor1.py	(revision 8e89fa9db7521ab69ddf3d63bd47cae76567d476)
+++ drone/monitor1.py	(revision 35fb6a283b9fc123d8e7eb5d3e3963e57c10f235)
@@ -1,12 +1,14 @@
-#!/usr/bin/env python
-# -*- coding:utf-8 -*-
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
 # author: H.L. TIAN 2017
+
 import DroNECore
-import DroNECore.PyIncident       as PI
+import DroNECore.PyIncident as PI
 import CtrlSvc.PushMatrixIncident as PMI
-import CtrlSvc.PushHistIncident   as PHI
-import CtrlSvc.HeartBeatIncident  as HBI
-import CtrlSvc.NeonRPCIncident    as NRI
-import CtrlSvc.NeonRPCTask        as NRT
+import CtrlSvc.PushHistIncident as PHI
+import CtrlSvc.HeartBeatIncident as HBI
+import CtrlSvc.NeonRPCIncident as NRI
+import CtrlSvc.NeonRPCTask as NRT
 import CtrlSvc.NeonUpdateDataTask as NUT
 import NEON
@@ -17,10 +19,13 @@
 import os
 
+
 class RedisRemoteData:
+
     def __init__(self, ip, path):
         from redis.sentinel import Sentinel
-        sentinel=Sentinel(ip, socket_timeout=10)
-        self.server = sentinel.master_for('neonmaster', socket_timeout=200, password='sanlie;123', db=0)
-        self.path   = path
+        sentinel = Sentinel(ip, socket_timeout=10)
+        self.server = sentinel.master_for('neonmaster',
+                socket_timeout=200, password='sanlie;123', db=0)
+        self.path = path
 
     def setData(self, data):
@@ -36,87 +41,110 @@
         self.data = self.server.get(self.path)
 
+
 def App(in_module='', in_redisip='', in_cron=1):
     m_modulename = in_module
-    m_redisip    = in_redisip
-    m_cron       = in_cron#15
+    m_redisip = in_redisip
+    m_cron = in_cron  # 15
 
-    #from xml.etree import ElementTree as ET
-    #root = ET.parse('/home/drone/workspace/drone/daqrun/cockpit/configure.xml')
-    #tof  = root.find('tofInformation')
-    #m_tofstart= int(tof.attrib['tofstart'])*factor
-    #m_tofstep = int(tof.attrib['tofstep'])*factor 
-    #m_tofbins = int(tof.attrib['tofbin'])
+    # from xml.etree import ElementTree as ET
+    # root = ET.parse('/home/drone/workspace/drone/daqrun/cockpit/configure.xml')
+    # tof  = root.find('tofInformation')
+    # m_tofstart= int(tof.attrib['tofstart'])*factor
+    # m_tofstep = int(tof.attrib['tofstep'])*factor
+    # m_tofbins = int(tof.attrib['tofbin'])
+
     factor = 1  # 1us to 1us
-    m_tofstart= 0*factor
-    m_tofstep = 16*factor
+    m_tofstart = 0 * factor
+    m_tofstep = 16 * factor
     m_tofbins = 2500
 
-    path  = '/MR/workspace/'+m_modulename
+    path = '/MR/workspace/' + m_modulename
 
-    m_taskMatrix = RedisRemoteData(m_redisip, path+"/value")
-    m_taskTOF    = RedisRemoteData(m_redisip, path+"/tof")
-    m_taskPID    = RedisRemoteData(m_redisip, path+"/pid")
-    
-    toflist = [m_tofstep+i*m_tofstep for i in xrange(m_tofbins+1)]
+    m_taskMatrix = RedisRemoteData(m_redisip, path + '/value')
+    m_taskTOF = RedisRemoteData(m_redisip, path + '/tof')
+    m_taskPID = RedisRemoteData(m_redisip, path + '/pid')
+
+    toflist = [m_tofstep + i * m_tofstep for i in xrange(m_tofbins + 1)]
     m_taskTOF.setData(json.dumps(toflist))
     m_taskTOF.dump()
 
-    import socket, os
-    m_taskheartbeat = RedisRemoteData(m_redisip, \
-                    '/MR/heartbeat/detector/'+m_modulename)
+    import socket
+    import os
+    m_taskheartbeat = RedisRemoteData(m_redisip,
+            '/MR/heartbeat/detector/' + m_modulename)
 
-    m_taskheartbeat.setData(HBI.HeartBeatCronIncident.encodeHeartBeat(status='running', \
-                                    hit = 0, event = 0, pulse = 0, idx = os.getpid()))
+    m_taskheartbeat.setData(HBI.HeartBeatCronIncident.encodeHeartBeat(status='running'
+                            , hit=0, event=0, pulse=0, idx=os.getpid()))
     m_taskheartbeat.dump()
 
     idstart = 3110001
-    idsize  = 1024
-    pidlist = [i+idstart for i in xrange(idsize)]
+    idsize = 1024
+    pidlist = [i + idstart for i in xrange(idsize)]
 
-    #print pidlist
+    # print pidlist
+
     m_taskPID.setData(json.dumps(pidlist))
     m_taskPID.dump()
 
-    m_configure = {"pidstart":idstart,"pidsize":idsize}
-    task = DroNECore.DroNEOnline("task")
+    m_configure = {'pidstart': idstart, 'pidsize': idsize}
+    task = DroNECore.DroNEOnline('task')
     task.asTop()
     task.setLogLevel(2)
 
-    ## ===========================
-    m_neonRedis = NEON.Neon.NeonRedisSentinel(m_redisip, i_socket_timeout=0.1, \
-                                           master_name='neonmaster', master_timeout = 120, master_password='sanlie;123', \
-                                           idb = 0, isWritable = True) # server mode, set msgs to Redis
-    servpob = NEON.Neon.NeonService.POBox(m_neonRedis, '/MR/process/detector', 'server:'+m_modulename)
-    servrpc = NEON.Neon.NeonService.NeonRPC(sendPOBox = servpob, recvPOBox = servpob, isServer=True)
-    nr = NRT.NeonRPCTask("NeonRPC", servrpc, remotedata = m_taskheartbeat)
+    # # ===========================
+
+    m_neonRedis = NEON.Neon.NeonRedisSentinel(  # server mode, set msgs to Redis
+        m_redisip,
+        i_socket_timeout=0.1,
+        master_name='neonmaster',
+        master_timeout=120,
+        master_password='sanlie;123',
+        idb=0,
+        isWritable=True,
+        )
+    servpob = NEON.Neon.NeonService.POBox(m_neonRedis,
+            '/MR/process/detector', 'server:' + m_modulename)
+    servrpc = NEON.Neon.NeonService.NeonRPC(sendPOBox=servpob,
+            recvPOBox=servpob, isServer=True)
+    nr = NRT.NeonRPCTask('NeonRPC', servrpc, remotedata=m_taskheartbeat)
 
     import CtrlSvc
-    ct = DroNECore.CtrlTask("ctrl")
-    pi = PMI.PushMatrixCronIncident("PushMatrix", cron = m_cron, \
-                                    repeatable = True, remotedata = m_taskMatrix,\
-                                    configure = m_configure)
-    hi = HBI.HeartBeatCronIncident("HeartBeat", cron = 2, repeatable = True, remotedata = m_taskheartbeat)
-    ni = NRI.NeonRPCCronIncident("NeonRPC", cron = 1, repeatable = True)
+    ct = DroNECore.CtrlTask('ctrl')
+    pi = PMI.PushMatrixCronIncident('PushMatrix', cron=m_cron,
+                                    repeatable=True,
+                                    remotedata=m_taskMatrix,
+                                    configure=m_configure)
+    hi = HBI.HeartBeatCronIncident('HeartBeat', cron=2,
+                                   repeatable=True,
+                                   remotedata=m_taskheartbeat)
+    ni = NRI.NeonRPCCronIncident('NeonRPC', cron=1, repeatable=True)
     ct.add(hi)
     ct.add(ni)
     ct.add(pi)
-    ## ===========================
-    nu = NUT.NeonUpdateDataTask("UpdateRemoteData", remotedata = m_taskMatrix, configure=m_configure)
-    ## ===========================
-    
+
+    # # ===========================
+
+    nu = NUT.NeonUpdateDataTask('UpdateRemoteData',
+                                remotedata=m_taskMatrix,
+                                configure=m_configure)
+
+    # # ===========================
+
     import DataSvc
-    task.property("svcs").append("MRDataSvc/DataSvc")
-    task.property("svcs").append("CtrlSvc")
-    task.property("svcs").append("EpicsInputSvc/DataInputSvc")
-    iSvc = task.find("DataInputSvc")
-    iSvc.property("Channel").set("rm:"+m_modulename)
+    task.property('svcs').append('MRDataSvc/DataSvc')
+    task.property('svcs').append('CtrlSvc')
+    task.property('svcs').append('EpicsInputSvc/DataInputSvc')
+    iSvc = task.find('DataInputSvc')
+    iSvc.property('Channel').set('rm:' + m_modulename)
 
     import Algorithms
-    task.property("algs").append("RunningInfAlg")
-    #task.property("algs").append("DumpAlg")
-    iRun = task.find("RunningInfAlg")
-    iRun.property("TofStart").set(m_tofstart)
-    iRun.property("TofBins").set(m_tofbins)
-    iRun.property("TofStep").set(m_tofstep)
+    task.property('algs').append('RunningInfAlg')
+
+    # task.property("algs").append("DumpAlg")
+
+    iRun = task.find('RunningInfAlg')
+    iRun.property('TofStart').set(m_tofstart)
+    iRun.property('TofBins').set(m_tofbins)
+    iRun.property('TofStep').set(m_tofstep)
 
     iSvc.show()
@@ -126,4 +154,6 @@
     task.run()
 
-if __name__ == "__main__":
-    App(in_module='monitor1', in_redisip=[('10.1.31.116', 9001)], in_cron=10)
+
+if __name__ == '__main__':
+    App(in_module='monitor1', in_redisip=[('10.1.31.116', 9001)],
+        in_cron=10)
Index: main.py
===================================================================
--- main.py	(revision 37bf37907f8f8056bb457866f38df8c67a6a0cd1)
+++ main.py	(revision 35fb6a283b9fc123d8e7eb5d3e3963e57c10f235)
@@ -68,6 +68,5 @@
     droneInfo[i]['state'] = 'waiting'
     droneInfo[i]['timestamp'] = '---'
-    droneInfo[i]['heartbeat'] = '/MR/heartbeat/detector/' \
-        + RMdrone[i]
+    droneInfo[i]['heartbeat'] = '/MR/heartbeat/detector/' + RMdrone[i]
 
 for i in range(len(droneInfo)):
@@ -100,28 +99,31 @@
 
     # _cmd="ps -ef | grep "+myname+" | grep -v grep | awk '{print $2}'"
-    pid1=[]
-    pid2=[]
-
-    _s=False
+
+    pid1 = []
+    pid2 = []
+
+    _s = False
     try:
         _cmd = 'ps -C ' + myname + ' -o pid='
         pid1 = subprocess.check_output(_cmd, shell=True)
         pid1 = shlex.split(pid)
-        _s=True
+        _s = True
     except:
-        pid1=[]
+        pid1 = []
 
     if not _s:
         try:
-            _tmp="\"python "+myname+"\""
-            _cmd = "ps -C " + _tmp + " -o pid="
+            _tmp = '"python ' + myname + '"'
+            _cmd = 'ps -C ' + _tmp + ' -o pid='
             pid2 = subprocess.check_output(_cmd, shell=True)
             pid2 = shlex.split(pid)
         except:
-            pid2=[]
-
-    pid=[]
-    for p in pid1:pid.append(p)
-    for p in pid2:pid.append(p)
+            pid2 = []
+
+    pid = []
+    for p in pid1:
+        pid.append(p)
+    for p in pid2:
+        pid.append(p)
 
     for p in pid:
@@ -284,6 +286,7 @@
             )
 
-        self.state=[]
-        for i in range(self.nModule):self.state.append(False)
+        self.state = []
+        for i in range(self.nModule):
+            self.state.append(False)
 
         self.createAll()
@@ -292,12 +295,13 @@
 
     def getState(self, n):
-       return self.state[n]
+        return self.state[n]
 
     def getStateAll(self, n):
-       return self.state
+        return self.state
 
     def create(self, n):
         clitpob = neon.Neon.NeonService.POBox(self.m_neonRedis,
-                '/SANS/process/detector', 'client:' + droneInfo[n]['module'])
+                '/SANS/process/detector', 'client:'
+                + droneInfo[n]['module'])
         clitrpc = neon.Neon.NeonService.NeonRPC(sendPOBox=clitpob,
                 recvPOBox=clitpob)
@@ -316,13 +320,14 @@
                 if _pid != -1:
                     droneInfo[n]['pid'] = str(_pid)
-                    self.state[n]=True
+                    self.state[n] = True
                     break
                 else:
-                    self.state[n]=False
-                    logger.error('%s create failed' % (droneInfo[n]['module']))
+                    self.state[n] = False
+                    logger.error('%s create failed'
+                                 % droneInfo[n]['module'])
         else:
             droneInfo[n]['pid'] = str(_pid)
-            self.state[n]=True
-        
+            self.state[n] = True
+
         webInfo[droneInfo[n]['module']]['pid'] = str(droneInfo[n]['pid'
                 ])
@@ -614,4 +619,5 @@
         droneServer,
         ):
+
         threading.Thread.__init__(self)
         self.stop = threading.Event()
@@ -979,6 +985,6 @@
         self.redisServer.set('/MR/drone/detector_counts',
                              json.dumps(self.detectorCountList))
-        
-        if _tmp !=0:
+
+        if _tmp != 0:
             try:
                 self.pvNeutron.put(_tmp)
@@ -1102,4 +1108,5 @@
         retry,
         ):
+
         com = str(com)
         cmd = int(cmd)
@@ -1239,29 +1246,10 @@
     def run(self):
         while True:
-            '''
-            try:
-                _value = str(self.pvCommand.get())
-                _time = str(self.pvCommand.timestamp)
-                if _value == 'STARTANALYSE' or _value == 'START':
-                    try:
-                        self.setProtonNeutron()
-                    except:
-                        pass
-                
-                if _time == self.lastTimeStamp and _value==self.lastCmd:
-                    continue
-                else:
-                    newCmd = str(_value)
-                    self.lastTimeStamp = _time
-                    self.lastCmd = newCmd
-                    logger.info('Receiving epics command %s' % newCmd)
-            except:
-                logger.debug('Receive epics command failed')
-                continue 
-            '''
-            newCmd='STARTANALYSE'
+            newCmd = 'STARTANALYSE'
+
             # newCmd=self.MRcommandList[random.randint(0,4)]
             # newCmd="STARTANALYSE"
             # logger.info("Receive epics command %s" % newCmd)
+
             if newCmd == 'CONF':
                 self.getEpicsConfigure()
@@ -1319,8 +1307,8 @@
 
                     self.setEpicsState('ERROR')
-                    logger.error('%s failed' % (newCmd))
-                    break 
-
+                    logger.error('%s failed' % newCmd)
+                    break
             elif newCmd == 'STARTANALYSE':
+
                 # clear drone
 
@@ -1388,5 +1376,5 @@
                         pass
                     self.pvStatus.put('ERROR')
-                    logger.error('%s failed' % (newCmd))
+                    logger.error('%s failed' % newCmd)
                     break
             elif newCmd == 'FINISH':
@@ -1437,5 +1425,5 @@
                     self.threadSetStatus.setStatus('ERROR')
                     self.pvStatus.put('ERROR')
-                    logger.error('%s failed' % (newCmd))
+                    logger.error('%s failed' % newCmd)
                     break
             elif newCmd == 'STOP':
@@ -1486,5 +1474,5 @@
                     self.threadSetStatus.setStatus('ERROR')
                     self.pvStatus.put('ERROR')
-                    logger.error('%s failed' % (newCmd))
+                    logger.error('%s failed' % newCmd)
                     break
             elif newCmd == 'RESET':
@@ -1506,5 +1494,5 @@
                     self.threadSetStatus.setStatus('ERROR')
                     self.pvStatus.put('ERROR')
-                    logger.error('%s failed' % (newCmd))
+                    logger.error('%s failed' % newCmd)
                     break
             else:
@@ -1565,4 +1553,5 @@
     # "==================="
     # connect Drone
+
     try:
         droneServer = getDroneServer()
@@ -1589,5 +1578,7 @@
     try:
         threadSetStatus = setStatus(1.0)
-        #threadSetStatus = setStatus(1.0)
+
+        # threadSetStatus = setStatus(1.0)
+
         threadSetStatus.setDaemon(True)
         threadSetStatus.start()
@@ -1601,6 +1592,6 @@
 
     try:
-        threadGetEpics = main(threadHeartbeat,
-                threadSetStatus, redisServer, droneServer)
+        threadGetEpics = main(threadHeartbeat, threadSetStatus,
+                              redisServer, droneServer)
         threadGetEpics.setDaemon(True)
         threadGetEpics.start()
Index: redis/redis_multiple.py
===================================================================
--- redis/redis_multiple.py	(revision 1887ff5d7cacc3730e6afa86842b75b553dc5c34)
+++ redis/redis_multiple.py	(revision 35fb6a283b9fc123d8e7eb5d3e3963e57c10f235)
@@ -1,7 +1,9 @@
 #!/usr/bin/python
+# -*- coding: utf-8 -*-
 
 import subprocess
 import os
 import sys
+
 
 # sudo fuser -k 9000/tcp
@@ -10,8 +12,11 @@
 
 def get_pid(name):
-    PID=[]
+    PID = []
     try:
-        #PID=map(int,subprocess.check_output(["pidof", name]).split())
-        PID=map(int,subprocess.check_output(["pgrep", "-f", name]).split())
+
+        # PID=map(int,subprocess.check_output(["pidof", name]).split())
+
+        PID = map(int, subprocess.check_output(['pgrep', '-f',
+                  name]).split())
     except:
         pass
@@ -19,7 +24,8 @@
     return PID
 
+
 def kill_PID(name):
     p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
+    (out, err) = p.communicate()
 
     for line in out.splitlines():
@@ -27,43 +33,48 @@
             pid = int(line.split(None, 1)[0])
             print pid
-            subprocess.Popen(['kill',  '-9',  str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-            #os.kill(pid, subprocess.signal.SIGKILL)
+            subprocess.Popen(['kill', '-9', str(pid)],
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+
+
+            # os.kill(pid, subprocess.signal.SIGKILL)
 
 def kill_process(name):
-    p="pkill -9 "+name
+    p = 'pkill -9 ' + name
     process = subprocess.call(p, shell=True)
-    #process.communicate()
+
+
+    # process.communicate()
 
 def redis_stop():
-    name="redis-server"
+    name = 'redis-server'
     kill_process(name)
-    name="redis-sentinel"
+    name = 'redis-sentinel'
     kill_process(name)
-  
-    print "INFO: Redis stopped!" 
-    ''' 
-    r=[]
-    r.append('ps -ef | grep redis-server')
-    r.append('ps -ef | grep redis-sentinel')
-    for p in r:
-        process = subprocess.call(p, shell=True)
-    '''
+
+    print 'INFO: Redis stopped!'
+
 
 def redis_start():
-    r=[]
-    r.append('/opt/shared/library/redis-4.0.1/bin/redis-server /home/neon/workspace/redis/node0/redis_9000.conf')
-    r.append('/opt/shared/library/redis-4.0.1/bin/redis-server /home/neon/workspace/redis/node1/redis_9010.conf')
-    r.append('/opt/shared/library/redis-4.0.1/bin/redis-sentinel /home/neon/workspace/redis/node0/sentinel_9000.conf')
-    r.append('/opt/shared/library/redis-4.0.1/bin/redis-sentinel /home/neon/workspace/redis/node1/sentinel_9010.conf')
+    r = []
+    r.append('/opt/shared/library/redis-4.0.1/bin/redis-server /home/neon/workspace/redis/node0/redis_9000.conf'
+             )
+    r.append('/opt/shared/library/redis-4.0.1/bin/redis-server /home/neon/workspace/redis/node1/redis_9010.conf'
+             )
+    r.append('/opt/shared/library/redis-4.0.1/bin/redis-sentinel /home/neon/workspace/redis/node0/sentinel_9000.conf'
+             )
+    r.append('/opt/shared/library/redis-4.0.1/bin/redis-sentinel /home/neon/workspace/redis/node1/sentinel_9010.conf'
+             )
     for p in r:
         subprocess.call(p, shell=True)
 
-    r=[]
+    r = []
     r.append('/opt/shared/library/redis-4.0.1/bin/redis-server')
     r.append('/opt/shared/library/redis-4.0.1/bin/redis-sentinel')
     for p in r:
         print get_pid(p)
-    
-    print "INFO: Redis started!" 
+
+    print 'INFO: Redis started!'
+
 
 def redis_restart():
@@ -71,13 +82,14 @@
     redis_start()
 
+
 if __name__ == '__main__':
-    cmd=sys.argv[1]
-    if cmd=="start":
+    cmd = sys.argv[1]
+    if cmd == 'start':
         redis_start()
-    elif cmd=="stop":
+    elif cmd == 'stop':
         redis_stop()
-    elif cmd=="restart":
+    elif cmd == 'restart':
         redis_restart()
     else:
-        print "start/stop/restart?"
+        print 'start/stop/restart?'
 
Index: redis/redis_single.py
===================================================================
--- redis/redis_single.py	(revision 1887ff5d7cacc3730e6afa86842b75b553dc5c34)
+++ redis/redis_single.py	(revision 35fb6a283b9fc123d8e7eb5d3e3963e57c10f235)
@@ -1,7 +1,9 @@
 #!/usr/bin/python
+# -*- coding: utf-8 -*-
 
 import subprocess
 import os
 import sys
+
 
 # sudo fuser -k 9000/tcp
@@ -10,8 +12,11 @@
 
 def get_pid(name):
-    PID=[]
+    PID = []
     try:
-        #PID=map(int,subprocess.check_output(["pidof", name]).split())
-        PID=map(int,subprocess.check_output(["pgrep", "-f", name]).split())
+
+        # PID=map(int,subprocess.check_output(["pidof", name]).split())
+
+        PID = map(int, subprocess.check_output(['pgrep', '-f',
+                  name]).split())
     except:
         pass
@@ -19,7 +24,8 @@
     return PID
 
+
 def kill_PID(name):
     p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
-    out, err = p.communicate()
+    (out, err) = p.communicate()
 
     for line in out.splitlines():
@@ -27,46 +33,51 @@
             pid = int(line.split(None, 1)[0])
             print pid
-            subprocess.Popen(['kill',  '-9',  str(pid)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-            #os.kill(pid, subprocess.signal.SIGKILL)
+            subprocess.Popen(['kill', '-9', str(pid)],
+                             stdout=subprocess.PIPE,
+                             stderr=subprocess.PIPE)
+
+
+            # os.kill(pid, subprocess.signal.SIGKILL)
 
 def kill_process(name):
-    p="pkill -9 "+name
+    p = 'pkill -9 ' + name
     process = subprocess.call(p, shell=True)
-    #process.communicate()
+
+
+    # process.communicate()
 
 def redis_stop():
-    name="redis-server"
+    name = 'redis-server'
     kill_process(name)
-    name="redis-sentinel"
+    name = 'redis-sentinel'
     kill_process(name)
-    print "INFO: Redis stopped!" 
-    ''' 
-    r=[]
-    r.append('ps -ef | grep redis-server')
-    r.append('ps -ef | grep redis-sentinel')
-    for p in r:
-        process = subprocess.call(p, shell=True)
-    '''
+    print 'INFO: Redis stopped!'
+
 
 def redis_start():
-    _cmd="grep redis-server | awk '{print $2}' | head -1"
-    pid=subprocess.check_output(_cmd, shell=True)
-    if pid!='':
-	pass
-    else:
-        _cmd="/opt/shared/library/redis-4.0.1/bin/redis-server /home/neon/workspace/redis/node0/redis_9000.conf"
-        subprocess.call(_cmd, shell=True)
-        print get_pid('/opt/shared/library/redis-4.0.1/bin/redis-server')
-   
-    _cmd="grep redis-server | awk '{print $2}' | head -1"
-    pid=subprocess.check_output(_cmd, shell=True)
-    if pid!='':
+    _cmd = "grep redis-server | awk '{print $2}' | head -1"
+    pid = subprocess.check_output(_cmd, shell=True)
+    if pid != '':
         pass
     else:
-        _cmd="/opt/shared/library/redis-4.0.1/bin/redis-sentinel /home/neon/workspace/redis/node0/sentinel_9000.conf"
+        _cmd = \
+            '/opt/shared/library/redis-4.0.1/bin/redis-server /home/neon/workspace/redis/node0/redis_9000.conf'
         subprocess.call(_cmd, shell=True)
-        print get_pid('/opt/shared/library/redis-4.0.1/bin/redis-sentinel')
- 
-    print "INFO: Redis started!" 
+        print get_pid('/opt/shared/library/redis-4.0.1/bin/redis-server'
+                      )
+
+    _cmd = "grep redis-server | awk '{print $2}' | head -1"
+    pid = subprocess.check_output(_cmd, shell=True)
+    if pid != '':
+        pass
+    else:
+        _cmd = \
+            '/opt/shared/library/redis-4.0.1/bin/redis-sentinel /home/neon/workspace/redis/node0/sentinel_9000.conf'
+        subprocess.call(_cmd, shell=True)
+        print get_pid('/opt/shared/library/redis-4.0.1/bin/redis-sentinel'
+                      )
+
+    print 'INFO: Redis started!'
+
 
 def redis_restart():
@@ -74,25 +85,14 @@
     redis_start()
 
+
 if __name__ == '__main__':
-    cmd=sys.argv[1]
-    if cmd=="start":
+    cmd = sys.argv[1]
+    if cmd == 'start':
         redis_start()
-    elif cmd=="stop":
+    elif cmd == 'stop':
         redis_stop()
-    elif cmd=="restart":
+    elif cmd == 'restart':
         redis_restart()
     else:
-        print "start/stop/restart?"
+        print 'start/stop/restart?'
 
-
-'''
-name="redis-server"
-print name, ":", get_pid(name)
-kill_PID(name)
-print name, ":", get_pid(name)
-
-name="redis-sentinel"
-print name, ":", get_pid(name)
-kill_PID(name)
-print name, ":", get_pid(name)
-'''
