Exemplo n.º 1
0
 def __init__(self):
     self.nv_log_handler = \
         nv_logger(self.__class__.__name__).get_logger()
     self.nv_log_handler_rl = \
         nv_logger_rl(nv_log_obj = self.nv_log_handler, timeout = 15)
     self.cam_stream_stop_event = Event()
     threading.Thread.__init__(self, None, None, "nv_watchdog",
                               args=(self.cam_stream_stop_event,))
     self.daemon = True
Exemplo n.º 2
0
 def __init__(self):
     # Initialize the thread manager
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.cam_thread_dic = {}
     self.join_cam_thread_dic = {}
     # Live streaming dictionary, A dictionary maintained for live streaming
     # threads.
     self.cam_live_threads = {}
     # camera live threads for join
     self.join_cam_live_threads = {}
Exemplo n.º 3
0
 def __init__(self):
     # Initialize the thread manager
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.cam_thread_dic = {}
     self.join_cam_thread_dic = {}
     # Live streaming dictionary, A dictionary maintained for live streaming
     # threads.
     self.cam_live_threads = {}
     # camera live threads for join
     self.join_cam_live_threads = {}
Exemplo n.º 4
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     if platform.system() == 'Linux':
         self.context = nv_linux_lib()
     elif platform.system() == 'Windows':
         self.nv_log_handler.error("Windows support is not available now.")
         raise NotImplementedError("Windows support is not available.")
     else:
         self.nv_log_handler.error("The platform cannot determined ")
         raise NotImplementedError("Unsupported platform %s" 
                                   % platform.system())
Exemplo n.º 5
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.db_engine = create_engine(NVDB_SQLALCHEMY_DB,
                                 connect_args={'check_same_thread': False},
                                 poolclass=StaticPool, echo=False)
     session_maker = sessionmaker(bind=self.db_engine)
     self.Session = scoped_session(session_maker)
     self.db_session = None
     db_base.metadata.create_all(self.db_engine)
     self.nv_midbox_db_entry = None
     self.nv_webserver = None
     self.nv_log_handler.debug("Tables created in nvdb")
Exemplo n.º 6
0
 def __init__(self):
     self.nv_log_handler = \
         nv_logger(self.__class__.__name__).get_logger()
     self.nv_log_handler_rl = \
         nv_logger_rl(nv_log_obj = self.nv_log_handler, timeout = 15)
     self.cam_stream_stop_event = Event()
     threading.Thread.__init__(self,
                               None,
                               None,
                               "nv_watchdog",
                               args=(self.cam_stream_stop_event, ))
     self.daemon = True
Exemplo n.º 7
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.db_engine = create_engine(
         NVDB_SQLALCHEMY_DB,
         connect_args={'check_same_thread': False},
         poolclass=StaticPool,
         echo=False)
     session_maker = sessionmaker(bind=self.db_engine)
     self.Session = scoped_session(session_maker)
     self.db_session = None
     db_base.metadata.create_all(self.db_engine)
     self.nv_midbox_db_entry = None
     self.nv_webserver = None
     self.nv_log_handler.debug("Tables created in nvdb")
Exemplo n.º 8
0
    def __init__(self, cam_tbl_entry=None):
        self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
        self.time_lapse = cam_tbl_entry.stream_file_time_sec

        self.cam_id = str(cam_tbl_entry.cam_id)
        self.name = cam_tbl_entry.name
        self.cam_dir = self.name
        self.username = cam_tbl_entry.username
        self.pwd = cam_tbl_entry.password
        self.cam_ip = str(ipaddress.IPv4Address(cam_tbl_entry.ip_addr))
        self.cam_listen_port = str(cam_tbl_entry.listen_port)
        self.os_context = nv_os_lib()
        self.nv_log_handler.debug("Initialized the camera handler for %s.",
                                  self.name)
        self.cam_thread_obj = None
        self.cam_stream_stop_event = Event()
        self.vlc_thread = None
Exemplo n.º 9
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.cam_thread_mgr = None
     self.nv_midbox_cli = None
     self.nv_relay_mgr = None
     self.cam_thread_mgr = thread_manager()
     try:
         self.nv_relay_mgr = relay_main()
         self.nv_relay_mgr.process_relay()
         self.midbox_camera_init()
         self.nv_midbox_cli = nv_middlebox_cli()
         self.nv_midbox_cli.start()
     except Exception as e:
         self.nv_log_handler.error("Unknown exception while starting"
                                   " the middlebox : %s", e)
         self.exit_all_threads()
         raise e
Exemplo n.º 10
0
 def __init__(self):
     '''
     *_dic contain list of syncronization primitives as below.
     {
         'name1' : 'obj1',
         'name2' : 'obj2'
     }
     or dictionary can be like
     {
         'name1' : ['lock-obj1', thread-name, lock-time],
         'name2' : ['lock-obj2', thread-name, lock-time]
     }
     '''
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     # Mutex dictionary has a list of elements,
     self.mutex_dic = {}
     self.rlock_dic = {}
     pass
