当前位置: 首页>>代码示例>>Python>>正文


Python logger.log方法代码示例

本文整理汇总了Python中logger.log方法的典型用法代码示例。如果您正苦于以下问题:Python logger.log方法的具体用法?Python logger.log怎么用?Python logger.log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在logger的用法示例。


在下文中一共展示了logger.log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def __init__(self, params):
        configure_logger(params['output_dir'])
        log('Parameters {}'.format(params))
        self.params = params
        self.binding = load_bindings(params['rom_file_path'])
        self.max_word_length = self.binding['max_word_length']
        self.sp = spm.SentencePieceProcessor()
        self.sp.Load(params['spm_file'])
        kg_env = KGA2CEnv(params['rom_file_path'], params['seed'], self.sp,
                          params['tsv_file'], step_limit=params['reset_steps'],
                          stuck_steps=params['stuck_steps'], gat=params['gat'])
        self.vec_env = VecEnv(params['batch_size'], kg_env, params['openie_path'])
        self.template_generator = TemplateActionGenerator(self.binding)
        env = FrotzEnv(params['rom_file_path'])
        self.vocab_act, self.vocab_act_rev = load_vocab(env)
        self.model = KGA2C(params, self.template_generator.templates, self.max_word_length,
                           self.vocab_act, self.vocab_act_rev, len(self.sp), gat=self.params['gat']).cuda()
        self.batch_size = params['batch_size']
        if params['preload_weights']:
            self.model = torch.load(self.params['preload_weights'])['model']
        self.optimizer = optim.Adam(self.model.parameters(), lr=params['lr'])

        self.loss_fn1 = nn.BCELoss()
        self.loss_fn2 = nn.BCEWithLogitsLoss()
        self.loss_fn3 = nn.MSELoss() 
开发者ID:rajammanabrolu,项目名称:KG-A2C,代码行数:27,代码来源:gdqn.py

示例2: convertImgurIndirectUrlToImg

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def convertImgurIndirectUrlToImg(submission, imgurAuth, url):
    # Login to imgur
    # This is required since they made NSFW images require login
    imgurClient = imgur.ImgurClient(imgurAuth.clientId, imgurAuth.clientSecret)

    if not checkImgurAPICredits(imgurClient):
        return None

    imageId = imgurIdFromUrl(url)
    if not imageId:
        logger.log("Failed to convert {} to image id".format(url))
        
    try:
        return imgurClient.get_image(imageId).link
    except Exception as e:
        errorMessage = ('Failed to convert imgur to image link: '
                        '[ERROR] Exception: Url {} raised exception:\n\t {}'.format(url, e))
        logger.log(errorMessage)
        LikedSavedDatabase.db.addUnsupportedSubmission(submission, errorMessage)
        return None 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:22,代码来源:imgurDownloader.py

示例3: checkImgurAPICredits

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def checkImgurAPICredits(imgurClient):
    logger.log('Imgur API Credit Report:\n'
        + '\tUserRemaining: ' + str(imgurClient.credits['UserRemaining'])
        + '\n\tClientRemaining: ' + str(imgurClient.credits['ClientRemaining']))

    if not imgurClient.credits['UserRemaining']:
        logger.log('You have used up all of your Imgur API credits! Please wait an hour')
        return False

    # Ensure that this user doesn't suck up all the credits (remove this if you're an asshole)
    if imgurClient.credits['ClientRemaining'] < 1000:
        logger.log('RedditLikedSavedImageDownloader Imgur Client is running low on Imgur API credits!\n'
            'Unfortunately, this means no one can download any Imgur albums until the end of the month.\n'
            'If you are really jonesing for access, authorize your own Imgur Client and fill in'
            ' its details in settings.txt.')
        return False

    return True 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:20,代码来源:imgurDownloader.py

示例4: getUrlContentType

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def getUrlContentType(url):
    if url:
        openedUrl = None
        try:
            openedUrl = urlopen(url)
        except IOError as e:
            logger.log('[ERROR] getUrlContentType(): IOError: Url {0} raised exception:\n\t{1} {2}'
                .format(url, e.errno, e.strerror))
        except Exception as e:
            logger.log('[ERROR] Exception: Url {0} raised exception:\n\t {1}'
                        .format(url, e))
            logger.log('[ERROR] Url ' + url + 
                ' raised an exception I did not handle. Open an issue at '
                '\n\thttps://github.com/makuto/redditLikedSavedImageDownloader/issues'
                '\n and I will try to fix it')
        else:
            if sys.version_info[0] >= 3:
                return openedUrl.info().get_content_subtype()
            else:
                return openedUrl.info().subtype
    return '' 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:23,代码来源:imageSaver.py

