Pylint and pep8 cleanup
This commit is contained in:
parent
c9e9791d8a
commit
77a036c6c8
@ -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,
|
||||||
|
@ -61,6 +61,8 @@ 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,6 +73,7 @@ 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)
|
||||||
@ -80,6 +83,7 @@ def make_packager(package, default_class, **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)
|
||||||
@ -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 ''
|
||||||
|
@ -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)
|
||||||
@ -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())
|
||||||
|
@ -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')
|
||||||
|
@ -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)
|
||||||
|
@ -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__)
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,7 +205,8 @@ class PythonPackager(DependencyPackager):
|
|||||||
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
|
||||||
@ -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:
|
||||||
|
@ -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")
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
19
run_tests.sh
19
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!"
|
||||||
fi
|
|
||||||
echo "Check '$output_filename' for a full report."
|
echo "Check '$output_filename' for a full report."
|
||||||
|
else
|
||||||
|
echo "You are a pep8 guru!"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "Check '$output_filename' for a full report."
|
echo "Check '$output_filename' for a full report."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
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