def do_POST(self):
     """ POST """
     APPLOGGER.debug(self.path)
     try:
         _environ = {
             'REQUEST_METHOD': 'POST',
             'CONTENT_TYPE': self.headers['Content-Type'],
         }
     except KeyError as ex:
         _environ = {}
         APPLOGGER.warn(ex)
     form = cgi.FieldStorage(fp=self.rfile,
                             headers=self.headers,
                             environ=_environ)
     action = self.path
     callinfo = action.replace('/', ' ').strip(' ')
     callinfo = '__' + callinfo
     try:
         callback = getattr(self, '_' + self.__class__.__name__ + callinfo)
         if callback != None and callable(callback):
             callback(form)
         else:
             APPLOGGER.debug(self.path)
             APPLOGGER.debug(str(form))
             self.send_response(503)
             self.end_headers()
     except AttributeError as ex:
         APPLOGGER.error(ex)
 def do_POST(self):
     """ POST """
     APPLOGGER.debug(self.path)
     try:
         _environ = {'REQUEST_METHOD': 'POST',
                     'CONTENT_TYPE': self.headers['Content-Type'],}
     except KeyError as ex:
         _environ = {}
         APPLOGGER.warn(ex)
     form = cgi.FieldStorage(fp=self.rfile,
                             headers=self.headers,
                             environ=_environ)
     action = self.path
     callinfo = action.replace('/', ' ').strip(' ')
     callinfo = '__' + callinfo
     try:
         callback = getattr(self, '_' + self.__class__.__name__ + callinfo)
         if callback != None and callable(callback):
             callback(form)
         else:
             APPLOGGER.debug(self.path)
             APPLOGGER.debug(str(form))
             self.send_response(503)
             self.end_headers()
     except AttributeError as ex:
         APPLOGGER.error(ex)
 def getvalue(src):
     """ set value """
     retval = -1
     try:
         retval = int(src)
     except ValueError as ex:
         APPLOGGER.warn(ex)
     return retval
 def getvalue(src):
     """ set value """
     retval = -1
     try:
         retval = int(src)
     except ValueError as ex:
         APPLOGGER.warn(ex)
     return retval
 def __stop(self, form):
     """ stop the video process """
     _ = form
     self.vvpmng.getlock()
     try:
         if not self.vvpmng.isset():
             APPLOGGER.warn('no process to stop')
             self.__sendmsg(200, 'no process to stop')
             return  # jump to finally
         if self.vvpmng.isrun():
             self.vvpmng.stop()
             APPLOGGER.warn('terminating..')
             self.vvpmng.setprocess(None)
             self.__sendmsg(200, 'terminating..')
         else:
             APPLOGGER.info('process is terminate')
             self.vvpmng.setprocess(None)
             self.__sendmsg(200, 'process is terminated')
     finally:
         self.vvpmng.releaselock()
 def __stop(self, form):
     """ stop the video process """
     _ = form
     self.vvpmng.getlock()
     try:
         if not self.vvpmng.isset():
             APPLOGGER.warn('no process to stop')
             self.__sendmsg(200, 'no process to stop')
             return # jump to finally
         if self.vvpmng.isrun():
             self.vvpmng.stop()
             APPLOGGER.warn('terminating..')
             self.vvpmng.setprocess(None)
             self.__sendmsg(200, 'terminating..')
         else:
             APPLOGGER.info('process is terminate')
             self.vvpmng.setprocess(None)
             self.__sendmsg(200, 'process is terminated')
     finally:
         self.vvpmng.releaselock()
 def __stop(self):
     """ __stop_process """
     self.vvpmng.getlock()
     try:
         if not self.vvpmng.isset():
             APPLOGGER.warn('no process to stop')
             self.request.sendall(self.clientcmd_stop + '|' + '0')
             return  #just jump to finally
         if self.vvpmng.isrun():
             self.vvpmng.stop()
             APPLOGGER.warn('terminating..')
             self.vvpmng.setprocess(None)
             # fake done
             self.request.sendall(self.clientcmd_stop + '|' + '1')
         else:
             APPLOGGER.info('process is terminate')
             self.vvpmng.setprocess(None)
             self.request.sendall(self.clientcmd_stop + '|' + '0')
     finally:
         self.vvpmng.process_cmd.record = False
         self.vvpmng.process_cmd.recordfname = ''
         self.request.close()
         self.vvpmng.releaselock()
 def __stop(self):
     """ __stop_process """
     self.vvpmng.getlock()
     try:
         if not self.vvpmng.isset():
             APPLOGGER.warn('no process to stop')
             self.request.sendall(self.clientcmd_stop + '|' + '0')
             return #just jump to finally
         if self.vvpmng.isrun():
             self.vvpmng.stop()
             APPLOGGER.warn('terminating..')
             self.vvpmng.setprocess(None)
             # fake done
             self.request.sendall(self.clientcmd_stop + '|' + '1')
         else:
             APPLOGGER.info('process is terminate')
             self.vvpmng.setprocess(None)
             self.request.sendall(self.clientcmd_stop + '|' + '0')
     finally:
         self.vvpmng.process_cmd.record = False
         self.vvpmng.process_cmd.recordfname = ''
         self.request.close()
         self.vvpmng.releaselock()
 def __process_req(self, data):
     """ process req """
     data = data.strip(' \n')
     if len(data) <= 0:
         return
     callinfo = data.lower()
     callinfo = '__' + callinfo
     callinfo = callinfo.split('|')
     splitlen = len(callinfo)
     if splitlen < 1 or splitlen > 2:
         APPLOGGER.warn('request parameter not correct')
         return
     try:
         callback = getattr(self, '_' + \
                 self.__class__.__name__ + callinfo[0])
         if callback != None and callable(callback):
             if splitlen == 1:
                 callback()
             else:
                 callback(data)
         else:
             APPLOGGER.error('request callback error')
     except AttributeError as ex:
         APPLOGGER.error(ex)
 def __process_req(self, data):
     """ process req """
     data = data.strip(' \n')
     if len(data) <= 0:
         return
     callinfo = data.lower()
     callinfo = '__' + callinfo
     callinfo = callinfo.split('|')
     splitlen = len(callinfo)
     if splitlen < 1 or splitlen > 2:
         APPLOGGER.warn('request parameter not correct')
         return
     try:
         callback = getattr(self, '_' + \
                 self.__class__.__name__ + callinfo[0])
         if callback != None and callable(callback):
             if splitlen == 1:
                 callback()
             else:
                 callback(data)
         else:
             APPLOGGER.error('request callback error')
     except AttributeError as ex:
         APPLOGGER.error(ex)