Pylint and pep8 cleanup
This commit is contained in:
parent
c9e9791d8a
commit
77a036c6c8
@ -89,7 +89,7 @@ def run(args):
|
|||||||
|
|
||||||
# Load the distro
|
# Load the distro
|
||||||
dist = distro.load(settings.DISTRO_DIR)
|
dist = distro.load(settings.DISTRO_DIR)
|
||||||
|
|
||||||
# Load + verify the person
|
# Load + verify the person
|
||||||
try:
|
try:
|
||||||
persona_obj = persona.load(persona_fn)
|
persona_obj = persona.load(persona_fn)
|
||||||
@ -129,7 +129,7 @@ def load_previous_settings():
|
|||||||
settings_prev = None
|
settings_prev = None
|
||||||
try:
|
try:
|
||||||
# Don't use sh here so that we always
|
# Don't use sh here so that we always
|
||||||
# read this (even if dry-run)
|
# read this (even if dry-run)
|
||||||
with open("/etc/anvil/settings.yaml", 'r') as fh:
|
with open("/etc/anvil/settings.yaml", 'r') as fh:
|
||||||
settings_prev = utils.load_yaml_text(fh.read())
|
settings_prev = utils.load_yaml_text(fh.read())
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -173,7 +173,7 @@ def main():
|
|||||||
Arguments: N/A
|
Arguments: N/A
|
||||||
Returns: 1 for success, 0 for failure
|
Returns: 1 for success, 0 for failure
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Do this first so people can see the help message...
|
# Do this first so people can see the help message...
|
||||||
args = opts.parse(load_previous_settings())
|
args = opts.parse(load_previous_settings())
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ class Action(object):
|
|||||||
self.keyring_encrypted = cli_opts.pop('keyring_encrypted')
|
self.keyring_encrypted = cli_opts.pop('keyring_encrypted')
|
||||||
self.prompt_for_passwords = cli_opts.pop('prompt_for_passwords', False)
|
self.prompt_for_passwords = cli_opts.pop('prompt_for_passwords', False)
|
||||||
self.store_passwords = cli_opts.pop('store_passwords', True)
|
self.store_passwords = cli_opts.pop('store_passwords', True)
|
||||||
self.cli_opts = cli_opts # Stored for components to get any options
|
# Stored for components to get any options
|
||||||
|
self.cli_opts = cli_opts
|
||||||
|
|
||||||
def _establish_passwords(self, component_order, instances):
|
def _establish_passwords(self, component_order, instances):
|
||||||
kr = pw.KeyringProxy(self.keyring_path,
|
kr = pw.KeyringProxy(self.keyring_path,
|
||||||
|
@ -185,7 +185,7 @@ class YamlInterpolator(object):
|
|||||||
elif isinstance(v, (list, set, tuple)):
|
elif isinstance(v, (list, set, tuple)):
|
||||||
n_v = self._interpolate_iterable(v)
|
n_v = self._interpolate_iterable(v)
|
||||||
return n_v
|
return n_v
|
||||||
|
|
||||||
def _interpolate_string(self, what):
|
def _interpolate_string(self, what):
|
||||||
if not re.search(INTERP_PAT, what):
|
if not re.search(INTERP_PAT, what):
|
||||||
return what
|
return what
|
||||||
|
@ -24,13 +24,13 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Component(object):
|
class Component(object):
|
||||||
def __init__(self, name, subsystems, instances, options, siblings, distro, passwords, **kwargs):
|
def __init__(self, name, subsystems, instances, options, siblings, distro, passwords, **kwargs):
|
||||||
# Subsystems this was requested with
|
# Subsystems this was requested with
|
||||||
self.subsystems = subsystems
|
self.subsystems = subsystems
|
||||||
|
|
||||||
# The component name (from config)
|
# The component name (from config)
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
# Any component options
|
# Any component options
|
||||||
self.options = options
|
self.options = options
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ class Component(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def warm_configs(self):
|
def warm_configs(self):
|
||||||
# Before any actions occur you get the chance to
|
# Before any actions occur you get the chance to
|
||||||
# warmup the configs u might use (ie for prompting for passwords
|
# warmup the configs u might use (ie for prompting for passwords
|
||||||
# earlier rather than later)
|
# earlier rather than later)
|
||||||
pass
|
pass
|
||||||
|
@ -54,13 +54,15 @@ from anvil.packaging import pip
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
####
|
####
|
||||||
#### STATUS CONSTANTS
|
#### STATUS CONSTANTS
|
||||||
####
|
####
|
||||||
STATUS_INSTALLED = 'installed'
|
STATUS_INSTALLED = 'installed'
|
||||||
STATUS_STARTED = "started"
|
STATUS_STARTED = "started"
|
||||||
STATUS_STOPPED = "stopped"
|
STATUS_STOPPED = "stopped"
|
||||||
STATUS_UNKNOWN = "unknown"
|
STATUS_UNKNOWN = "unknown"
|
||||||
|
|
||||||
|
|
||||||
class ProgramStatus(object):
|
class ProgramStatus(object):
|
||||||
def __init__(self, status, name=None, details=''):
|
def __init__(self, status, name=None, details=''):
|
||||||
self.name = name
|
self.name = name
|
||||||
@ -71,15 +73,17 @@ class ProgramStatus(object):
|
|||||||
#### Utils...
|
#### Utils...
|
||||||
####
|
####
|
||||||
|
|
||||||
|
|
||||||
def make_packager(package, default_class, **kwargs):
|
def make_packager(package, default_class, **kwargs):
|
||||||
cls = packager.get_packager_class(package, default_class)
|
cls = packager.get_packager_class(package, default_class)
|
||||||
return cls(**kwargs)
|
return cls(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
#### INSTALL CLASSES
|
#### INSTALL CLASSES
|
||||||
####
|
####
|
||||||
|
|
||||||
|
|
||||||
class PkgInstallComponent(component.Component):
|
class PkgInstallComponent(component.Component):
|
||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
component.Component.__init__(self, *args, **kargs)
|
component.Component.__init__(self, *args, **kargs)
|
||||||
@ -512,7 +516,7 @@ class PythonInstallComponent(PkgInstallComponent):
|
|||||||
return configured_am
|
return configured_am
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
#### RUNTIME CLASSES
|
#### RUNTIME CLASSES
|
||||||
####
|
####
|
||||||
|
|
||||||
@ -612,7 +616,7 @@ class PythonRuntime(ProgramRuntime):
|
|||||||
|
|
||||||
def _post_app_start(self, app_info):
|
def _post_app_start(self, app_info):
|
||||||
if 'sleep_time' in app_info:
|
if 'sleep_time' in app_info:
|
||||||
LOG.info("%s requested a %s second sleep time, please wait...",
|
LOG.info("%s requested a %s second sleep time, please wait...",
|
||||||
colorizer.quote(app_info.get('name')), app_info.get('sleep_time'))
|
colorizer.quote(app_info.get('name')), app_info.get('sleep_time'))
|
||||||
sh.sleep(int(app_info.get('sleep_time')))
|
sh.sleep(int(app_info.get('sleep_time')))
|
||||||
|
|
||||||
@ -668,7 +672,7 @@ class PythonRuntime(ProgramRuntime):
|
|||||||
return statii
|
return statii
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
#### UNINSTALL CLASSES
|
#### UNINSTALL CLASSES
|
||||||
####
|
####
|
||||||
|
|
||||||
@ -790,7 +794,7 @@ class PythonUninstallComponent(PkgUninstallComponent):
|
|||||||
LOG.warn("No python directory found at %s - skipping", colorizer.quote(where, quote_color='red'))
|
LOG.warn("No python directory found at %s - skipping", colorizer.quote(where, quote_color='red'))
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
#### TESTING CLASSES
|
#### TESTING CLASSES
|
||||||
####
|
####
|
||||||
|
|
||||||
@ -803,10 +807,10 @@ class EmptyTestingComponent(component.Component):
|
|||||||
class PythonTestingComponent(component.Component):
|
class PythonTestingComponent(component.Component):
|
||||||
def _get_test_exclusions(self):
|
def _get_test_exclusions(self):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def _use_run_tests(self):
|
def _use_run_tests(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_test_command(self):
|
def _get_test_command(self):
|
||||||
# See: http://docs.openstack.org/developer/nova/devref/unit_tests.html
|
# See: http://docs.openstack.org/developer/nova/devref/unit_tests.html
|
||||||
# And: http://wiki.openstack.org/ProjectTestingInterface
|
# And: http://wiki.openstack.org/ProjectTestingInterface
|
||||||
@ -828,6 +832,7 @@ class PythonTestingComponent(component.Component):
|
|||||||
app_dir = self.get_option('app_dir')
|
app_dir = self.get_option('app_dir')
|
||||||
tox_fn = sh.joinpths(app_dir, 'tox.ini')
|
tox_fn = sh.joinpths(app_dir, 'tox.ini')
|
||||||
if sh.isfile(tox_fn):
|
if sh.isfile(tox_fn):
|
||||||
|
# Suck out some settings from the tox file
|
||||||
try:
|
try:
|
||||||
tox_cfg = cfg.BuiltinConfigParser(fns=[tox_fn])
|
tox_cfg = cfg.BuiltinConfigParser(fns=[tox_fn])
|
||||||
env_values = tox_cfg.get('testenv', 'setenv') or ''
|
env_values = tox_cfg.get('testenv', 'setenv') or ''
|
||||||
@ -856,7 +861,7 @@ class PythonTestingComponent(component.Component):
|
|||||||
def run_tests(self):
|
def run_tests(self):
|
||||||
app_dir = self.get_option('app_dir')
|
app_dir = self.get_option('app_dir')
|
||||||
if not sh.isdir(app_dir):
|
if not sh.isdir(app_dir):
|
||||||
LOG.warn("Unable to find application directory at %s, can not run %s tests.",
|
LOG.warn("Unable to find application directory at %s, can not run %s tests.",
|
||||||
colorizer.quote(app_dir), colorizer.quote(self.name))
|
colorizer.quote(app_dir), colorizer.quote(self.name))
|
||||||
return
|
return
|
||||||
cmd = self._get_test_command()
|
cmd = self._get_test_command()
|
||||||
@ -864,7 +869,7 @@ class PythonTestingComponent(component.Component):
|
|||||||
sh.execute(*cmd, stdout_fh=None, stderr_fh=None, cwd=app_dir, env_overrides=env)
|
sh.execute(*cmd, stdout_fh=None, stderr_fh=None, cwd=app_dir, env_overrides=env)
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
#### PACKAGING CLASSES
|
#### PACKAGING CLASSES
|
||||||
####
|
####
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class GlanceInstaller(comp.PythonInstallComponent):
|
|||||||
def _fetch_keystone_params(self):
|
def _fetch_keystone_params(self):
|
||||||
params = khelper.get_shared_params(ip=self.get_option('ip'),
|
params = khelper.get_shared_params(ip=self.get_option('ip'),
|
||||||
service_user='glance',
|
service_user='glance',
|
||||||
**utils.merge_dicts(self.get_option('keystone'),
|
**utils.merge_dicts(self.get_option('keystone'),
|
||||||
khelper.get_shared_passwords(self)))
|
khelper.get_shared_passwords(self)))
|
||||||
return {
|
return {
|
||||||
'auth_host': params['endpoints']['admin']['host'],
|
'auth_host': params['endpoints']['admin']['host'],
|
||||||
@ -125,10 +125,6 @@ class GlanceInstaller(comp.PythonInstallComponent):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _config_adjust_paste(self, contents, fn):
|
def _config_adjust_paste(self, contents, fn):
|
||||||
params = khelper.get_shared_params(ip=self.get_option('ip'),
|
|
||||||
service_user='glance',
|
|
||||||
**utils.merge_dicts(self.get_option('keystone'),
|
|
||||||
khelper.get_shared_passwords(self)))
|
|
||||||
with io.BytesIO(contents) as stream:
|
with io.BytesIO(contents) as stream:
|
||||||
config = cfg.create_parser(cfg.RewritableConfigParser, self)
|
config = cfg.create_parser(cfg.RewritableConfigParser, self)
|
||||||
config.readfp(stream)
|
config.readfp(stream)
|
||||||
@ -151,7 +147,7 @@ class GlanceInstaller(comp.PythonInstallComponent):
|
|||||||
config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
|
config.set('DEFAULT', 'sql_connection', dbhelper.fetch_dbdsn(dbname=DB_NAME,
|
||||||
utf8=True,
|
utf8=True,
|
||||||
dbtype=self.get_option('db', 'type'),
|
dbtype=self.get_option('db', 'type'),
|
||||||
**utils.merge_dicts(self.get_option('db'),
|
**utils.merge_dicts(self.get_option('db'),
|
||||||
dbhelper.get_shared_passwords(self))))
|
dbhelper.get_shared_passwords(self))))
|
||||||
config.remove_option('DEFAULT', 'log_file')
|
config.remove_option('DEFAULT', 'log_file')
|
||||||
config.set('paste_deploy', 'flavor', self.get_option('paste_flavor'))
|
config.set('paste_deploy', 'flavor', self.get_option('paste_flavor'))
|
||||||
@ -269,8 +265,7 @@ class GlanceTester(comp.PythonTestingComponent):
|
|||||||
#
|
#
|
||||||
# It seems to assume tox is being used, which we can't use directly
|
# It seems to assume tox is being used, which we can't use directly
|
||||||
# since anvil doesn't really do venv stuff (its meant to avoid those...)
|
# since anvil doesn't really do venv stuff (its meant to avoid those...)
|
||||||
cmd = ['nosetests','--exclude-dir=glance/tests/functional',
|
cmd = ['nosetests', '--exclude-dir=glance/tests/functional']
|
||||||
'--with-coverage','--cover-package=glance']
|
|
||||||
for e in self._get_test_exclusions():
|
for e in self._get_test_exclusions():
|
||||||
cmd.append('--exclude=%s' % (e))
|
cmd.append('--exclude=%s' % (e))
|
||||||
return cmd
|
return cmd
|
||||||
|
@ -346,7 +346,6 @@ class Image(object):
|
|||||||
return (sh.exists(self.url) or (self.parsed_url.scheme == '' and self.parsed_url.netloc == ''))
|
return (sh.exists(self.url) or (self.parsed_url.scheme == '' and self.parsed_url.netloc == ''))
|
||||||
|
|
||||||
def _cached_paths(self):
|
def _cached_paths(self):
|
||||||
url_fn = self._extract_url_fn()
|
|
||||||
md5er = hashlib.new('md5')
|
md5er = hashlib.new('md5')
|
||||||
md5er.update(self.url)
|
md5er.update(self.url)
|
||||||
path = sh.joinpths(self.cache_dir, md5er.hexdigest())
|
path = sh.joinpths(self.cache_dir, md5er.hexdigest())
|
||||||
|
@ -151,7 +151,7 @@ class ConfConfigurator(object):
|
|||||||
|
|
||||||
nova_conf.add('verbose', self.installer.get_bool_option('verbose'))
|
nova_conf.add('verbose', self.installer.get_bool_option('verbose'))
|
||||||
|
|
||||||
# Allow destination machine to match source for resize.
|
# Allow destination machine to match source for resize.
|
||||||
nova_conf.add('allow_resize_to_same_host', True)
|
nova_conf.add('allow_resize_to_same_host', True)
|
||||||
|
|
||||||
# Which scheduler do u want?
|
# Which scheduler do u want?
|
||||||
@ -197,7 +197,7 @@ class ConfConfigurator(object):
|
|||||||
|
|
||||||
# Auth will be using keystone
|
# Auth will be using keystone
|
||||||
nova_conf.add('auth_strategy', 'keystone')
|
nova_conf.add('auth_strategy', 'keystone')
|
||||||
|
|
||||||
# Is config drive being forced?
|
# Is config drive being forced?
|
||||||
if self.installer.get_bool_option('force_cfg_drive'):
|
if self.installer.get_bool_option('force_cfg_drive'):
|
||||||
nova_conf.add('force_config_drive', 'always')
|
nova_conf.add('force_config_drive', 'always')
|
||||||
@ -229,7 +229,7 @@ class ConfConfigurator(object):
|
|||||||
nova_conf.add('rabbit_password', rbhelper.get_shared_passwords(self.installer)['pw'])
|
nova_conf.add('rabbit_password', rbhelper.get_shared_passwords(self.installer)['pw'])
|
||||||
nova_conf.add('rabbit_userid', self.installer.get_option('rabbit', 'user_id'))
|
nova_conf.add('rabbit_userid', self.installer.get_option('rabbit', 'user_id'))
|
||||||
nova_conf.add('rpc_backend', 'nova.rpc.impl_kombu')
|
nova_conf.add('rpc_backend', 'nova.rpc.impl_kombu')
|
||||||
|
|
||||||
# The USB tablet device is meant to improve mouse behavior in
|
# The USB tablet device is meant to improve mouse behavior in
|
||||||
# the VNC console, but it has the side effect of increasing
|
# the VNC console, but it has the side effect of increasing
|
||||||
# the CPU usage of an idle VM tenfold.
|
# the CPU usage of an idle VM tenfold.
|
||||||
|
@ -19,6 +19,7 @@ from anvil import log
|
|||||||
|
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def get_shared_passwords(component):
|
def get_shared_passwords(component):
|
||||||
mp = {}
|
mp = {}
|
||||||
mp['pw'] = component.get_password('rabbit')
|
mp['pw'] = component.get_password('rabbit')
|
||||||
|
@ -59,12 +59,12 @@ class HorizonInstaller(comp.PythonInstallComponent):
|
|||||||
def __init__(self, *args, **kargs):
|
def __init__(self, *args, **kargs):
|
||||||
comp.PythonInstallComponent.__init__(self, *args, **kargs)
|
comp.PythonInstallComponent.__init__(self, *args, **kargs)
|
||||||
self.blackhole_dir = sh.joinpths(self.get_option('app_dir'), '.blackhole')
|
self.blackhole_dir = sh.joinpths(self.get_option('app_dir'), '.blackhole')
|
||||||
self.access_log = sh.joinpths('/var/log/',
|
self.access_log = sh.joinpths('/var/log/',
|
||||||
self.distro.get_command_config('apache', 'name'),
|
self.distro.get_command_config('apache', 'name'),
|
||||||
'horizon_access.log')
|
'horizon_access.log')
|
||||||
self.error_log = sh.joinpths('/var/log/',
|
self.error_log = sh.joinpths('/var/log/',
|
||||||
self.distro.get_command_config('apache', 'name'),
|
self.distro.get_command_config('apache', 'name'),
|
||||||
'horizon_error.log')
|
'horizon_error.log')
|
||||||
|
|
||||||
def _filter_pip_requires_line(self, fn, line):
|
def _filter_pip_requires_line(self, fn, line):
|
||||||
# Knock off all nova, quantum, swift, keystone, cinder
|
# Knock off all nova, quantum, swift, keystone, cinder
|
||||||
|
@ -200,9 +200,9 @@ class NovaInstaller(comp.PythonInstallComponent):
|
|||||||
def _config_adjust_paste(self, contents, fn):
|
def _config_adjust_paste(self, contents, fn):
|
||||||
params = khelper.get_shared_params(ip=self.get_option('ip'),
|
params = khelper.get_shared_params(ip=self.get_option('ip'),
|
||||||
service_user='nova',
|
service_user='nova',
|
||||||
**utils.merge_dicts(self.get_option('keystone'),
|
**utils.merge_dicts(self.get_option('keystone'),
|
||||||
khelper.get_shared_passwords(self)))
|
khelper.get_shared_passwords(self)))
|
||||||
|
|
||||||
with io.BytesIO(contents) as stream:
|
with io.BytesIO(contents) as stream:
|
||||||
config = cfg.create_parser(cfg.RewritableConfigParser, self)
|
config = cfg.create_parser(cfg.RewritableConfigParser, self)
|
||||||
config.readfp(stream)
|
config.readfp(stream)
|
||||||
|
@ -42,11 +42,11 @@ class memoized(object):
|
|||||||
value = self.func(*args)
|
value = self.func(*args)
|
||||||
self.cache[args] = value
|
self.cache[args] = value
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
'''Return the function's docstring.'''
|
'''Return the function's docstring.'''
|
||||||
return self.func.__doc__
|
return self.func.__doc__
|
||||||
|
|
||||||
def __get__(self, obj, objtype):
|
def __get__(self, obj, objtype):
|
||||||
'''Support instance methods.'''
|
'''Support instance methods.'''
|
||||||
return functools.partial(self.__call__, obj)
|
return functools.partial(self.__call__, obj)
|
||||||
|
@ -33,7 +33,6 @@ LOG = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
class Distro(object):
|
class Distro(object):
|
||||||
|
|
||||||
def __init__(self, name, platform_pattern, packager_name, commands, components):
|
def __init__(self, name, platform_pattern, packager_name, commands, components):
|
||||||
self.name = name
|
self.name = name
|
||||||
self._platform_pattern = re.compile(platform_pattern, re.IGNORECASE)
|
self._platform_pattern = re.compile(platform_pattern, re.IGNORECASE)
|
||||||
|
@ -26,7 +26,7 @@ from anvil import colorizer
|
|||||||
from anvil import log as logging
|
from anvil import log as logging
|
||||||
from anvil import shell as sh
|
from anvil import shell as sh
|
||||||
from anvil import utils
|
from anvil import utils
|
||||||
|
|
||||||
from anvil.components import db
|
from anvil.components import db
|
||||||
from anvil.components import horizon
|
from anvil.components import horizon
|
||||||
from anvil.components import nova
|
from anvil.components import nova
|
||||||
@ -166,7 +166,7 @@ class NovaInstaller(nova.NovaInstaller):
|
|||||||
cmd = ['groupadd', 'libvirtd']
|
cmd = ['groupadd', 'libvirtd']
|
||||||
sh.execute(*cmd, run_as_root=True)
|
sh.execute(*cmd, run_as_root=True)
|
||||||
if not sh.isfile(LIBVIRT_POLICY_FN):
|
if not sh.isfile(LIBVIRT_POLICY_FN):
|
||||||
contents = self._get_policy(self._get_policy_users())
|
contents = self._get_policy(self._get_policy_users())
|
||||||
with sh.Rooted(True):
|
with sh.Rooted(True):
|
||||||
sh.mkdirslist(sh.dirname(LIBVIRT_POLICY_FN))
|
sh.mkdirslist(sh.dirname(LIBVIRT_POLICY_FN))
|
||||||
sh.write_file(LIBVIRT_POLICY_FN, contents)
|
sh.write_file(LIBVIRT_POLICY_FN, contents)
|
||||||
|
@ -19,15 +19,13 @@ import contextlib
|
|||||||
import functools
|
import functools
|
||||||
import urllib2
|
import urllib2
|
||||||
|
|
||||||
from urlparse import (urlparse, parse_qs)
|
from urlparse import parse_qs
|
||||||
|
|
||||||
import progressbar
|
import progressbar
|
||||||
|
|
||||||
from anvil import colorizer
|
from anvil import colorizer
|
||||||
from anvil import exceptions as excp
|
|
||||||
from anvil import log as logging
|
from anvil import log as logging
|
||||||
from anvil import shell as sh
|
from anvil import shell as sh
|
||||||
from anvil import utils
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -75,7 +73,7 @@ class GitDownloader(Downloader):
|
|||||||
if branch or tag:
|
if branch or tag:
|
||||||
checkout_what = []
|
checkout_what = []
|
||||||
if tag:
|
if tag:
|
||||||
# Avoid 'detached HEAD state' message by moving to a
|
# Avoid 'detached HEAD state' message by moving to a
|
||||||
# $tag-anvil branch for that tag
|
# $tag-anvil branch for that tag
|
||||||
checkout_what = [tag, '-b', "%s-%s" % (tag, 'anvil')]
|
checkout_what = [tag, '-b', "%s-%s" % (tag, 'anvil')]
|
||||||
LOG.info("Adjusting to tag %s.", colorizer.quote(tag))
|
LOG.info("Adjusting to tag %s.", colorizer.quote(tag))
|
||||||
|
@ -37,6 +37,3 @@ def get_key(key, default_value=None):
|
|||||||
if value is None:
|
if value is None:
|
||||||
value = default_value
|
value = default_value
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ def _size_cb(option, opt_str, value, parser):
|
|||||||
parser.values.show_amount = utils.to_bytes(value)
|
parser.values.show_amount = utils.to_bytes(value)
|
||||||
except (TypeError, ValueError) as e:
|
except (TypeError, ValueError) as e:
|
||||||
raise OptionValueError("Invalid value for %s due to %s" % (opt_str, e))
|
raise OptionValueError("Invalid value for %s due to %s" % (opt_str, e))
|
||||||
|
|
||||||
|
|
||||||
def parse(previous_settings=None):
|
def parse(previous_settings=None):
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ def parse(previous_settings=None):
|
|||||||
help=("when packaging attempt to use the versions that are "
|
help=("when packaging attempt to use the versions that are "
|
||||||
"installed for the components dependencies"))
|
"installed for the components dependencies"))
|
||||||
parser.add_option_group(pkg_group)
|
parser.add_option_group(pkg_group)
|
||||||
|
|
||||||
install_group = OptionGroup(parser, "Install specific options")
|
install_group = OptionGroup(parser, "Install specific options")
|
||||||
install_group.add_option('-c', "--only-configure",
|
install_group.add_option('-c', "--only-configure",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
@ -140,7 +140,7 @@ def parse(previous_settings=None):
|
|||||||
parser.add_option_group(uninstall_group)
|
parser.add_option_group(uninstall_group)
|
||||||
|
|
||||||
# Extract only what we care about, these will be passed
|
# Extract only what we care about, these will be passed
|
||||||
# to the constructor of actions as arguments
|
# to the constructor of actions as arguments
|
||||||
# so don't adjust the naming wily nilly...
|
# so don't adjust the naming wily nilly...
|
||||||
if previous_settings:
|
if previous_settings:
|
||||||
parser.set_defaults(**previous_settings)
|
parser.set_defaults(**previous_settings)
|
||||||
|
@ -138,7 +138,7 @@ class DependencyPackager(comp.Component):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def _make_fn(self, ext):
|
def _make_fn(self, ext):
|
||||||
your_fn = "%s-%s-%s.%s" % (self.details['name'],
|
your_fn = "%s-%s-%s.%s" % (self.details['name'],
|
||||||
self.details['version'],
|
self.details['version'],
|
||||||
self.details['release'], ext)
|
self.details['release'], ext)
|
||||||
return your_fn
|
return your_fn
|
||||||
@ -192,7 +192,7 @@ class DependencyPackager(comp.Component):
|
|||||||
|
|
||||||
def package(self):
|
def package(self):
|
||||||
self._create_package()
|
self._create_package()
|
||||||
return self.package_dir
|
return self.package_dir
|
||||||
|
|
||||||
|
|
||||||
class PythonPackager(DependencyPackager):
|
class PythonPackager(DependencyPackager):
|
||||||
@ -200,12 +200,13 @@ class PythonPackager(DependencyPackager):
|
|||||||
DependencyPackager.__init__(self, *args, **kargs)
|
DependencyPackager.__init__(self, *args, **kargs)
|
||||||
self._extended_details = None
|
self._extended_details = None
|
||||||
self._setup_fn = sh.joinpths(self.get_option('app_dir'), 'setup.py')
|
self._setup_fn = sh.joinpths(self.get_option('app_dir'), 'setup.py')
|
||||||
|
|
||||||
def _build_requirements(self):
|
def _build_requirements(self):
|
||||||
return [
|
return [
|
||||||
'python',
|
'python',
|
||||||
'python-devel',
|
'python-devel',
|
||||||
'gcc', # Often used for building c python modules, should not be harmful...
|
# Often used for building c python modules, should not be harmful...
|
||||||
|
'gcc',
|
||||||
'python-setuptools',
|
'python-setuptools',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -29,19 +29,6 @@ LOG = logging.getLogger(__name__)
|
|||||||
RAND_PW_LEN = 20
|
RAND_PW_LEN = 20
|
||||||
PW_USER = 'anvil'
|
PW_USER = 'anvil'
|
||||||
|
|
||||||
# There is some weird issue fixed after 0.9.2
|
|
||||||
# this applies that fix for us for now (taken from the trunk code)...
|
|
||||||
class FixedCryptedFileKeyring(CryptedFileKeyring):
|
|
||||||
|
|
||||||
@properties.NonDataProperty
|
|
||||||
def keyring_key(self):
|
|
||||||
# _unlock or _init_file will set the key or raise an exception
|
|
||||||
if self._check_file():
|
|
||||||
self._unlock()
|
|
||||||
else:
|
|
||||||
self._init_file()
|
|
||||||
return self.keyring_key
|
|
||||||
|
|
||||||
|
|
||||||
class KeyringProxy(object):
|
class KeyringProxy(object):
|
||||||
def __init__(self, path, keyring_encrypted=False, enable_prompt=True, random_on_empty=True):
|
def __init__(self, path, keyring_encrypted=False, enable_prompt=True, random_on_empty=True):
|
||||||
@ -50,7 +37,7 @@ class KeyringProxy(object):
|
|||||||
path = "%s.crypt" % (path)
|
path = "%s.crypt" % (path)
|
||||||
self.path = path
|
self.path = path
|
||||||
if keyring_encrypted:
|
if keyring_encrypted:
|
||||||
self.ring = FixedCryptedFileKeyring()
|
self.ring = CryptedFileKeyring()
|
||||||
else:
|
else:
|
||||||
self.ring = UncryptedFileKeyring()
|
self.ring = UncryptedFileKeyring()
|
||||||
self.ring.file_path = path
|
self.ring.file_path = path
|
||||||
@ -67,7 +54,7 @@ class KeyringProxy(object):
|
|||||||
if self.random_on_empty and len(pw_val) == 0:
|
if self.random_on_empty and len(pw_val) == 0:
|
||||||
pw_val = RandomPassword().get_password(name, RAND_PW_LEN)
|
pw_val = RandomPassword().get_password(name, RAND_PW_LEN)
|
||||||
return (False, pw_val)
|
return (False, pw_val)
|
||||||
|
|
||||||
def save(self, name, password):
|
def save(self, name, password):
|
||||||
self.ring.set_password(name, PW_USER, password)
|
self.ring.set_password(name, PW_USER, password)
|
||||||
|
|
||||||
@ -89,8 +76,8 @@ class InputPassword(object):
|
|||||||
def _prompt_user(self, prompt_text):
|
def _prompt_user(self, prompt_text):
|
||||||
prompt_text = prompt_text.strip()
|
prompt_text = prompt_text.strip()
|
||||||
message = ("Enter a secret to use for the %s "
|
message = ("Enter a secret to use for the %s "
|
||||||
"[or press enter to get a generated one]: " % prompt_text
|
"[or press enter to get a generated one]: ")
|
||||||
)
|
message = message % (prompt_text)
|
||||||
rc = ""
|
rc = ""
|
||||||
while True:
|
while True:
|
||||||
rc = getpass.getpass(message)
|
rc = getpass.getpass(message)
|
||||||
|
@ -40,7 +40,6 @@ def _pformat_list(lst, item_max_len):
|
|||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _pformat_hash(hsh, item_max_len):
|
def _pformat_hash(hsh, item_max_len):
|
||||||
lines = []
|
lines = []
|
||||||
if not hsh:
|
if not hsh:
|
||||||
@ -80,7 +79,7 @@ def _pformat_escape(item, item_max_len):
|
|||||||
|
|
||||||
def _pformat_simple(item, item_max_len):
|
def _pformat_simple(item, item_max_len):
|
||||||
if item_max_len is None or item_max_len < 0:
|
if item_max_len is None or item_max_len < 0:
|
||||||
return "%s" % (item)
|
return "%s" % (item)
|
||||||
if item_max_len == 0:
|
if item_max_len == 0:
|
||||||
return ''
|
return ''
|
||||||
item_str = "%s" % (item)
|
item_str = "%s" % (item)
|
||||||
|
@ -23,4 +23,3 @@ COMPONENT_CONF_DIR = os.path.join(CONFIG_DIR, "components")
|
|||||||
DISTRO_DIR = os.path.join(CONFIG_DIR, "distros")
|
DISTRO_DIR = os.path.join(CONFIG_DIR, "distros")
|
||||||
PERSONA_DIR = os.path.join(CONFIG_DIR, "personas")
|
PERSONA_DIR = os.path.join(CONFIG_DIR, "personas")
|
||||||
TEMPLATE_DIR = os.path.join(CONFIG_DIR, "templates")
|
TEMPLATE_DIR = os.path.join(CONFIG_DIR, "templates")
|
||||||
|
|
||||||
|
@ -516,9 +516,9 @@ def mkdir(path, recurse=True, adjust_suids=False):
|
|||||||
if not is_dry_run():
|
if not is_dry_run():
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
if adjust_suids:
|
if adjust_suids:
|
||||||
(uid, gid) = get_suids()
|
(uid, gid) = get_suids()
|
||||||
if uid is not None and gid is not None:
|
if uid is not None and gid is not None:
|
||||||
chown_r(path, uid, gid)
|
chown_r(path, uid, gid)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ def make_bool(val):
|
|||||||
if isinstance(val, bool):
|
if isinstance(val, bool):
|
||||||
return val
|
return val
|
||||||
if isinstance(val, types.NoneType):
|
if isinstance(val, types.NoneType):
|
||||||
return False
|
return False
|
||||||
sval = str(val).lower().strip()
|
sval = str(val).lower().strip()
|
||||||
if sval in ['true', '1', 'on', 'yes', 't']:
|
if sval in ['true', '1', 'on', 'yes', 't']:
|
||||||
return True
|
return True
|
||||||
|
@ -483,10 +483,10 @@ ____ ___ ____ _ _ ____ ___ ____ ____ _ _
|
|||||||
return random.choice(possibles).strip("\n\r")
|
return random.choice(possibles).strip("\n\r")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _welcome_slang():
|
def _welcome_slang():
|
||||||
potentials = list()
|
potentials = [
|
||||||
potentials.append("And now for something completely different!")
|
"And now for something completely different!",
|
||||||
|
]
|
||||||
return random.choice(potentials)
|
return random.choice(potentials)
|
||||||
|
|
||||||
|
|
||||||
|
17
run_tests.sh
17
run_tests.sh
@ -31,20 +31,23 @@ function find_code {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function run_pep8 {
|
function run_pep8 {
|
||||||
echo "Running pep8 ..."
|
echo "+ Running pep8 ..."
|
||||||
files=$(find_code)
|
files=$(find_code)
|
||||||
ignores="E202,E501"
|
ignores="E202,E501,E128,E127,E126,E125,E124,E123,E121"
|
||||||
output_filename="pep8.log"
|
output_filename="pep8.log"
|
||||||
opts="--ignore=$ignores --repeat"
|
opts="--ignore=$ignores --repeat"
|
||||||
pep8 ${opts} ${files} 2>&1 > $output_filename
|
pep8 ${opts} ${files} 2>&1 > $output_filename
|
||||||
|
# Exit code is always 1 if any error or warning is found.
|
||||||
if [ "$?" -ne "0" ]; then
|
if [ "$?" -ne "0" ]; then
|
||||||
echo "Some badness was found!"
|
echo "Some badness was found!"
|
||||||
|
echo "Check '$output_filename' for a full report."
|
||||||
|
else
|
||||||
|
echo "You are a pep8 guru!"
|
||||||
fi
|
fi
|
||||||
echo "Check '$output_filename' for a full report."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_pylint {
|
function run_pylint {
|
||||||
echo "Running pylint ..."
|
echo "+ Running pylint ..."
|
||||||
opts="--rcfile=pylintrc --output-format=parseable"
|
opts="--rcfile=pylintrc --output-format=parseable"
|
||||||
files=$(find_code)
|
files=$(find_code)
|
||||||
output_filename="pylint.log"
|
output_filename="pylint.log"
|
||||||
@ -65,20 +68,20 @@ function run_pylint {
|
|||||||
else
|
else
|
||||||
echo "You are not yet a code master."
|
echo "You are not yet a code master."
|
||||||
grep -i "Your code" $output_filename
|
grep -i "Your code" $output_filename
|
||||||
|
echo "Check '$output_filename' for a full report."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
echo "Check '$output_filename' for a full report."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_tests {
|
function run_tests {
|
||||||
echo "Running tests ..."
|
echo "+ Running tests ..."
|
||||||
# Cleanup *.pyc
|
# Cleanup *.pyc
|
||||||
find . -type f -name "*.pyc" -delete
|
find . -type f -name "*.pyc" -delete
|
||||||
$NOSETESTS
|
$NOSETESTS
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate_yaml {
|
function validate_yaml {
|
||||||
echo "Validating YAML files..."
|
echo "+ Validating YAML files..."
|
||||||
for f in `find conf/ -name *.yaml -type f`; do
|
for f in `find conf/ -name *.yaml -type f`; do
|
||||||
echo "Checking yaml file: $f"
|
echo "Checking yaml file: $f"
|
||||||
python tools/validate-yaml.py $f
|
python tools/validate-yaml.py $f
|
||||||
|
Loading…
Reference in New Issue
Block a user