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


Python log.info函数代码示例

本文整理汇总了Python中utils.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: save_csv

def save_csv(csv, fn):
    log.info("Savin' CSV to '%s'" % (fn))
    fh = open(fn, 'w')
    for line in csv:
        fh.write(','.join(map(str, line)))
        fh.write('\n')
    fh.close()
开发者ID:Smarsh,项目名称:norc,代码行数:7,代码来源:reporting.py

示例2: collect_orphan_feeds

 def collect_orphan_feeds(cls, user):
     us = cls.objects.filter(user=user)
     try:
         usf = UserSubscriptionFolders.objects.get(user=user)
     except UserSubscriptionFolders.DoesNotExist:
         return
     us_feed_ids = set([sub.feed_id for sub in us])
     folders = json.decode(usf.folders)
     
     def collect_ids(folders, found_ids):
         for item in folders:
             # print ' --> %s' % item
             if isinstance(item, int):
                 # print ' --> Adding feed: %s' % item
                 found_ids.add(item)
             elif isinstance(item, dict):
                 # print ' --> Descending folder dict: %s' % item.values()
                 found_ids.update(collect_ids(item.values(), found_ids))
             elif isinstance(item, list):
                 # print ' --> Descending folder list: %s' % len(item)
                 found_ids.update(collect_ids(item, found_ids))
         # print ' --> Returning: %s' % found_ids
         return found_ids
     found_ids = collect_ids(folders, set())
     diff = len(us_feed_ids) - len(found_ids)
     if diff > 0:
         logging.info(" ---> Collecting orphans on %s. %s feeds with %s orphans" % (user.username, len(us_feed_ids), diff))
         orphan_ids = us_feed_ids - found_ids
         folders.extend(list(orphan_ids))
         usf.folders = json.encode(folders)
         usf.save()
开发者ID:TKupels,项目名称:NewsBlur,代码行数:31,代码来源:models.py

示例3: switch_hash

 def switch_hash(cls, feed_id, old_hash, new_hash):
     r = redis.Redis(connection_pool=settings.REDIS_STORY_HASH_POOL)
     # r2 = redis.Redis(connection_pool=settings.REDIS_STORY_HASH_POOL2)
     p = r.pipeline()
     # p2 = r2.pipeline()
     UNREAD_CUTOFF = datetime.datetime.now() - datetime.timedelta(days=settings.DAYS_OF_STORY_HASHES)
     
     usersubs = UserSubscription.objects.filter(feed_id=feed_id, last_read_date__gte=UNREAD_CUTOFF)
     logging.info(" ---> ~SB%s usersubs~SN to switch read story hashes..." % len(usersubs))
     for sub in usersubs:
         rs_key = "RS:%s:%s" % (sub.user.pk, feed_id)
         read = r.sismember(rs_key, old_hash)
         if read:
             p.sadd(rs_key, new_hash)
             # p2.sadd(rs_key, new_hash)
             p.expire(rs_key, settings.DAYS_OF_STORY_HASHES*24*60*60)
             # p2.expire(rs_key, settings.DAYS_OF_STORY_HASHES*24*60*60)
             
             read_user_key = "RS:%s" % sub.user.pk
             p.sadd(read_user_key, new_hash)
             # p2.sadd(read_user_key, new_hash)
             p.expire(read_user_key, settings.DAYS_OF_STORY_HASHES*24*60*60)
             # p2.expire(read_user_key, settings.DAYS_OF_STORY_HASHES*24*60*60)
     
     p.execute()
开发者ID:TKupels,项目名称:NewsBlur,代码行数:25,代码来源:models.py

示例4: __init__

    def __init__(self):
        log.info('Initialization HTTP Server')

        @self.web.route('/', methods=['GET'])
        def homepage():
            log.debug('In homepage Route')
            return render_template('index.html')

        @self.web.route('/blank')
        def blank():
            log.debug('In blank Route')
            return render_template('blank.html')

        @self.web.route('/add', methods=['POST'])
        def add():
            log.debug('In add Route')
            return jsonify(code=1001, msg='success', id=123)

        @self.web.route('/status/<int:id>', methods=['GET'])
        def status(id):
            log.debug('In status Route')
            return jsonify(code=1001, msg='success', status='running')

        @self.web.errorhandler(404)
        def page_not_found(e):
            log.debug('In 404 Route')
            return render_template('404.html'), 404
