Example #1
0
def refresh():
    config_app(app, 'scriptfan.cfg')
    #ctx = app.app_context()
    #ctx.push()
    #hs.refreshStockHolder()
    dts.freshBasicStockInfo()
    print "hello"
Example #2
0
def refresh():
    config_app(app, 'scriptfan.cfg')
    #ctx = app.app_context()
    #ctx.push()
    #hs.refreshStockHolder()
    dts.freshBasicStockInfo()
    print "hello"
Example #3
0
 def setUp(self):
     self.app = app
     config_app(app, 'scriptfan.cfg')
     register_blueprints(app)
     self.app_context = self.app.app_context()
     self.app_context.push()
Example #4
0
 def setUp(self):
     self.app = app
     config_app(app, 'scriptfan.cfg')
     register_blueprints(app)
     self.app_context = self.app.app_context()
     self.app_context.push()
Example #5
0
from sqlalchemy import or_

from webapp.models import Stock
from webapp.models.req_error_log import ReqErrorLog

sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))

from webapp import app, db, config_app
from webapp.services import db_service as dbs,data_service as dts

reload(sys)
sys.setdefaultencoding('utf8')
import threading

config_app(app, 'scriptfan.cfg')
ctx = app.app_context()

g_queue = multiprocessing.Queue()

def update_stock(t):
    ctx.push()
    while not g_queue.empty():
        time.sleep(5)
        try:
            item = g_queue.get()
            result = dts.getFinanceData(item)
            dts.updateFinanceData(result)
        except Exception, ex:
            app.logger.warn('stock %s update fail' % item)
            msg = traceback.format_exc()
Example #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from celery import Celery

from celery.schedules import crontab

import refresh_stock_holder,refresh_stock_finance,refresh_stock_trade
from refresh_stock_holder import urls_queue, data_queue, ThreadCrawl, ThreadWrite
from webapp import celery, app, config_app
from webapp.services.holder_service import getRefreshStocks

config_app(app, 'scriptfan.cfg')
ctx = app.app_context()

@celery.task
def stock_holder():
    with app.app_context() as ctx:
        refresh_stock_holder.main(ctx)

@celery.task
def stock_finance():
    with app.app_context() as ctx:
        refresh_stock_finance.main(ctx)

@celery.task
def stock_trade():
    with app.app_context() as ctx:
        refresh_stock_trade.main(ctx)


celery.conf.beat_schedule = {
Example #7
0
def createApp(config):
    config_app(app, config)
    register_blueprints(app)
    return app
Example #8
0
def runserver(config, host, port):
    config_app(app, config)
    register_blueprints(app)
    app.run(host=host, port=port,debug=True)
Example #9
0
def createApp(config):
    config_app(app, config)
    register_blueprints(app)
    return app
Example #10
0
def runserver(config, host, port):
    config_app(app, config)
    register_blueprints(app)
    app.run(host=host, port=port, debug=True)