How to use the picard.log.warning function in picard

To help you get started, we’ve selected a few picard 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 metabrainz / picard / picard / ui / mainwindow.py View on Github external
def update_cd_lookup_drives(self, drives):
        if not drives:
            log.warning("CDROM: No CD-ROM drives found - Lookup CD functionality disabled")
        else:
            shortcut_drive = config.setting["cd_lookup_device"].split(",")[0] if len(drives) > 1 else ""
            self.cd_lookup_action.setEnabled(discid is not None)
            self.cd_lookup_menu.clear()
            for drive in drives:
                action = self.cd_lookup_menu.addAction(drive)
                action.setData(drive)
                if drive == shortcut_drive:
                    # Clear existing shortcode on main action and assign it to sub-action
                    self.cd_lookup_action.setShortcut(QtGui.QKeySequence())
                    action.setShortcut(QtGui.QKeySequence(_("Ctrl+K")))
        self._update_cd_lookup_button()
github metabrainz / picard / picard / ui / playertoolbar.py View on Github external
self._player = None
        self._toolbar = None
        self._selected_objects = []
        if qt_multimedia_available:
            log.debug('Internal player: QtMultimedia available, initializing QMediaPlayer')
            player = QtMultimedia.QMediaPlayer(parent)
            player.setAudioRole(QtMultimedia.QAudio.MusicRole)
            self.state_changed = player.stateChanged
            self._logarithmic_volume = get_logarithmic_volume(player.volume())
            availability = player.availability()
            if availability == QtMultimedia.QMultimedia.Available:
                log.debug('Internal player: available, QMediaPlayer set up')
                self._player = player
                self._player.error.connect(self._on_error)
            elif availability == QtMultimedia.QMultimedia.ServiceMissing:
                log.warning("Internal player: unavailable, service is missing")
            else:
                log.warning("Internal player: unavailable, status=%d", availability)
        else:
            log.warning("Internal player: unavailable, %s", qt_multimedia_errmsg)
github metabrainz / picard / picard / pluginmanager.py View on Github external
def zip_import(path):
    if (not is_zip(path) or not os.path.isfile(path)):
        return (None, None, None)
    try:
        zip_importer = zipimport.zipimporter(path)
        plugin_name = _plugin_name_from_path(path)
        manifest_data = None
        if is_zipped_package(path):
            try:
                manifest_data = load_manifest(path)
            except Exception as why:
                log.warning("Failed to load manifest data from json: %s", why)
        return (zip_importer, plugin_name, manifest_data)
    except zipimport.ZipImportError as why:
        log.error("ZIP import error: %s", why)
        return (None, None, None)
github metabrainz / picard / picard / ui / infodialog.py View on Github external
row_count = self.artwork_table.rowCount()
        for image in images:
            while row != row_count:
                image_type = self.artwork_table.item(row, self.artwork_table._type_col)
                if image_type and image_type.data(QtCore.Qt.UserRole) == image.types_as_string():
                    break
                row += 1
            if row == row_count:
                continue
            data = None
            try:
                if image.thumbnail:
                    try:
                        data = image.thumbnail.data
                    except CoverArtImageIOError as e:
                        log.warning(e)
                else:
                    data = image.data
            except CoverArtImageIOError:
                log.error(traceback.format_exc())
                continue
            item = QtWidgets.QTableWidgetItem()
            item.setData(QtCore.Qt.UserRole, image)
            pixmap = QtGui.QPixmap()
            if data is not None:
                pixmap.loadFromData(data)
                item.setToolTip(
                    _("Double-click to open in external viewer\n"
                      "Temporary file: %s\n"
                      "Source: %s") % (image.tempfile_filename, image.source))
            infos = []
            if image.comment:
github fdemmer / Picard-Last.fm.ng-Plugin / lastfmng / settings.py View on Github external
def load_config_file(filename, cfg=None):
    full_path = os.path.join(os.path.dirname(__file__), filename)
    if not cfg:
        cfg = ConfigParser()

    try:
        with codecs.open(full_path, 'r', 'utf8') as fh:
            cfg.read_file(fh)
    except UnicodeDecodeError:
        log.warning('Configuration is not UTF-8 encoded, trying ISO-8859!')
        with codecs.open(full_path, 'r', 'latin_1') as fh:
            cfg.read_file(fh)
    except IOError:
        pass

    return cfg