Exemplo n.º 11
0
 def __init__(self):
     '''
     *_dic contain list of syncronization primitives as below.
     {
         'name1' : 'obj1',
         'name2' : 'obj2'
     }
     or dictionary can be like
     {
         'name1' : ['lock-obj1', thread-name, lock-time],
         'name2' : ['lock-obj2', thread-name, lock-time]
     }
     '''
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     # Mutex dictionary has a list of elements,
     self.mutex_dic = {}
     self.rlock_dic = {}
     pass
Exemplo n.º 12
0
    def __init__(self):
        '''
        Dictionary to hold the different queues. the dictionary will be looks
        like
        cam_stream_queue_dic = {
                            'camera1' : [queue1, camera_timer_obj]
                            'camera2' : [queue2, camera_timer_obj]
                             .....
                             }
        the queues are holding the series of file-pairs. for eg:
        queue1 = <[src1, dst1], [src2. dst2], ....>

        camera_timer_obj is used to determine the liveness of camera. If a
        camera generates invalid streams(less than valid size) continuously
        for a period(NV_CAM_CONN_TIMEOUT), then the camera will move to
        disconnected state.
        '''
        self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
        self.cam_stream_queue_dic = {}
Exemplo n.º 13
0
    def __init__(self):
        '''
        Dictionary to hold the different queues. the dictionary will be looks
        like
        cam_stream_queue_dic = {
                            'camera1' : [queue1, camera_timer_obj]
                            'camera2' : [queue2, camera_timer_obj]
                             .....
                             }
        the queues are holding the series of file-pairs. for eg:
        queue1 = <[src1, dst1], [src2. dst2], ....>

        camera_timer_obj is used to determine the liveness of camera. If a
        camera generates invalid streams(less than valid size) continuously
        for a period(NV_CAM_CONN_TIMEOUT), then the camera will move to
        disconnected state.
        '''
        self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
        self.cam_stream_queue_dic = {}
Exemplo n.º 14
0
 def __init__(self, cam_tbl_entry = None):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     if cam_tbl_entry is None:
         self.nv_log_handler.error("Cannot start live preview for empty"
                                   "camera entry")
         return
     self.cam_id = cam_tbl_entry.cam_id
     self.cam_name = cam_tbl_entry.name
     self.live_url = cam_tbl_entry.live_url
     self.cam_uname = cam_tbl_entry.username
     self.cam_pwd = cam_tbl_entry.password
     self.cam_ip = str(ipaddress.IPv4Address(cam_tbl_entry.ip_addr))
     self.cam_listen_port = str(cam_tbl_entry.listen_port)
     self.os_context = nv_os_lib()
     self.live_thread_cmd = None
     self.live_cam_thread = None
     self.cam_live_stop_event = Event()
     # Do not modify the value in methods
     self.const_stream_len_sec = cam_tbl_entry.stream_file_time_sec
     # Do not modify this value in any of methods
     self.const_live_stream_timeout = self.const_stream_len_sec * 4
     self.stream_state = cam_tbl_entry.status
     self.state_chk_timeout = self.const_stream_len_sec
Exemplo n.º 15
0
 def __init__(self, q_name = "default_queue", max_size = 10000):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.ipc_queue = Queue(maxsize = max_size)
     self.q_name = q_name
     self.CONST_IPCQ_MUTEX = q_name
Exemplo n.º 16
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     threading.Thread.__init__(self, None, None, "nv_midbox_cli")
     self.daemon = True  # Kill the cli thread when main thread exits.
Exemplo n.º 17
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.connections = set()
Exemplo n.º 18
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     threading.Thread.__init__(self, None, None, "nv_midbox_ws")
     self.daemon = True
     self.os_context = nv_os_lib()
Exemplo n.º 19
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.ssh = None
     self.sftp = None
Exemplo n.º 20
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.os_context = nv_os_lib()
     self.watcher_obj = relay_watcher()
     self.observer_obj = Observer()
Exemplo n.º 21
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.websrv = None
     self.ftp_obj = relay_ftp_handler()
     self.is_relay_thread_killed = False # flag for tracking user kill.
Exemplo n.º 22
0
 def __init__(self, q_name="default_queue", max_size=10000):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.ipc_queue = Queue(maxsize=max_size)
     self.q_name = q_name
     self.CONST_IPCQ_MUTEX = q_name
Exemplo n.º 23
0
 def __init__(self):
     self.ws_key = ws_token()
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.ws_client = None
Exemplo n.º 24
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.os_context = nv_os_lib()
     self.watcher_obj = relay_watcher()
     self.observer_obj = Observer()
Exemplo n.º 25
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.os_context = nv_os_lib()
     self.websrv = None
     self.sftp = None
     self.queue_mgr = relay_queue_mgr()
Exemplo n.º 26
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.websrv = None
     self.ftp_obj = relay_ftp_handler()
     self.is_relay_thread_killed = False  # flag for tracking user kill.
Exemplo n.º 27
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.os_context = nv_os_lib()
     self.websrv = None 
     self.sftp = None
     self.queue_mgr = relay_queue_mgr()
Exemplo n.º 28
0
 def __init__(self):
     self.nv_log_handler = nv_logger(self.__class__.__name__).get_logger()
     self.nv_cli_mgr = None # Cli thread to read user inputs.
     self.nv_conf = None
     self.nv_websock = None
     self.watchdog = None