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


Python LOGGER.p_log方法代碼示例

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


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

示例1: getUser

# 需要導入模塊: from config import LOGGER [as 別名]
# 或者: from config.LOGGER import p_log [as 別名]
def getUser(email):
    user = User.query.filter_by(email=email).first()
    form = EditUserForm(g.user.email)
    if user is None:
        flash('Utilisateur %s introuvable' % email)
        users = User.query.order_by('last_connection desc').all()
        return render_template('getUsers.html', users=users, app_name=app_name)
    else:
        if form.validate_on_submit():
            try:
                g.user.firstname = form.firstname.data
                g.user.email = form.email.data
                g.user.timezone = form.timezone.data
                if form.new_password.data != '':
                    g.user.set_password(form.new_password.data)
                db.session.add(g.user)
                db.session.commit()
                flash(u'tes modifs\' sont bien enregistrées')
            except:
                db.session.rollback()
                flash(u'ERREUR : impossible d\'enregistrer tes modifs !')
                LOGGER.p_log(u'impossible d\'enregistrer les modifs', exception=exc_info())  
        else:
            for errors in form.errors.values():
                for error in errors:
                    flash(error)
                    print error
            form.firstname.data = g.user.firstname
            form.email.data = g.user.email
            form.timezone.data = g.user.timezone
        return render_template('getUser.html', app_name=app_name, user=user, form=form)
開發者ID:littleDad,項目名稱:mesLucioles,代碼行數:33,代碼來源:views.py

示例2: addBill

# 需要導入模塊: from config import LOGGER [as 別名]
# 或者: from config.LOGGER import p_log [as 別名]
def addBill(s_date, s_type, s_label, s_total, s_payer_id, s_user_ids):
    """
        create a Spending in the database.
          1) create the Spending model and fill its attributes except parts
          2) estimate parts and add them to our Spending
          3) adjust balance for each User with this parts
          4) until no errors: add all of this in the database
    """
    try:
        bill = Spending()
        bill.timestamp = datetime.utcnow()
        bill.s_date = s_date
        bill.s_type = s_type
        bill.label = s_label
        bill.total = s_total
        bill.payer_id = s_payer_id
        db.session.add(bill)

        # db.session.query(User).get(s_payer_id).given_money += float(bill.total)
        
        tmp_parts = bill.computeParts(db.session, len(s_user_ids))
        user_parts = []
        for idx, i in enumerate(tmp_parts):
            db.session.add(
                Spending.Part(
                    spending=bill,
                    total=i, # == tmp_parts[idx],
                    user_id=s_user_ids[idx]
                )
            )
            user_parts.append([s_user_ids[idx], i])
        
        # for user_id, user_bill in user_parts:
        #     db.session.query(User).get(user_id).borrowed_money += user_bill

        db.session.commit()
        return 1
    except:
        db.session.rollback()
        LOGGER.p_log(u'impossible d\'ajouter la dépense', exception=exc_info())     
        return 0
開發者ID:littleDad,項目名稱:mesLucioles,代碼行數:43,代碼來源:views.py

示例3: delSpending

# 需要導入模塊: from config import LOGGER [as 別名]
# 或者: from config.LOGGER import p_log [as 別名]
def delSpending(id):
    bill = Spending.query.get(int(id))

    if bill is None:
        flash(u'Dépense (id = %s) introuvable' % id)
        return redirect(url_for(
            'comptes',
            app_name=app_name,
            spends_page='depenses'
        ))

    else:
        print "on supprime %s" % bill.label
        try:
            # delete associated parts and reset users' balances
            parts = db.session.query(Spending.Part).filter_by(
                    spending_id=int(id)
                ).all()
            db.session.delete(bill)
            for part in parts:
                u_tmp = db.session.query(User).filter_by(id=part.user_id).first()
                # u_tmp.borrowed_money -= part.total
                LOGGER.p_log(u"%s récupère %s € !" % (u_tmp.getName(), part.total))
                db.session.delete(part)

            # db.session.query(User).get(bill.payer_id).given_money -= bill.total

            # and finally delete the bill
            db.session.commit()
            flash(u'dépense supprimée')
        except:
            db.session.rollback()
            flash(u'impossible de supprimer la dépense')
            LOGGER.p_log(u'impossible de supprimer la dépense', exception=exc_info())   

    return redirect(
        url_for(
        'comptes',
        spends_page='depenses'
    ))
開發者ID:littleDad,項目名稱:mesLucioles,代碼行數:42,代碼來源:views.py

示例4: makeParts

# 需要導入模塊: from config import LOGGER [as 別名]
# 或者: from config.LOGGER import p_log [as 別名]
        def makeParts(value, p_size, spending_name, spending_time):
            """make p_size parts with the value.
            if centimes left, we allocate these lost ones to a random user. sometimes
                it's positive numbers, sometimes not!
            my priority was to NOT have lost centimes.

            P.S.: sorry for this madness with floating and decimal numbers, there wasn't
                any 'easy' way!
            """
            getcontext().prec = 6
            value = dec(str(value))  # I'll probably go to hell for this...

            # attribution aux parts de la valeur entière divisible par p_size
            parts = [int(value/p_size)] * p_size

            # on transforme le reste en centimes que l'on distribue
            left_centimes = int(100 * (value - sum(parts)))

            # attribution aux parts des centimes restants
            for idx, part in enumerate(parts):
                parts[idx] += (left_centimes/p_size) / 100.

            # on attribue les centimes restants à un user aléatoire
            the_last_centime = (left_centimes % p_size) / 100.
            if the_last_centime != 0:
                the_one = randint(0, len(parts)-1)
                parts[the_one] += the_last_centime

            # any error is logged. because money is money. no jokes!
            if float(value) != float(sum(parts)):
                LOGGER.p_log('error in adding a spending', level='warning')
                LOGGER.p_log('spending_time: ' + str(spending_time), blank=True)
                LOGGER.p_log('value: ' + str(value), blank=True)
                LOGGER.p_log('sum: ' + str(sum(parts)), blank=True)
                LOGGER.p_log('parts: ' + str(parts), blank=True)
            return parts
開發者ID:littleDad,項目名稱:mesLucioles,代碼行數:38,代碼來源:models.py


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