Ejemplo n.º 1
0
def set_up():
    load_app_options()  # 加载配置

    def signal_received(signum, stack):
        global RUNNING
        RUNNING = False

    signal.signal(signal.SIGUSR1, signal_received)
Ejemplo n.º 2
0
def set_up():
    load_app_options()  # 加载配置

    def signal_received(signum, stack):
        global RUNNING
        RUNNING = False

    signal.signal(signal.SIGUSR1, signal_received)
Ejemplo n.º 3
0
    result = PropDict({
        'price':
        price,
        'count':
        sale_info.count,
        'base_amount':
        Decimal(BASE_PRICE - price) * sale_info.count,
        'premium_amount':
        max(sale_info.amount - Decimal(BASE_PRICE) * sale_info.count,
            Decimal(0)),
        'month_info':
        start_day.strftime('%Y年%m月')
    })
    result['total_amount'] = result[
        'base_amount'] + result['premium_amount'] * Decimal('0.7')
    return result


if __name__ == '__main__':
    # 加载配置
    load_app_options()

    # 配置日志
    logging.basicConfig(
        level=logging.INFO,
        format=
        '[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d] %(message)s')

    logging.info('start generate agent account_sequence')
    gen_account_sequence()
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-

import torndb
from conf import load_app_options
import logging
from tornado.options import options
from datetime import datetime, timedelta

load_app_options()  # 加载配置
logging.info("start check expire order ")
logging.basicConfig(
    level=logging.INFO,
    format='[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d] %(message)s')

db = torndb.Connection(host=options.mysql_host,
                       database=options.mysql_database,
                       user=options.mysql_user,
                       password=options.mysql_password)

expire_at = datetime.now() + timedelta(hours=-2)
orders = db.query(
    'select oi.goods_id, oi.num from order_item oi, orders o where oi.order_id = o.id '
    'and o.created_at < %s and status = 0 and created_at > "2014-02-11 00:00:00"',
    expire_at)
db.execute(
    'update orders set status = 8 where created_at < %s and status = 0 '
    'and created_at > "2014-02-11 00:00:00" ', expire_at)

for order in orders:
    db.execute('update goods set stock = stock + %s where id = %s', order.num,
               order.goods_id)
Ejemplo n.º 5
0
import torndb
import logging
from conf import load_app_options
from tornado.options import options
import json
from autumn.utils import json_hook

from autumn.api.taobao import Taobao
from autumn.api.jingdong import Jingdong
from autumn.api.wuba import Wuba
from tornado.gen import coroutine
from tornado.ioloop import IOLoop

# 加载配置
load_app_options()

# 配置日志
logging.basicConfig(level=logging.INFO,
                    format='[%(levelname)1.1s %(asctime)s %(module)s:%(lineno)d] %(message)s')

# 配置连接
db = torndb.Connection(
    host=options.mysql_host, database=options.mysql_database,
    user=options.mysql_user, password=options.mysql_password)


@coroutine
def sync_stock():
    sql = """
        select g.id, gds.distributor_shop_id, gds.distributor_goods_id, gds.goods_link_id, g.stock, ds.taobao_api_info,
Ejemplo n.º 6
0
# -*- coding: utf-8 -*-
import os
import logging
import torndb
from tornado import ioloop, web, autoreload, httpserver
from tornado.options import options, define
from controllers.handlers import handlers
from conf import load_app_options

if __name__ == '__main__':
    define('app_path', os.path.dirname(os.path.abspath(__file__)))  # app.py所在目录
    define('app_port', 8601)

    load_app_options()  # 加载配置

    settings = {
        'template_path': os.path.join(options.app_path, 'templates'),
        'static_path': os.path.join(options.app_path, 'static'),
        'cookie_secret': options.cookie_secret,
        'debug': options.app_debug,
        'login_url': '/login',
        'xsrf_cookies': False,
    }

    application = web.Application(handlers, **settings)
    application.db = torndb.Connection(
        host=options.mysql_host, database=options.mysql_database,
        user=options.mysql_user, password=options.mysql_password)

    server = httpserver.HTTPServer(application)
    server.listen(options.app_port)