예제 #1
0
Managers will often provide methods for initial setup of a host or periodic
tasks to a wrapping service.

This module provides Manager, a base class for managers.

"""
import socket
import eventlet

from ops import utils
from ops import log as logging
from ops.options import get_options

options = get_options()

LOG = logging.getLogger(__name__)


def periodic_task(*args, **kwargs):
    """Decorator to indicate that a method is a periodic task.

    This decorator can be used in two ways:

        1. Without arguments '@periodic_task', this will be run on every tick
           of the periodic scheduler.

        2. With arguments, @periodic_task(ticks_between_runs=N), this will be
           run on every N ticks of the periodic scheduler.
    """
    def decorator(f):
        f._periodic_task = True
예제 #2
0
파일: manager.py 프로젝트: halfss/blacklib
tasks to a wrapping service.

This module provides Manager, a base class for managers.

"""
import socket
import eventlet

from ops import utils
from ops import log as logging
from ops.options import get_options

options = get_options()


LOG = logging.getLogger(__name__)


def periodic_task(*args, **kwargs):
    """Decorator to indicate that a method is a periodic task.

    This decorator can be used in two ways:

        1. Without arguments '@periodic_task', this will be run on every tick
           of the periodic scheduler.

        2. With arguments, @periodic_task(ticks_between_runs=N), this will be
           run on every N ticks of the periodic scheduler.
    """
    def decorator(f):
        f._periodic_task = True
예제 #3
0
from ops import log as logging

from ops.service import db as service_db

auth_opts = [
    {
        "name": "policy",
        "default": "ops.api.auth.policy",
        "help": "",
        "type": str,
    },
]

options = get_options(auth_opts, 'auth')

LOG = logging.getLogger()


def load_policy():
    option_split = options.policy.split(".")
    mod = option_split[0]
    fun = options.policy[options.policy.rfind('.') + 1:]
    fn_, modpath, desc = imp.find_module(mod)
    fn_, path, desc = imp.find_module(
        fun, [os.path.join(modpath, "/".join(option_split[1:-1]))])
    return imp.load_module(fun, fn_, path, desc)


class BaseAuth(tornado.web.RequestHandler):
    def __init__(self, application, request, **kwargs):
        super(BaseAuth, self).__init__(application, request, **kwargs)
예제 #4
0
#coding=utf8

from ops.api.utils import load_url_map
from ops import log as logging 

LOG = logging.getLogger('api')

url_map = load_url_map(__path__, __package__, log=LOG)
예제 #5
0
파일: auth.py 프로젝트: halfss/blacklib
from ops import log as logging

from ops.service import db as service_db

auth_opts = [
        {
            "name": "policy",
            "default": "ops.api.auth.policy",
            "help": "",
            "type": str,
        },
]

options = get_options(auth_opts, 'auth')

LOG = logging.getLogger()



def load_policy():
    option_split = options.policy.split(".")
    mod = option_split[0]
    fun = options.policy[options.policy.rfind('.')+1:]
    fn_, modpath, desc = imp.find_module(mod)
    fn_, path, desc = imp.find_module(fun, [os.path.join(modpath, "/".join(option_split[1:-1]))])
    return imp.load_module(fun, fn_, path, desc)
    

class BaseAuth(tornado.web.RequestHandler):
    def __init__(self, application, request, **kwargs):
        super(BaseAuth, self).__init__(application, request, **kwargs)