开发者ID:bk7477890,项目名称:cobra,代码行数:27,代码来源:route.py

示例5: run_action

 def run_action(self, action, args=None):
     if not args:
         args = {}
     if not action.atomic:
         log.info(log.term.bold("## %s" % action.name))
     for carg in action.const_args:
         args[carg] = action.const_args[carg]
     action_fun = action.action_fun
     if not action_fun:
         action_fun, action_module = self._get_action_fun(action.name)
         if not action_fun:
             raise exception.ActionFunctionNotAvailable(action=action.name)
     argspec = inspect.getargspec(action_fun)
     fun_args = []
     if argspec.defaults:
         n_defaults = len(argspec.defaults)
     else:
         n_defaults = 0
     n_required = len(argspec.args) - n_defaults
     for i, arg in enumerate(argspec.args):
         if arg in args:
             fun_args.append(args[arg])
         else:
             if i < n_required:
                 raise exception.RequiredActionArgumentNotAvailable(
                     action=action.name, arg=arg)
             else:
                 fun_args.append(argspec.defaults[i - n_required])
     return action_fun(*fun_args)
开发者ID:djipko,项目名称:rdopkg,代码行数:29,代码来源:action.py

示例6: exception_change_feed_address

def exception_change_feed_address(request):
    feed_id = request.POST['feed_id']
    feed = get_object_or_404(Feed, pk=feed_id)
    feed_address = request.POST['feed_address']
    
    if not feed.has_feed_exception and not feed.has_page_exception:
        logging.info(" ***********> [%s] Incorrect feed address change: %s" % (request.user, feed))
        return HttpResponseForbidden()
        
    feed.has_feed_exception = False
    feed.active = True
    feed.fetched_once = False
    feed.feed_address = feed_address
    feed.next_scheduled_update = datetime.datetime.now()
    try:
        feed.save()
    except IntegrityError:
        original_feed = Feed.objects.get(feed_address=feed_address)
        original_feed.next_scheduled_update = datetime.datetime.now()
        original_feed.has_feed_exception = False
        original_feed.active = True
        original_feed.save()
        merge_feeds(original_feed.pk, feed.pk)
    
    return {'code': 1}
开发者ID:dkeskar,项目名称:NewsBlur,代码行数:25,代码来源:views.py

示例7: rebase_nightly

def rebase_nightly(upstream_branch, local_patches_branch, branch=None,
                   lame_patches=None):
    log.info("Rebasing upstream %s" % upstream_branch)
    nightly.rebase_nightly(upstream_branch,
                           lame_patches=lame_patches,
                           patches_branch=local_patches_branch,
                           distgit_branch=branch)
开发者ID:codenrhoden,项目名称:rdopkg,代码行数:7,代码来源:actions.py

示例8: rename_file

def rename_file(filename, suffix):
    """按规则重命名文件"""
    category = get_category(filename)
    path_name = os.path.dirname(filename)
    new_name = os.path.join(path_name, 'ESO_%s_%s.xlsx' % (category_names[category], suffix))
    log.info('%s -> %s' % (filename, new_name))
    shutil.move(filename, new_name)
开发者ID:esozh,项目名称:eso_zh_ui,代码行数:7,代码来源:rename_lang_xls.py

示例9: load_starred_stories

