Ejemplo n.º 1
0
    def __init__(self):
        gpio.setwarnings(False)
        gpio.setmode(gpio.BOARD)

        self.logger = logger.Logger()
        self.config = config.Config()
        self.config.read_config()

        self.cameras_switcher = cameras_switcher.CamerasSwitcher(gpio)
        self.pi_camera = PiCamera()
        self.pi_camera.resolution = (1920, 1080)
        self.protected_areas = protected_areas.ProtectedAreas(self.logger, gpio, self.cameras_switcher, self.pi_camera)
        self.modem = modem.Modem(self.logger)
        self.email = email_sender.EmailSender(self.logger, self.config)
        self.sms = sms.Sms(self.config, self.email)

        self.detectors_controller = detectors.Detectors(self.config, self.protected_areas)
        self.avail_space_controller = avail_space.AvailSpace(self.logger)
        self.alarm_controller = alarm.Alarm(
            self.logger,
            self.config,
            self.avail_space_controller,
            self.detectors_controller,
            self.protected_areas,
            self.sms,
            self.email)
Ejemplo n.º 2
0
    def setUp(self):
        self.logger = logging.getLogger('MotionNotify')
        self.logger.level = logging.DEBUG
        self.logger.addHandler(logging.StreamHandler(sys.stdout))

        self.config = config_mod.Config("../motion-notify.cfg")
        self.config.set_on_event_start_event_action_list("SmtpEmailNotifyAction:if_active")
        self.config.set_on_picture_save_event_action_list(
            "GoogleDriveUploadAction:always,SmtpEmailNotifyAction:if_active")
        self.config.set_on_movie_end_event_action_list("SmtpEmailNotifyAction:if_active")
        pass
Ejemplo n.º 3
0
def bottle_worker(host, port):
    bottle.run(host=host, port=port, server="gevent")


if __name__ == "__main__":
    # Create folders if needed
    console.printn("> Checking folders...")
    paths = [".data"]
    for i in paths:
        if not os.path.exists(i):
            os.makedirs(i, 0o770)
    console.done()

    # Load and check config.json
    console.printn("> Loading config file...")
    glob.config = config.Config()
    # TODO: Use exceptions
    if glob.config.status != config.ConfigStatus.VALID:
        console.warning()

        if glob.config.status == config.ConfigStatus.DOESNT_EXIST:
            console.colored("> The config file doesn't exist", bcolors.YELLOW)
        elif glob.config.status == config.ConfigStatus.INVALID:
            console.colored("> The config file has an invalid structure",
                            bcolors.YELLOW)
        elif glob.config.status == config.ConfigStatus.INVALID_SYNTAX:
            console.colored("> Couldn't parse config.json", bcolors.YELLOW)
        else:
            console.colored("> Unknown error", bcolors.YELLOW)

        yn = input("> Do you want to generate a default config.json? (y/n): ")
Ejemplo n.º 4
0
        logger.debug("All events actions handled...")

    def __init__(self, config_obj, motion_event_obj):
        logger.debug("Initializing...")
        self.config_obj = config_obj
        self.motion_event_obj = motion_event_obj
        self.is_system_active = False
        self.handle_event()


if __name__ == '__main__':
    logger.info("Motion Notify script started")
    try:

        if len(sys.argv) < 6:
            exit(
                'Motion Notify - Usage: motion-notify.py {config-file-path} {media-file-path} {event-type on_event_start, on_picture_save or on_movie_end} {timestamp} {event_id} {file_type} ')

        cfg_path = sys.argv[1]
        if not os.path.exists(cfg_path):
            exit('Config file does not exist [%s]' % cfg_path)

        motion_event_obj = motion_event_mod.MotionEvent(sys.argv[2], event_type_mod.EventType[sys.argv[3]], sys.argv[4],
                                                        sys.argv[5],
                                                sys.argv[6])

        MotionNotify(config_mod.Config(cfg_path), motion_event_obj)
    except Exception as e:
        logger.error("Initialization error..." + e.__str__())
        exit('Error: [%s]' % e)