github metabrainz / picard-plugins / plugins / workandmovement / __init__.py View on Github external
`create_work_and_movement_from_title`.
    """
    movement_title = work.title
    if work.parent:
        work_title = work.parent.title
        if movement_title.startswith(work_title):
            movement_title = movement_title[len(work_title):].lstrip(':').strip()
    match = _re_part_number.match(movement_title)
    if match:
        # Only remove the number if it matches the part_number
        try:
            number = number_to_int(match.group('number'))
            if number == work.part_number:
                movement_title = _re_part_number.sub("", movement_title)
        except ValueError as e:
            log.warning(e)
    return movement_title
github metabrainz / picard / picard / formats / asf.py View on Github external
def _load(self, filename):
        log.debug("Loading file %r", filename)
        self.__casemap = {}
        file = ASF(encode_filename(filename))
        metadata = Metadata()
        for name, values in file.tags.items():
            if name == 'WM/Picture':
                for image in values:
                    try:
                        (mime, data, type_, description) = unpack_image(image.value)
                    except ValueError as e:
                        log.warning('Cannot unpack image from %r: %s',
                                    filename, e)
                        continue
                    try:
                        coverartimage = TagCoverArtImage(
                            file=filename,
                            tag=name,
                            types=types_from_id3(type_),
                            comment=description,
                            support_types=True,
                            data=data,
                        )
                    except CoverArtImageError as e:
                        log.error('Cannot load image from %r: %s' %
                                  (filename, e))
                    else:
                        metadata.images.append(coverartimage)
github metabrainz / picard / picard / ui / mainwindow.py View on Github external
self.search_action = QtWidgets.QAction(icontheme.lookup('system-search'), _("Search"), self)
        self.search_action.setEnabled(False)
        self.search_action.triggered.connect(self.search)

        self.cd_lookup_action = QtWidgets.QAction(icontheme.lookup('media-optical'), _("Lookup &CD..."), self)
        self.cd_lookup_action.setStatusTip(_("Lookup the details of the CD in your drive"))
        # TR: Keyboard shortcut for "Lookup CD"
        self.cd_lookup_action.setShortcut(QtGui.QKeySequence(_("Ctrl+K")))
        self.cd_lookup_action.triggered.connect(self.tagger.lookup_cd)

        self.cd_lookup_menu = QtWidgets.QMenu(_("Lookup &CD..."))
        self.cd_lookup_menu.triggered.connect(self.tagger.lookup_cd)
        self.cd_lookup_action.setEnabled(False)
        if discid is None:
            log.warning("CDROM: discid library not found - Lookup CD functionality disabled")
        else:
            thread.run_task(get_cdrom_drives, self._update_cd_lookup_actions)

        self.analyze_action = QtWidgets.QAction(icontheme.lookup('picard-analyze'), _("&Scan"), self)
        self.analyze_action.setStatusTip(_("Use AcoustID audio fingerprint to identify the files by the actual music, even if they have no metadata"))
        self.analyze_action.setEnabled(False)
        self.analyze_action.setToolTip(_('Identify the file using its AcoustID audio fingerprint'))
        # TR: Keyboard shortcut for "Analyze"
        self.analyze_action.setShortcut(QtGui.QKeySequence(_("Ctrl+Y")))
        self.analyze_action.triggered.connect(self.analyze)

        self.cluster_action = QtWidgets.QAction(icontheme.lookup('picard-cluster'), _("Cl&uster"), self)
        self.cluster_action.setStatusTip(_("Cluster files into album clusters"))
        self.cluster_action.setEnabled(False)
        # TR: Keyboard shortcut for "Cluster"
        self.cluster_action.setShortcut(QtGui.QKeySequence(_("Ctrl+U")))
github metabrainz / picard-plugins / plugins / smart_title_case / smart_title_case.py View on Github external
new_artists = list(map(string_title_case, artists))
            new_artist = [artist_title_case(x, artists, new_artists) for x in artist]
            if artists != new_artists and artist != new_artist:
                log.debug("SmartTitleCase: %s: %s replaced with %s", artist_string, artist, new_artist)
                log.debug("SmartTitleCase: %s: %r replaced with %r", artists_list, artists, new_artists)
                metadata[artist_string] = new_artist
                metadata[artists_list] = new_artists
            elif artists != new_artists or artist != new_artist:
                if artists != new_artists:
                    log.warning("SmartTitleCase: %s changed, %s wasn't", artists_list, artist_string)
                    log.warning("SmartTitleCase: %s: %r changed to %r", artists_list, artists, new_artists)
                    log.warning("SmartTitleCase: %s: %r unchanged", artist_string, artist)
                else:
                    log.warning("SmartTitleCase: %s changed, %s wasn't", artist_string, artists_list)
                    log.warning("SmartTitleCase: %s: %r changed to %r", artist_string, artist, new_artist)
                    log.warning("SmartTitleCase: %s: %r unchanged", artists_list, artists)