def load_starred_stories(request):
    user = get_user(request)
    offset = int(request.REQUEST.get('offset', 0))
    limit = int(request.REQUEST.get('limit', 10))
    page = int(request.REQUEST.get('page', 0))
    if page: offset = limit * page
        
    mstories = MStarredStory.objects(user_id=user.pk).order_by('-starred_date')[offset:offset+limit]
    stories = Feed.format_stories(mstories)
    
    for story in stories:
        story_date = localtime_for_timezone(story['story_date'], user.profile.timezone)
        now = localtime_for_timezone(datetime.datetime.now(), user.profile.timezone)
        story['short_parsed_date'] = format_story_link_date__short(story_date, now)
        story['long_parsed_date'] = format_story_link_date__long(story_date, now)
        starred_date = localtime_for_timezone(story['starred_date'], user.profile.timezone)
        story['starred_date'] = format_story_link_date__long(starred_date, now)
        story['read_status'] = 1
        story['starred'] = True
        story['intelligence'] = {
            'feed': 0,
            'author': 0,
            'tags': 0,
            'title': 0,
        }
    
    logging.info(" ---> [%s] ~FCLoading starred stories: ~SB%s stories" % (request.user, len(stories)))
    
    return dict(stories=stories)
开发者ID:francois2metz,项目名称:NewsBlur,代码行数:29,代码来源:views.py

示例10: load_feed_statistics

def load_feed_statistics(request):
    stats = dict()
    feed_id = request.GET['feed_id']
    feed = get_object_or_404(Feed, pk=feed_id)
    feed.save_feed_story_history_statistics()
    
    # Dates of last and next update
    stats['last_update'] = relative_timesince(feed.last_update)
    stats['next_update'] = relative_timeuntil(feed.next_scheduled_update)
    
    # Minutes between updates
    update_interval_minutes, random_factor = feed.get_next_scheduled_update()
    stats['update_interval_minutes'] = update_interval_minutes
    
    # Stories per month - average and month-by-month breakout
    average_stories_per_month, story_count_history = feed.average_stories_per_month, feed.story_count_history
    stats['average_stories_per_month'] = average_stories_per_month
    stats['story_count_history'] = story_count_history and json.decode(story_count_history)
    
    # Subscribers
    stats['subscriber_count'] = feed.num_subscribers
    
    logging.info(" ---> [%s] Statistics: %s" % (request.user, feed))
    
    return stats
开发者ID:tosh,项目名称:NewsBlur,代码行数:25,代码来源:views.py

示例11: run

    def run(self, feed_pks, **kwargs):
        from apps.rss_feeds.models import Feed
        from apps.statistics.models import MStatistics
        r = redis.Redis(connection_pool=settings.REDIS_FEED_UPDATE_POOL)

        mongodb_replication_lag = int(MStatistics.get('mongodb_replication_lag', 0))
        compute_scores = bool(mongodb_replication_lag < 10)
        
        profiler = DBProfilerMiddleware()
        profiler_activated = profiler.process_celery()
        if profiler_activated:
            mongo_middleware = MongoDumpMiddleware()
            mongo_middleware.process_celery(profiler)
            redis_middleware = RedisDumpMiddleware()
            redis_middleware.process_celery(profiler)
        
        options = {
            'quick': float(MStatistics.get('quick_fetch', 0)),
            'updates_off': MStatistics.get('updates_off', False),
            'compute_scores': compute_scores,
            'mongodb_replication_lag': mongodb_replication_lag,
        }
        
        if not isinstance(feed_pks, list):
            feed_pks = [feed_pks]
            
        for feed_pk in feed_pks:
            feed = Feed.get_by_id(feed_pk)
            if not feed or feed.pk != int(feed_pk):
                logging.info(" ---> ~FRRemoving feed_id %s from tasked_feeds queue, points to %s..." % (feed_pk, feed and feed.pk))
                r.zrem('tasked_feeds', feed_pk)
            if feed:
                feed.update(**options)
                if profiler_activated: profiler.process_celery_finished()
开发者ID:bodegard,项目名称:NewsBlur,代码行数:34,代码来源:tasks.py

示例12: run

    def run(self, target=None, tid=None):
        if target is None:
            log.critical("Please set --target param")
            sys.exit()
        if tid is None:
            log.critical("Please set --tid param")
            sys.exit()

        # Statistic Code
        p = subprocess.Popen(
            ['cloc', target], stdout=subprocess.PIPE)
        (output, err) = p.communicate()
        rs = output.split("\n")
        for r in rs:
            r_e = r.split()
            if len(r_e) > 3 and r_e[0] == 'SUM:':
                t = CobraTaskInfo.query.filter_by(id=tid).first()
                if t is not None:
                    t.code_number = r_e[4]
                    try:
                        db.session.add(t)
                        db.session.commit()
                        log.info("Statistic code number done")
                    except Exception as e:
                        log.error("Statistic code number failed" + str(e.message))