示例5: main

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def main(args, extra_args, save_path):
    # configure logger, disable logging in child MPI processes (with rank > 0)

    # arg_parser = common_arg_parser()
    # args, unknown_args = arg_parser.parse_known_args()
    # extra_args = parse_cmdline_kwargs(unknown_args)

    if MPI is None or MPI.COMM_WORLD.Get_rank() == 0:
        rank = 0
        logger.configure()
    else:
        logger.configure(format_strs=[])
        rank = MPI.COMM_WORLD.Get_rank()

    model, env = train(args, extra_args)
    # env.close()

    # if args.save_path is not None and rank == 0:
    #     save_path = osp.expanduser(args.save_path)
    model.save(save_path)

    if args.play:
        logger.log("Running trained model")
        print()
        # env = build_env(args)
        obs = env.reset()
        def initialize_placeholders(nlstm=128,**kwargs):
            return np.zeros((args.num_env or 1, 2*nlstm)), np.zeros((1))
        state, dones = initialize_placeholders(**extra_args)
        while True:
            actions, _, state, _ = model.step(obs,S=state, M=dones)
            obs, _, done, _ = env.step(actions)
            env.render()
            done = done.any() if isinstance(done, np.ndarray) else done

            if done:
                obs = env.reset()

        env.close() 
开发者ID:quantumiracle,项目名称:Reinforcement_Learning_for_Traffic_Light_Control,代码行数:41,代码来源:run.py

示例6: main

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def main(args, extra_args, save_path):
    # configure logger, disable logging in child MPI processes (with rank > 0)

    # arg_parser = common_arg_parser()
    # args, unknown_args = arg_parser.parse_known_args()
    # extra_args = parse_cmdline_kwargs(unknown_args)

    if MPI is None or MPI.COMM_WORLD.Get_rank() == 0:
        rank = 0
        logger.configure()
    else:
        logger.configure(format_strs=[])
        rank = MPI.COMM_WORLD.Get_rank()

    model, env = train(args, extra_args)
    # env.close()

    # if args.save_path is not None and rank == 0:
    #     save_path = osp.expanduser(args.save_path)
    model.save(save_path)

    if args.play:
        logger.log("Running trained model")
        print()
        # env = build_env(args)
        obs = env.reset()
        def initialize_placeholders(nlstm=128,**kwargs):
            return np.zeros((args.num_env or 1, 2*nlstm)), np.zeros((1))
        state, dones = initialize_placeholders(**extra_args)
        while True:
            actions, _, state, _ = model.step(obs,S=state, M=dones)
            obs, _, done, _ = env.step(actions)
            env.render()
            done = done.any() if isinstance(done, np.ndarray) else done

            if done:
                obs = env.reset()

        # env.close() 
开发者ID:quantumiracle,项目名称:Reinforcement_Learning_for_Traffic_Light_Control,代码行数:41,代码来源:run.py

示例7: configure_logger

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def configure_logger(log_dir):
    logger.configure(log_dir, format_strs=['log'])
    global tb
    tb = logger.Logger(log_dir, [logger.make_output_format('tensorboard', log_dir),
                                 logger.make_output_format('csv', log_dir),
                                 logger.make_output_format('stdout', log_dir)])
    global log
    log = logger.log 
开发者ID:rajammanabrolu,项目名称:KG-A2C,代码行数:10,代码来源:gdqn.py

示例8: __parse

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def __parse(self, lines):
        #log("FieldNode: " + line + " parsing")
        self.buf = lines

        i = self.buf[0].find('=')
        segs = []
        if i > 0:
            segs = self.buf[0][:i].split()
            self.value = self.buf[0][i + 1:].strip()
        else:
            segs = self.buf[0].split()
        self.access = segs[1:-1]
        self.name, self.descriptor = segs[-1].split(':')
        log("FieldNode: " + self.name + " parsed!") 
开发者ID:pilgun,项目名称:acvtool,代码行数:16,代码来源:fieldnode.py

示例9: _log_rc

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def _log_rc(cmd_output, funct_name, **kvarg):
    """Generic logger that picks correct log type based on return code"""

    rc = cmd_output['rc'] if 'rc' in cmd_output else cmd_output

    logger.log(logger.decide_level(rc),
               funct_name,
               **kvarg
               ) 
开发者ID:Bridgewater,项目名称:appetite,代码行数:11,代码来源:conn_manager.py

