def setUp(self): unittest.TestCase.setUp(self) proj_home = os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')) self.app = app.myADSCelery('test', local_config={'SQLALCHEMY_URL': self.postgresql_url, 'SQLALCHEMY_ECHO': False, 'PROJ_HOME': proj_home, 'TEST_DIR': os.path.join(proj_home, 'myadsp/tests'), }) Base.metadata.bind = self.app._session.get_bind() Base.metadata.create_all()
import adsputils from myadsp import app as app_module from myadsp import utils from .models import AuthorInfo from .emails import myADSTemplate #from flask import current_app from kombu import Queue import os import json from sqlalchemy.orm import exc as ormexc app = app_module.myADSCelery('myADS-pipeline', proj_home=os.path.realpath( os.path.join(os.path.dirname(__file__), '../'))) app.conf.CELERY_QUEUES = (Queue('process', app.exchange, routing_key='process'), ) logger = app.logger @app.task(queue='process') def task_process_myads(message): """ Process the myADS notifications for a given user :param message: contains the message inside the packet { 'userid': adsws user ID, 'frequency': 'daily' or 'weekly', 'force': Boolean (if present, we'll reprocess myADS notifications for the user,
from myadsp import app as app_module from myadsp import utils from .models import AuthorInfo from .emails import myADSTemplate #from flask import current_app from kombu import Queue import os import json from sqlalchemy.orm import exc as ormexc # ============================= INITIALIZATION ==================================== # proj_home = os.path.realpath(os.path.join(os.path.dirname(__file__), '../')) app = app_module.myADSCelery('myADS-pipeline', proj_home=proj_home, local_config=globals().get('local_config', {})) logger = app.logger app.conf.CELERY_QUEUES = (Queue('process', app.exchange, routing_key='process'), ) # ============================= TASKS ============================================= # @app.task(queue='process') def task_process_myads(message): """ Process the myADS notifications for a given user :param message: contains the message inside the packet
from jinja2 import Environment, PackageLoader, select_autoescape import datetime # ============================= INITIALIZATION ==================================== # # - Use app logger: #import logging #logger = logging.getLogger('myADS-pipeline') # - Or individual logger for this file: proj_home = os.path.realpath(os.path.join(os.path.dirname(__file__), '../')) config = load_config(proj_home=proj_home) logger = setup_logging(__name__, proj_home=proj_home, level=config.get('LOGGING_LEVEL', 'INFO'), attach_stdout=config.get('LOG_STDOUT', False)) app = app_module.myADSCelery('myADS-pipeline', proj_home=proj_home) env = Environment(loader=PackageLoader('myadsp', 'templates'), autoescape=select_autoescape(enabled_extensions=('html', 'xml'), default_for_string=True)) # =============================== FUNCTIONS ======================================= # def send_email(email_addr='', email_template=Email, payload_plain=None, payload_html=None, subject=None): """