summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-05-10 12:47:06 +0000
committerGerrit Code Review <review@openstack.org>2013-05-10 12:47:06 +0000
commite78d45735e31a77d566317e28e6c0ea068fcb3cf (patch)
tree69532f86ecbb55070413246d08cbc861f0d6daf8 /openstack
parentf36c7c966cd66f4c6a534fedc6da096296fc4f7a (diff)
parent562cc6844d3dc5cbd35ad404307224959900df30 (diff)
downloadoslo-e78d45735e31a77d566317e28e6c0ea068fcb3cf.tar.gz
oslo-e78d45735e31a77d566317e28e6c0ea068fcb3cf.tar.xz
oslo-e78d45735e31a77d566317e28e6c0ea068fcb3cf.zip
Merge "Stylistic improvements from quantum-rootwrap"
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/rootwrap/filters.py20
-rw-r--r--openstack/common/rootwrap/wrapper.py8
2 files changed, 13 insertions, 15 deletions
diff --git a/openstack/common/rootwrap/filters.py b/openstack/common/rootwrap/filters.py
index d9618af..58121cb 100644
--- a/openstack/common/rootwrap/filters.py
+++ b/openstack/common/rootwrap/filters.py
@@ -20,7 +20,7 @@ import re
class CommandFilter(object):
- """Command filter only checking that the 1st argument matches exec_path"""
+ """Command filter only checking that the 1st argument matches exec_path."""
def __init__(self, exec_path, run_as, *args):
self.name = ''
@@ -30,7 +30,7 @@ class CommandFilter(object):
self.real_exec = None
def get_exec(self, exec_dirs=[]):
- """Returns existing executable, or empty string if none found"""
+ """Returns existing executable, or empty string if none found."""
if self.real_exec is not None:
return self.real_exec
self.real_exec = ""
@@ -46,10 +46,8 @@ class CommandFilter(object):
return self.real_exec
def match(self, userargs):
- """Only check that the first argument (command) matches exec_path"""
- if (os.path.basename(self.exec_path) == userargs[0]):
- return True
- return False
+ """Only check that the first argument (command) matches exec_path."""
+ return os.path.basename(self.exec_path) == userargs[0]
def get_command(self, userargs, exec_dirs=[]):
"""Returns command to execute (with sudo -u if run_as != root)."""
@@ -60,12 +58,12 @@ class CommandFilter(object):
return [to_exec] + userargs[1:]
def get_environment(self, userargs):
- """Returns specific environment to set, None if none"""
+ """Returns specific environment to set, None if none."""
return None
class RegExpFilter(CommandFilter):
- """Command filter doing regexp matching for every argument"""
+ """Command filter doing regexp matching for every argument."""
def match(self, userargs):
# Early skip if command or number of args don't match
@@ -135,7 +133,7 @@ class PathFilter(CommandFilter):
class DnsmasqFilter(CommandFilter):
- """Specific filter for the dnsmasq call (which includes env)"""
+ """Specific filter for the dnsmasq call (which includes env)."""
CONFIG_FILE_ARG = 'CONFIG_FILE'
@@ -160,7 +158,7 @@ class DnsmasqFilter(CommandFilter):
class DeprecatedDnsmasqFilter(DnsmasqFilter):
- """Variant of dnsmasq filter to support old-style FLAGFILE"""
+ """Variant of dnsmasq filter to support old-style FLAGFILE."""
CONFIG_FILE_ARG = 'FLAGFILE'
@@ -210,7 +208,7 @@ class KillFilter(CommandFilter):
class ReadFileFilter(CommandFilter):
- """Specific filter for the utils.read_file_as_root call"""
+ """Specific filter for the utils.read_file_as_root call."""
def __init__(self, file_path, *args):
self.file_path = file_path
diff --git a/openstack/common/rootwrap/wrapper.py b/openstack/common/rootwrap/wrapper.py
index e0ac9df..d488ddd 100644
--- a/openstack/common/rootwrap/wrapper.py
+++ b/openstack/common/rootwrap/wrapper.py
@@ -93,7 +93,7 @@ def setup_syslog(execname, facility, level):
def build_filter(class_name, *args):
- """Returns a filter object of class class_name"""
+ """Returns a filter object of class class_name."""
if not hasattr(filters, class_name):
logging.warning("Skipping unknown filter class (%s) specified "
"in filter definitions" % class_name)
@@ -103,7 +103,7 @@ def build_filter(class_name, *args):
def load_filters(filters_path):
- """Load filters from a list of directories"""
+ """Load filters from a list of directories."""
filterlist = []
for filterdir in filters_path:
if not os.path.isdir(filterdir):
@@ -121,7 +121,7 @@ def load_filters(filters_path):
return filterlist
-def match_filter(filters, userargs, exec_dirs=[]):
+def match_filter(filter_list, userargs, exec_dirs=[]):
"""
Checks user command and arguments through command filters and
returns the first matching filter.
@@ -131,7 +131,7 @@ def match_filter(filters, userargs, exec_dirs=[]):
"""
first_not_executable_filter = None
- for f in filters:
+ for f in filter_list:
if f.match(userargs):
# Try other filters if executable is absent
if not f.get_exec(exec_dirs=exec_dirs):