示例#1
0
文件: worker.py 项目: aig-/turbolift
def start_work():
    """Begin Work."""

    def get_method(method, name):
        """Import what is required to run the System."""

        to_import = '%s.%s' % (method.__name__, name)
        return __import__(to_import, fromlist="None")

    def get_actions(module, name):
        """Get all available actions from an imported method.

        :param module:
        :param name:
        :return method attributes:
        """

        return getattr(module, name)

    # Low imports for load in module.
    import pkgutil

    # Low imports for load in module.
    import turbolift as turbo
    from turbolift.authentication import authentication as auth
    from turbolift import methods as met

    try:
        for mod, name, package in pkgutil.iter_modules(met.__path__):
            if ARGS.get(name) is not None:
                titled_name = name.title().replace('_', '')
                method = get_method(method=met, name=name)
                actions = get_actions(module=method, name=titled_name)
                actions(auth=auth.authenticate()).start()
                break
        else:
            raise turbo.SystemProblem('No Method set for processing')
    except KeyboardInterrupt:
        turbo.emergency_kill(reclaim=True)
示例#2
0
# Load our Logger
from turbolift.logger import logger
log_method = logger.load_in(
    log_level='info',
    log_file='turbolift_library',
    log_location=HOME
)


# Load our constants
turbolift.load_constants(log_method, args)


# Authenticate against the swift API
from turbolift.authentication import authentication
authentication = authentication.authenticate()


# Package up the Payload
import turbolift.utils.http_utils as http
payload = http.prep_payload(
    auth=authentication,
    container=args.get('container'),
    source=args.get('source'),
    args=args
)


# Load all of our available cloud actions
from turbolift.clouderator import actions
cf_actions = actions.CloudActions(payload=payload)
示例#3
0
    'quiet': True,  # Make the application not print stdout
    'container': 'test9000'  # Name of the container
}

# Load our Logger
from turbolift.logger import logger
log_method = logger.load_in(log_level='info',
                            log_file='turbolift_library',
                            log_location=HOME)

# Load our constants
turbolift.load_constants(log_method, args)

# Authenticate against the swift API
from turbolift.authentication import authentication
authentication = authentication.authenticate()

# Package up the Payload
import turbolift.utils.http_utils as http
payload = http.prep_payload(auth=authentication,
                            container=args.get('container'),
                            source=args.get('source'),
                            args=args)

# Load all of our available cloud actions
from turbolift.clouderator import actions
cf_actions = actions.CloudActions(payload=payload)

# List Objects
# =============================================================================
kwargs = {