Modify the controlfiles pathway to no longer use
build and board as seperate entities.
The build is in fact the board/build-info.
Remove controlfile and download from the CherryPy config.
request.process_request_body has to do with storing requests with
rfile in memory or not. Neither of these pathways utilize this.
Add a bit more error handling with a pointer to coming up with a more
reasonable solution. Please keep discussions regarding that on bug:
crosbug.com/25040
TEST=Ran local tests
BUG=None
Change-Id: Ib8e9244c4865daae356e97da6412c7972239b184
Reviewed-on: https://gerrit.chromium.org/gerrit/14159
Reviewed-by: Chris Masone <[email protected]>
Commit-Ready: Scott Zawalski <[email protected]>
Reviewed-by: Scott Zawalski <[email protected]>
Tested-by: Scott Zawalski <[email protected]>
diff --git a/devserver.py b/devserver.py
index ef32d4b..4e304ec 100755
--- a/devserver.py
+++ b/devserver.py
@@ -79,16 +79,6 @@
{
'response.timeout': 100000,
},
- '/download':
- {
- # Gets rid of cherrypy parsing post file for args.
- 'request.process_request_body': False,
- },
- '/controlfile':
- {
- # Gets rid of cherrypy parsing post file for args.
- 'request.process_request_body': False,
- },
'/update':
{
# Gets rid of cherrypy parsing post file for args.
@@ -212,18 +202,17 @@
return self._downloader.Download(kwargs['archive_url'])
@cherrypy.expose
- def controlfiles(self, **params): # board, build, control_path=None):
+ def controlfiles(self, **params):
"""Return a control file or a list of all known control files.
Example URL:
To List all control files:
- http://dev-server/controlfiles/?board=x86-alex-release&build=R18-1514.0.0
+ http://dev-server/controlfiles?board=x86-alex-release&build=R18-1514.0.0
To return the contents of a path:
- http://dev-server/controlfiles/?board=x86-alex-release&build=R18-1514.0.0&control_path=client/sleeptest/control
+ http://dev-server/controlfiles?board=x86-alex-release&build=R18-1514.0.0&control_path=client/sleeptest/control
Args:
- board: The board i.e. x86-alex-release.
- build: The build i.e. R18-1514.0.0-a1-b1450.
+ build: The build i.e. x86-alex-release/R18-1514.0.0-a1-b1450.
control_path: If you want the contents of a control file set this
to the path. E.g. client/site_tests/sleeptest/control
Optional, if not provided return a list of control files is returned.
@@ -235,18 +224,16 @@
if not params:
return _PrintDocStringAsHTML(self.controlfiles)
- if ('board' not in params or
- 'build' not in params):
- errmsg = 'Error: board and build are required!'
+ if 'build' not in params:
+ errmsg = 'Error: build is required!'
raise cherrypy.HTTPError('500 Internal Server Error',
- 'Error: board= and build= params are required!')
+ 'Error: build= is required!')
if 'control_path' not in params:
return devserver_util.GetControlFileList(updater.static_dir,
- params['board'], params['build'])
+ params['build'])
else:
- return devserver_util.GetControlFile(updater.static_dir, params['board'],
- params['build'],
+ return devserver_util.GetControlFile(updater.static_dir, params['build'],
params['control_path'])
@cherrypy.expose
diff --git a/devserver_util.py b/devserver_util.py
index a8cfb65..4c41571 100644
--- a/devserver_util.py
+++ b/devserver_util.py
@@ -387,12 +387,12 @@
return dev_build_dir
-def GetControlFile(static_dir, board, build, control_path):
+
+def GetControlFile(static_dir, build, control_path):
"""Attempts to pull the requested control file from the Dev Server.
Args:
static_dir: Directory where builds are served from.
- board: Fully qualified board name; e.g. x86-generic-release.
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.
@@ -402,21 +402,25 @@
Returns:
Content of the requested control file.
"""
- control_path = os.path.join(static_dir, board, build, 'autotest',
+ control_path = os.path.join(static_dir, build, 'autotest',
control_path)
if not SafeSandboxAccess(static_dir, control_path):
raise DevServerUtilError('Invaid control file "%s".' % control_path)
+ if not os.path.exists(control_path):
+ # TODO(scottz): Come up with some sort of error mechanism.
+ # crosbug.com/25040
+ return 'Unknown control path %s' % control_path
+
with open(control_path, 'r') as control_file:
return control_file.read()
-def GetControlFileList(static_dir, board, build):
+def GetControlFileList(static_dir, build):
"""List all control|control. files in the specified board/build path.
Args:
static_dir: Directory where builds are served from.
- board: Fully qualified board name; e.g. x86-generic-release.
build: Fully qualified build string; e.g. R17-1234.0.0-a1-b983.
Raises:
@@ -425,13 +429,16 @@
Returns:
String of each file separated by a newline.
"""
- autotest_dir = os.path.join(static_dir, board, build, 'autotest')
+ autotest_dir = os.path.join(static_dir, build, 'autotest')
if not SafeSandboxAccess(static_dir, autotest_dir):
raise DevServerUtilError('Autotest dir not in sandbox "%s".' % autotest_dir)
control_files = set()
- control_paths = ['testsuite', 'server/tests', 'server/site_tests',
- 'client/tests', 'client/site_tests']
+ if not os.path.exists(autotest_dir):
+ # TODO(scottz): Come up with some sort of error mechanism.
+ # crosbug.com/25040
+ return 'Unknown build path %s' % autotest_dir
+
for entry in os.walk(autotest_dir):
dir_path, _, files = entry
for file_entry in files: