示例#1
0
def main():
    parser = build_parser()
    args = parser.parse_args()
    if len(args.grep_args) == 0:
        parser.print_help()
        return 1
    if args.grep and args.json:
        print "Illegal options: cannot use both -j and -g."
        parser.print_help()
        return 2

    lazy_scores = delay(get_scores, args.grep_args)
    scores = delay(
        lambda: sorted(lazy_scores[0].iteritems(), key=itemgetter(1))[::-1])
    author_to_files = delay(lambda: lazy_scores[1])

    # By default, we only want to print the scores (the -s argument) unless
    # others are explicitly given.
    print_scores = args.scores or not (args.scores or args.files or args.grep)
    print_grep = args.grep
    print_files = args.files
    print_json = args.json

    if print_scores or print_files:
        if force(lazy_scores) is None:
            return 1

    if print_json:
        data = {}
        if print_scores:
            data['scores'] = scores
        if print_files:
            data['files'] = author_to_files

        print json.dumps(data, sort_keys=True, indent=4)
        return 0

    if print_scores:
        print "High score list:"
        for author, score in scores:
            print "    %s with a score of %d" % (author, score)
        print

    if print_grep:
        print annotate_grep(args.grep_args)

    if print_files:
        print "Files touched by authors:"
        for author, files in sorted(force(author_to_files).iteritems()):
            print '\n    %s:' % author
            for f in files:
                print(' ' * 8) + f

    return 0
示例#2
0
def main():
    parser = build_parser()
    args = parser.parse_args()
    if len(args.grep_args) == 0:
        parser.print_help()
        return 1
    if args.grep and args.json:
        print "Illegal options: cannot use both -j and -g."
        parser.print_help()
        return 2

    lazy_scores = delay(get_scores, args.grep_args)
    scores = delay(lambda: sorted(lazy_scores[0].iteritems(), key = itemgetter(1))[::-1])
    author_to_files = delay(lambda: lazy_scores[1])

    # By default, we only want to print the scores (the -s argument) unless
    # others are explicitly given.
    print_scores = args.scores or not (args.scores or args.files or args.grep)
    print_grep = args.grep
    print_files = args.files
    print_json = args.json

    if print_scores or print_files:
        if force(lazy_scores) is None:
            return 1

    if print_json:
        data = {}
        if print_scores:
            data['scores'] = scores
        if print_files:
            data['files'] = author_to_files

        print json.dumps(data, sort_keys = True, indent = 4)
        return 0

    if print_scores:
        print "High score list:"
        for author, score in scores:
            print "    %s with a score of %d" % (author, score)
        print

    if print_grep:
        print annotate_grep(args.grep_args)

    if print_files:
        print "Files touched by authors:"
        for author, files in sorted(force(author_to_files).iteritems()):
            print '\n    %s:' % author
            for f in files:
                print (' ' * 8) + f

    return 0
示例#3
0
# coding=utf-8
import lazypy
import logging
import os
import os.path

logger = logging.getLogger(__name__)
# default setting
CONFIG_DIR = os.environ.get('ENERGY_SAVING_CONFIG_DIR', '/etc/energy_saving')

DATABASE_TYPE = 'mysql'
DATABASE_USER = '******'
DATABASE_PASSWORD = '******'
DATABASE_IP = '127.0.0.1'
DATABASE_PORT = 3306
DATABASE_SERVER = lazypy.delay(lambda: '%s:%s' % (DATABASE_IP, DATABASE_PORT))
DATABASE_NAME = 'energy_saving'
DATABASE_URI = lazypy.delay(lambda: '%s://%s:%s@%s/%s' % (
    lazypy.force(DATABASE_TYPE), lazypy.force(DATABASE_USER),
    lazypy.force(DATABASE_PASSWORD), lazypy.force(DATABASE_SERVER),
    lazypy.force(DATABASE_NAME)))

DATABASE_POOL_TYPE = 'instant'