开发者ID:LoveWalter,项目名称:cobra,代码行数:25,代码来源:__init__.py

示例13: mark_story_as_read

def mark_story_as_read(request):
    story_ids = request.REQUEST.getlist('story_id')
    feed_id = int(request.REQUEST['feed_id'])
    
    usersub = UserSubscription.objects.select_related('feed').get(user=request.user, feed=feed_id)
    if not usersub.needs_unread_recalc:
        usersub.needs_unread_recalc = True
        usersub.save()
        
    data = dict(code=0, payload=story_ids)
    
    if len(story_ids) > 1:
        logging.debug(" ---> [%s] Read %s stories in feed: %s" % (request.user, len(story_ids), usersub.feed))
    else:
        logging.debug(" ---> [%s] Read story in feed: %s" % (request.user, usersub.feed))
        
    for story_id in story_ids:
        story = MStory.objects(story_feed_id=feed_id, story_guid=story_id)[0]
        now = datetime.datetime.utcnow()
        m = MUserStory(story=story, user_id=request.user.pk, feed_id=feed_id, read_date=now)
        try:
            m.save()
        except OperationError:
            logging.info(' ---> [%s] *** Marked story as read: Duplicate Story -> %s' % (request.user, story_id))
    
    return data
开发者ID:tosh,项目名称:NewsBlur,代码行数:26,代码来源:views.py

示例14: opml_upload

def opml_upload(request):
    xml_opml = None
    message = "OK"
    code = 1
    payload = {}
    
    if request.method == 'POST':
        if 'file' in request.FILES:
            logging.info(" ---> [%s] ~FR~SBOPML upload starting..." % request.user)
            file = request.FILES['file']
            xml_opml = file.read()
            opml_importer = OPMLImporter(xml_opml, request.user)
            folders = opml_importer.process()

            feeds = UserSubscription.objects.filter(user=request.user).values()
            payload = dict(folders=folders, feeds=feeds)
            logging.info(" ---> [%s] ~FR~SBOPML Upload: ~SK%s~SN~SB~FR feeds" % (request.user, len(feeds)))
            
            request.session['import_from_google_reader'] = False
        else:
            message = "Attach an .opml file."
            code = -1
            
    data = json.encode(dict(message=message, code=code, payload=payload))
    return HttpResponse(data, mimetype='text/plain')
开发者ID:knv,项目名称:NewsBlur,代码行数:25,代码来源:views.py

示例15: clean

 def clean(self):
     username = self.cleaned_data.get('username', '').lower()
     password = self.cleaned_data.get('password', '')
     
     user = User.objects.filter(Q(username__iexact=username) | Q(email=username))
     if user:
         user = user[0]
     if username and user:
         self.user_cache = authenticate(username=user.username, password=password)
         if self.user_cache is None:
             blank = blank_authenticate(user.username)
             if blank:
                 user.set_password(user.username)
                 user.save()
             self.user_cache = authenticate(username=user.username, password=user.username)
         if self.user_cache is None:
             email_user = User.objects.filter(email=username)
             if email_user:
                 email_user = email_user[0]
                 self.user_cache = authenticate(username=email_user.username, password=password)
                 if self.user_cache is None:
                     blank = blank_authenticate(email_user.username)
                     if blank:
                         email_user.set_password(email_user.username)
                         email_user.save()
                     self.user_cache = authenticate(username=email_user.username, password=email_user.username)
         if self.user_cache is None:
             logging.info(" ***> [%s] Bad Login" % username)
             raise forms.ValidationError(_("Whoopsy-daisy, wrong password. Try again."))
     elif username and not user:
         raise forms.ValidationError(_("That username is not registered. Please try again."))
         
     return self.cleaned_data
开发者ID:76,项目名称:NewsBlur,代码行数:33,代码来源:forms.py


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