示例10: AddAllFromReddit

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def AddAllFromReddit(database, settings):
    if not settings.hasRedditSettings():
        logger.log('Reddit settings are not provided!')
        return

    submissions = []

    logger.log('Adding last 1000 liked/saved submissions from Reddit. This will take a long time.')

    redditSubmissions, redditComments, earlyOutPoints = redditScraper.getRedditUserLikedSavedSubmissions(
        settings.settings['Username'], settings.settings['Password'], 
        settings.settings['Client_id'], settings.settings['Client_secret'],
        request_limit = None, # No limit = request as many as possible (1000)
        saveLiked = settings.settings['Reddit_Save_Liked'], 
        saveSaved = settings.settings['Reddit_Save_Saved'],
        earlyOutPointSaved = None, 
        earlyOutPointLiked = None,
        unlikeLiked = False,
        unsaveSaved = False)

    logger.log('Retrieved submissions, adding to database...')

    for submission in redditSubmissions:
        database.addSubmission(submission)

    for comment in redditComments:
        database.addComment(comment)

    logger.log('Done! Saved {} submissions and {} comments'.format(len(redditSubmissions), len(redditComments))) 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:31,代码来源:CreateDatabase.py

示例11: AddAllFromDirectory

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def AddAllFromDirectory(fileDatabase, directory):
    logger.log('Scanning {} to create FileCollectionDatabase'.format(directory))
    numFiles = 0
    for root, dirs, files in os.walk(directory):
        for file in files:
            fileDatabase.addFileNoSave(file, os.path.relpath(os.path.join(root, file), directory))
            numFiles += 1
            
    fileDatabase.save()

    logger.log('Done; {} files in database'.format(numFiles)) 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:13,代码来源:CreateDatabase.py

示例12: initialize

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def initialize():
    settings.getSettings()
        
    if not settings.settings['Database']:
        logger.log('Please provide a location for the Database')
        return

    # Do this early so we can use it anywhere
    LikedSavedDatabase.initializeFromSettings(settings.settings) 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:11,代码来源:redditUserImageScraper.py

示例13: saveRequestedUrls

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def saveRequestedUrls(pipeConnection, urls):
    if pipeConnection:
        logger.setPipe(pipeConnection)

    initialize()

    logger.log('Attempting to save {} requested urls. This may take several minutes...'
               .format(len(urls)))

    submissions = []
    # Create Submission for each URL
    for url in urls:
        convertedSubmission = submission.Submission()
        convertedSubmission.source = "UserRequested"
        convertedSubmission.title = "UserRequested"
        convertedSubmission.author = "(Requested by user)"
        convertedSubmission.subreddit = "Requested_Downloads"
        convertedSubmission.subredditTitle = "Requested Downloads"
        convertedSubmission.body = "(Requested by user)"
        convertedSubmission.bodyUrl= url
        convertedSubmission.postUrl= url
        submissions.append(convertedSubmission)

    if len(submissions) != len(urls):
        logger.log('Could not parse {} URLs!'.format(len(urls) - len(submissions)))

    unsupportedSubmissions = imageSaver.saveAllImages(settings.settings['Output_dir'], submissions, 
                                                      imgur_auth = imgurDownloader.getImgurAuth(),
                                                      only_download_albums = settings.settings['Only_download_albums'],
                                                      skip_n_percent_submissions = settings.settings['Skip_n_percent_submissions'],
                                                      soft_retrieve_imgs = settings.settings['Should_soft_retrieve'],
                                                      only_important_messages = settings.settings['Only_important_messages'])

    logger.log('Download finished. Output to \'Requested Downloads\' directory')
    
    if pipeConnection:
        logger.log(scriptFinishedSentinel)
        pipeConnection.close() 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:40,代码来源:redditUserImageScraper.py

示例14: getImgurAuth

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def getImgurAuth():
    imgurAuth = None
    if settings.hasImgurSettings():
        return ImgurAuth(settings.settings['Imgur_client_id'], 
                                         settings.settings['Imgur_client_secret'])
    else:
        logger.log('No Imgur Client ID and/or Imgur Client Secret was provided, or album download is not'
                   ' enabled. This is required to download imgur albums. They will be ignored. Check'
                   ' settings.txt for how to fill in these values.')
        return None 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:12,代码来源:imgurDownloader.py

示例15: gfycatToRedGifsWorkaround

# 需要导入模块: import logger [as 别名]
# 或者: from logger import log [as 别名]
def gfycatToRedGifsWorkaround(gfyUrl):
    logger.log("Using Gfycat->RedGifs workaround")
    return findSourceFromHTML(gfyUrl, '<source id="mp4source" src=')

# Lazy initialize in case it's not needed 
开发者ID:makuto,项目名称:Liked-Saved-Image-Downloader,代码行数:7,代码来源:imageSaver.py


注:本文中的logger.log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。