DEBUG = True
SERVER_PORT = 80
DEFAULT_LOGLEVEL = 'debug'
DEFAULT_LOGDIR = '/var/log/energy_saving'
DEFAULT_LOGINTERVAL = 6
DEFAULT_LOGINTERVAL_UNIT = 'h'
DEFAULT_LOGFORMAT = (
示例#4
0
SQLALCHEMY_DATABASE_URI = "sqlite://"
SQLALCHEMY_DATABASE_POOL_TYPE = "static"
COBBLER_INSTALLATION_LOGDIR = "/var/log/cobbler/anamon"
CHEF_INSTALLATION_LOGDIR = "/var/log/chef"
INSTALLATION_LOGDIR = {"CobblerInstaller": COBBLER_INSTALLATION_LOGDIR, "ChefInstaller": CHEF_INSTALLATION_LOGDIR}
CLUSTERHOST_INATALLATION_LOGDIR_NAME = "name"
HOST_INSTALLATION_LOGDIR_NAME = "name"
DEFAULT_LOGLEVEL = "debug"
DEFAULT_LOGDIR = "/tmp"
DEFAULT_LOGINTERVAL = 1
DEFAULT_LOGINTERVAL_UNIT = "h"
DEFAULT_LOGFORMAT = "%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s"
DEFAULT_LOGBACKUPCOUNT = 5
WEB_LOGFILE = ""
CELERY_LOGFILE = ""
CELERYCONFIG_DIR = lazypy.delay(lambda: CONFIG_DIR)
CELERYCONFIG_FILE = ""
PROGRESS_UPDATE_INTERVAL = 30
POLLSWITCH_INTERVAL = 60
SWITCHES = []

USER_AUTH_HEADER_NAME = "X-Auth-Token"
USER_TOKEN_DURATION = "2h"
COMPASS_ADMIN_EMAIL = "*****@*****.**"
COMPASS_ADMIN_PASSWORD = "******"
COMPASS_DEFAULT_PERMISSIONS = ["list_permissions"]
SWITCHES_DEFAULT_FILTERS = []
DEFAULT_SWITCH_IP = "0.0.0.0"
DEFAULT_SWITCH_PORT = 0

COMPASS_SUPPORTED_PROXY = "http://127.0.0.1:3128"
示例#5
0
INSTALLATION_LOGDIR = {
    'CobblerInstaller': COBBLER_INSTALLATION_LOGDIR,
    'ChefInstaller': CHEF_INSTALLATION_LOGDIR
}
CLUSTERHOST_INATALLATION_LOGDIR_NAME = 'name'
HOST_INSTALLATION_LOGDIR_NAME = 'name'
DEFAULT_LOGLEVEL = 'debug'
DEFAULT_LOGDIR = '/tmp'
DEFAULT_LOGINTERVAL = 1
DEFAULT_LOGINTERVAL_UNIT = 'h'
DEFAULT_LOGFORMAT = (
    '%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s')
DEFAULT_LOGBACKUPCOUNT = 5
WEB_LOGFILE = ''
CELERY_LOGFILE = ''
CELERYCONFIG_DIR = lazypy.delay(lambda: CONFIG_DIR)
CELERYCONFIG_FILE = ''
PROGRESS_UPDATE_INTERVAL = 30
POLLSWITCH_INTERVAL = 60
SWITCHES = []

USER_AUTH_HEADER_NAME = 'X-Auth-Token'
USER_TOKEN_DURATION = '2h'
COMPASS_ADMIN_EMAIL = '*****@*****.**'
COMPASS_ADMIN_PASSWORD = '******'
COMPASS_DEFAULT_PERMISSIONS = [
    'list_permissions',
]
SWITCHES_DEFAULT_FILTERS = []
DEFAULT_SWITCH_IP = '0.0.0.0'
DEFAULT_SWITCH_PORT = 0
示例#6
0
INSTALLATION_LOGDIR = {
    'CobblerInstaller': COBBLER_INSTALLATION_LOGDIR,
    'ChefInstaller': CHEF_INSTALLATION_LOGDIR
}
CLUSTERHOST_INATALLATION_LOGDIR_NAME = 'name'
HOST_INSTALLATION_LOGDIR_NAME = 'name'
DEFAULT_LOGLEVEL = 'debug'
DEFAULT_LOGDIR = '/tmp'
DEFAULT_LOGINTERVAL = 1
DEFAULT_LOGINTERVAL_UNIT = 'h'
DEFAULT_LOGFORMAT = (
    '%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s')
DEFAULT_LOGBACKUPCOUNT = 5
WEB_LOGFILE = ''
CELERY_LOGFILE = ''
CELERYCONFIG_DIR = lazypy.delay(lambda: CONFIG_DIR)
CELERYCONFIG_FILE = ''
PROGRESS_UPDATE_INTERVAL = 30
POLLSWITCH_INTERVAL = 60
SWITCHES = [
]

USER_AUTH_HEADER_NAME = 'X-Auth-Token'
USER_TOKEN_DURATION = '2h'
COMPASS_ADMIN_EMAIL = '*****@*****.**'
COMPASS_ADMIN_PASSWORD = '******'
COMPASS_DEFAULT_PERMISSIONS = [
    'list_permissions',
]
SWITCHES_DEFAULT_FILTERS = []
DEFAULT_SWITCH_IP = '0.0.0.0'
from orca.utils import flags
from orca.utils import logsetting
from orca.utils import setting_util as util
from orca.utils import setting_wrapper as setting

if os.environ.get('CELERY_CONFIG_LOGGING'):
    flags.init()
    flags.OPTIONS.logfile = util.parse(setting.CELERY_LOGFILE)
    logsetting.init()

CELERY_RESULT_BACKEND = 'amqp://'

BROKER_PROTOCOL = 'amqp'
DEFAULT_BROKER_USER = '******'
BROKER_USER = lazypy.delay(
    lambda: util.get_from_config(setting.CONFIG, [
        'propertySources', 0, 'source', 'lograbbitmq.instance.username'
    ], DEFAULT_BROKER_HOST))
BROKER_PASSWORD_ENCRYPT_PATTERN = {
    'strContent':
    '%(password)s',
    'strSecretkey':
    lazypy.delay(lambda: util.get_from_config(setting.CONFIG, [
        'propertySources', 0, 'source', 'lograbbitmq.instance.secretkey'
    ], 'DEPLOY')),
    'strSecretValue':
    lazypy.delay(lambda: util.get_from_config(
        setting.CONFIG, [
            'propertySources', 0, 'source', 'lograbbitmq.instance.secretValue'
        ], 'B2CAD4CE182A2736D90D8AA46D1683191D975D9D3150297'
        'F9497F06FE35004F6E396D98426B4490755FAEBC5FC4713F1'))
}
示例#8
0
SQLALCHEMY_DATABASE_POOL_TYPE = 'static'
INSTALLATION_LOGDIR = {
    'CobblerInstaller': '/var/log/cobbler/anamon',
    'ChefInstaller': '/var/log/chef'
}
CLUSTERHOST_INATALLATION_LOGDIR_NAME = 'name'
HOST_INSTALLATION_LOGDIR_NAME = 'name'
DEFAULT_LOGLEVEL = 'debug'
DEFAULT_LOGDIR = '/tmp'
DEFAULT_LOGINTERVAL = 1
DEFAULT_LOGINTERVAL_UNIT = 'h'
DEFAULT_LOGFORMAT = (
    '%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s')
WEB_LOGFILE = ''
CELERY_LOGFILE = ''
CELERYCONFIG_DIR = lazypy.delay(lambda: CONFIG_DIR)
CELERYCONFIG_FILE = ''
PROGRESS_UPDATE_INTERVAL = 30
POLLSWITCH_INTERVAL = 60
SWITCHES = [
]

USER_AUTH_HEADER_NAME = 'X-Auth-Token'
USER_TOKEN_DURATION = '2h'
COMPASS_ADMIN_EMAIL = '*****@*****.**'
COMPASS_ADMIN_PASSWORD = '******'
COMPASS_DEFAULT_PERMISSIONS = [
    'list_permissions',
]
SWITCHES_DEFAULT_FILTERS = []
DEFAULT_SWITCH_IP = '0.0.0.0'