How to use the pibooth.utils.LOGGER.warning function in pibooth

To help you get started, we’ve selected a few pibooth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github werdeil / pibooth / pibooth / booth.py View on Github external
def initialize(self):
        """Restore the application with initial parameters defined in the
        configuration file.
        Only parameters that can be changed at runtime are restored.
        """
        # Handle the language configuration
        language.CURRENT = self.config.get('GENERAL', 'language')
        fonts.CURRENT = fonts.get_filename(self.config.gettuple('PICTURE', 'text_fonts', str)[0])

        # Set the captures choices
        choices = self.config.gettuple('PICTURE', 'captures', int)
        for chx in choices:
            if chx not in [1, 2, 3, 4]:
                LOGGER.warning("Invalid captures number '%s' in config, fallback to '%s'",
                               chx, self.capture_choices)
                choices = self.capture_choices
                break
        self.capture_choices = choices

        # Reset printed pages number
        self.printer.nbr_printed = 0

        # Handle autostart of the application
        self.config.enable_autostart(self.config.getboolean('GENERAL', 'autostart'))

        self.window.arrow_location = self.config.get('WINDOW', 'arrows')
        self.window.arrow_offset = self.config.getint('WINDOW', 'arrows_x_offset')
        self.window.drop_cache()

        # Handle window size
github werdeil / pibooth / pibooth / printer.py View on Github external
if not cups:
            LOGGER.warning("No printer found (pycups or pycups-notify not installed)")
            return  # CUPS is not installed

        if not name or name.lower() == 'default':
            self.name = self._conn.getDefault()
            if not self.name and self._conn.getPrinters():
                self.name = list(self._conn.getPrinters().keys())[0]  # Take first one
        elif name in self._conn.getPrinters():
            self.name = name

        if not self.name:
            if name.lower() == 'default':
                LOGGER.warning("No printer configured in CUPS (see http://localhost:631)")
            else:
                LOGGER.warning("No printer named '%s' in CUPS (see http://localhost:631)", name)
        else:
            LOGGER.info("Connected to printer '%s'", self.name)
github werdeil / pibooth / pibooth / controls / camera.py View on Github external
def gp_set_config_value(config, section, option, value):
    """Set camera configuration. This method don't send the updated
    configuration to the camera (avoid connection flooding if several
    values have to be changed)
    """
    try:
        value = GP_PARAMS.get(PiConfigParser.language, GP_PARAMS['en']).get(value, value)
        LOGGER.debug('Setting option %s/%s=%s', section, option, value)
        child = config.get_child_by_name(section).get_child_by_name(option)
        choices = [c for c in child.get_choices()]
        if value not in choices:
            LOGGER.warning(
                "Invalid value '%s' for option %s (possible choices: %s), still trying to set it", value, option, choices)
            child.set_value(str(value))
        else:
            child.set_value(str(value))
    except gp.GPhoto2Error:
        raise ValueError('Unsupported setting {}/{}={}'.format(section, option, value))
github werdeil / pibooth / pibooth / camera / opencv.py View on Github external
image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        # Crop to keep aspect ratio of the resolution
        height, width = image.shape[:2]
        cropped = sizing.new_size_by_croping_ratio((width, height), self.resolution)
        image = image[cropped[1]:cropped[3], cropped[0]:cropped[2]]
        # Resize to fit the resolution
        height, width = image.shape[:2]
        size = sizing.new_size_keep_aspect_ratio((width, height), self.resolution, 'outer')
        image = cv2.resize(image, size, interpolation=cv2.INTER_AREA)

        if self._capture_hflip:
            image = cv2.flip(image, 1)

        if effect != 'none':
            LOGGER.warning("Effect with OpenCV camera is not implemented")

        return Image.fromarray(image)
github werdeil / pibooth / pibooth / config.py View on Github external
def reload(self):
        """Reload current configuration file.
        """
        self.read(self.filename)

        # Handle the language configuration, save it as a class attribute for easy access
        language = self.get('GENERAL', 'language')
        if language not in get_supported_languages():
            LOGGER.warning("Unsupported language '%s', fallback to English", language)
        else:
            PiConfigParser.language = language

        # Handle autostart of the application
        self.enable_autostart(self.getboolean('GENERAL', 'autostart'))
github werdeil / pibooth / pibooth / camera / gphoto.py View on Github external
"""Set camera configuration. This method don't send the updated
        configuration to the camera (avoid connection flooding if several
        values have to be changed)
        """
        try:
            LOGGER.debug('Setting option %s/%s=%s', section, option, value)
            config = self._cam.get_config()
            child = config.get_child_by_name(section).get_child_by_name(option)
            if child.get_type() == gp.GP_WIDGET_RADIO:
                choices = [c for c in child.get_choices()]
            else:
                choices = None
            data_type = type(child.get_value())
            value = data_type(value)  # Cast value
            if choices and value not in choices:
                LOGGER.warning(
                    "Invalid value '%s' for option %s (possible choices: %s), trying to set it anyway", value, option, choices)
            child.set_value(value)
            self._cam.set_config(config)
        except gp.GPhoto2Error as ex:
            LOGGER.error('Unsupported option %s/%s=%s (%s), configure your DSLR manually', section, option, value, ex)
github werdeil / pibooth / pibooth / printer.py View on Github external
self.max_pages = max_pages
        self.count = counters
        if not cups:
            LOGGER.warning("No printer found (pycups or pycups-notify not installed)")
            return  # CUPS is not installed

        if not name or name.lower() == 'default':
            self.name = self._conn.getDefault()
            if not self.name and self._conn.getPrinters():
                self.name = list(self._conn.getPrinters().keys())[0]  # Take first one
        elif name in self._conn.getPrinters():
            self.name = name

        if not self.name:
            if name.lower() == 'default':
                LOGGER.warning("No printer configured in CUPS (see http://localhost:631)")
            else:
                LOGGER.warning("No printer named '%s' in CUPS (see http://localhost:631)", name)
        else:
            LOGGER.info("Connected to printer '%s'", self.name)
github werdeil / pibooth / pibooth / booth.py View on Github external
def _initialize(self):
        """Restore the application with initial parameters defined in the
        configuration file.
        Only parameters that can be changed at runtime are restored.
        """
        # Handle the language configuration
        language.CURRENT = self._config.get('GENERAL', 'language')
        fonts.CURRENT = fonts.get_filename(self._config.gettuple('PICTURE', 'text_fonts', str)[0])

        # Set the captures choices
        choices = self._config.gettuple('PICTURE', 'captures', int)
        for chx in choices:
            if chx not in [1, 2, 3, 4]:
                LOGGER.warning("Invalid captures number '%s' in config, fallback to '%s'",
                               chx, self.capture_choices)
                choices = self.capture_choices
                break
        self.capture_choices = choices

        # Handle autostart of the application
        self._config.handle_autostart()

        self._window.arrow_location = self._config.get('WINDOW', 'arrows')
        self._window.arrow_offset = self._config.getint('WINDOW', 'arrows_x_offset')
        self._window.text_color = self._config.gettyped('WINDOW', 'text_color')
        self._window.drop_cache()

        # Handle window size
        size = self._config.gettyped('WINDOW', 'size')
        if isinstance(size, str) and size.lower() == 'fullscreen':