Ejemplo n.º 1
0
 def startProcess(self, index):
     if self.procStates[index] != STATE_READY:
         Log.w(
             "processe{%d} is not ready, state {%d}, please call setupProccesse() before"
             % (index, self.procStates[index]))
         return False
     self.processes[index].start()
     return True
Ejemplo n.º 2
0
    def terminateProcess(self, index):
        if self.procStates[index] == STATE_TERMINATE:
            Log.w("processe{%d} has been terminated!" % index)
            return False

        os.kill(self.processes[index].pid, signal.SIGINT)
        self.processes[index].join()
        self.procStates[index] = STATE_TERMINATE
        return True
Ejemplo n.º 3
0
 def load(self):
     try:
         with open(self.file_path, 'r') as fp:
             content = fp.read()
             fp.close()
             self.blackList = json.loads(content)
             return True
     except IOError:
         Log.w("{BlackSiteList.load} load file (%s) failed!",
               self.file_path)
         return False
Ejemplo n.º 4
0
 def save(self, file_path=None):
     if file_path == None:
         file_path = self.file_path
     try:
         with open(file_path, 'w') as fp:
             content = json.dumps(self.blackList)
             fp.write(content)
             fp.flush()
             fp.close()
             return True
     except IOError:
         Log.w("{BlackSiteList.save} save to file (%s) failed!",
               self.file_path)
         return False