當前位置: 首頁>>代碼示例>>Python>>正文


Python LOGGER.warning方法代碼示例

本文整理匯總了Python中config.LOGGER.warning方法的典型用法代碼示例。如果您正苦於以下問題:Python LOGGER.warning方法的具體用法?Python LOGGER.warning怎麽用?Python LOGGER.warning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在config.LOGGER的用法示例。


在下文中一共展示了LOGGER.warning方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handleTraceback

# 需要導入模塊: from config import LOGGER [as 別名]
# 或者: from config.LOGGER import warning [as 別名]
def handleTraceback(object):
    context = object.context
    entry_url = object.entry_url

    if entry_url is None:
        return

    LOGGER.info("handle traceback [%s]" % entry_url)
    try:
        cleanup_lock.acquire()
        # we don't want to produce any errors here, thus, we'll be nice and die
        # silently if an error occurs here
        try:
            transaction.begin()
            # get our logbook view to use the api
            logbook = context.unrestrictedTraverse('@@logbook')
            # get the generated error url from Products.SiteErrorLog
            err_id = urllib.splitvalue(entry_url)[1]
            # save error
            logbook.save_error(err_id, context=aq_parent(context))
            transaction.get().note('collective.logbook traceback [%s]' %
                    entry_url)
            transaction.commit()
        finally:
            cleanup_lock.release()
    # only warning
    except Exception, e:
        LOGGER.warning("An error occured while handling the traceback")
        LOGGER.warning("%s" % e)
        LOGGER.exception(e)
開發者ID:miohtama,項目名稱:collective.logbook-1,代碼行數:32,代碼來源:events.py

示例2: run

# 需要導入模塊: from config import LOGGER [as 別名]
# 或者: from config.LOGGER import warning [as 別名]
def run():
    # TODO: break this into smaller functions
    LOGGER.info('Running music downloader...')
    tracks_to_download = get_tracks_to_download()
    if not tracks_to_download:
        LOGGER.info('No queued tracks found in database')
        return
    LOGGER.info('Found {} tracks from database to download...'.format(len(tracks_to_download)))
    options = {
        'format': 'bestaudio/best',
        'postprocessors': [{
            'key': 'FFmpegExtractAudio',
            'preferredcodec': 'mp3',
            'preferredquality': '192',
        }],
        'quiet': False}

    for queued_track in tracks_to_download:
        exists = session.query(SavedTrack).filter(SavedTrack.artist == queued_track.artist,
                                                  SavedTrack.title == queued_track.title).count() > 0
        if exists:
            LOGGER.info('Track already exists as Saved Track, deleting Queued track and skipping download.')
            session.delete(queued_track)
            session.commit()
            continue
        track_save_name = u'{} - {}'.format(queued_track.artist, queued_track.title)
        final_track_path = TRACK_DIRECTORY + track_save_name + '.mp3'
        holding_track_path = HOLD_DIRECTORY + track_save_name + '.mp3'
        LOGGER.info('Downloading track: {}'.format(track_save_name))
        options['outtmpl'] = u'{}/{}.%(ext)s'.format(HOLD_DIRECTORY, track_save_name)
        ydl = youtube_dl.YoutubeDL(options)
        download_link = build_download_link(queued_track.youtube_video_id)
        # download the track
        try:
            ydl.download([download_link])
        except youtube_dl.utils.DownloadError as e:
            LOGGER.warning('youtube-dl encountered an error: {}' .format(e.message))
            continue
        saved_track = SavedTrack()
        saved_track.update_from_dict(queued_track.as_dict())
        saved_track.path = final_track_path
        saved_track.md5 = calculate_md5(holding_track_path)
        fingerprint_duration = fingerprint_file(holding_track_path, 30)
        saved_track.fingerprint = fingerprint_duration[1]
        saved_track.duration = fingerprint_duration[0]

        session.merge(saved_track)
        session.delete(queued_track)
        session.commit()
        os.rename(holding_track_path, final_track_path)
        LOGGER.info('Complete. Downloaded track data committed to database.')
開發者ID:chrismv48,項目名稱:music-master,代碼行數:53,代碼來源:downloader.py


注:本文中的config.LOGGER.warning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。