Devserver: fix pylint errors in common_util.py.
BUG=chromium:344939
TEST=Unittests + pylint.
Change-Id: Ic798e58f258019aea563e30e39012db97a4728b4
Reviewed-on: https://chromium-review.googlesource.com/193992
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Queue: Chris Sosa <sosa@chromium.org>
Tested-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py
index ba4ba8f..58c83fa 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -678,9 +678,9 @@
400, 'hardware_class is required in Omaha Request')
track = app.getAttribute('track')
- if not track or not track.endswith('-channel'):
+ if not (track and track.endswith('-channel')):
raise common_util.DevServerHTTPError(
- 400, 'Omaha requests need an update channel')
+ 400, 'Omaha requests need a valid update channel')
def _GetStaticUrl(self):
"""Returns the static url base that should prefix all payload responses."""
diff --git a/common_util.py b/common_util.py
index f60014c..eae7411 100644
--- a/common_util.py
+++ b/common_util.py
@@ -38,9 +38,9 @@
def __init__(self, status, message):
"""CherryPy error with logging.
- Args:
- status: HTTPResponse status.
- message: Message associated with the response.
+ Args:
+ status: HTTPResponse status.
+ message: Message associated with the response.
"""
cherrypy.HTTPError.__init__(self, status, message)
_Log('HTTPError status: %s message: %s', status, message)
@@ -117,11 +117,11 @@
build: Fully qualified build string; e.g. R17-1234.0.0-a1-b983.
control_path: Path to control file on Dev Server relative to Autotest root.
- Raises:
- CommonUtilError: If lock can't be acquired.
-
Returns:
Content of the requested control file.
+
+ Raises:
+ CommonUtilError: If lock can't be acquired.
"""
# Be forgiving if the user passes in the control_path with a leading /
control_path = control_path.lstrip('/')
@@ -151,12 +151,12 @@
build: Fully qualified build string; e.g. R17-1234.0.0-a1-b983.
suite_name: Name of the suite for which we require control files.
+ Returns:
+ String of each control file separated by a newline.
+
Raises:
CommonUtilError: If the suite_to_control_file_map isn't found in
the specified build's staged directory.
-
- Returns:
- String of each control file separated by a newline.
"""
suite_to_control_map = os.path.join(static_dir, build,
'autotest', 'test_suites',
@@ -184,11 +184,11 @@
static_dir: Directory where builds are served from.
build: Fully qualified build string; e.g. R17-1234.0.0-a1-b983.
- Raises:
- CommonUtilError: If path is outside of sandbox.
-
Returns:
String of each file separated by a newline.
+
+ Raises:
+ CommonUtilError: If path is outside of sandbox.
"""
autotest_dir = os.path.join(static_dir, build, 'autotest/')
if not PathInDir(static_dir, autotest_dir):
@@ -222,9 +222,10 @@
Args:
file_path: path to file to be hashed
- do_sha1: whether or not to compute a SHA1 hash
+ do_sha1: whether or not to compute a SHA1 hash
do_sha256: whether or not to compute a SHA256 hash
- do_md5: whether or not to compute a MD5 hash
+ do_md5: whether or not to compute a MD5 hash
+
Returns:
A dictionary containing binary hash values, keyed by 'sha1', 'sha256' and
'md5', respectively.
@@ -347,8 +348,9 @@
install_path: Path to extract the tarball to.
files_to_extract: String of specific files in the tarball to extract.
excluded_files: String of files to not extract.
- return_extracted_file: Whether or not the caller expects the list of
+ return_extracted_files: whether or not the caller expects the list of
files extracted; if False, returns an empty list.
+
Returns:
List of absolute paths of the files extracted (possibly empty).
"""
diff --git a/devserver.py b/devserver.py
index 7caaadc..97cbded 100755
--- a/devserver.py
+++ b/devserver.py
@@ -990,7 +990,7 @@
'this setting enabled, this devserver instance serves as '
'just an Omaha server instance. In this mode, the '
'devserver enforces a few extra components of the Omaha '
- 'protocol e.g. hardware class being sent etc.')
+ 'protocol, such as hardware class, being sent.')
group.add_option('-u', '--urlbase',
metavar='URL',
help='base URL for update images, other than the '