# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/.
r"""Make it easy to serve updates for testing.
Serve a local file like:
```
$ ./mach update serve -v /path/to/update.mar
```
@Command("update", category="testing", description="Test the update cycle.") def update(command_context): pass
@SubCommand("update", "serve", description="Serve updates.")
@CommandArgument("-v", "--verbose", action="store_true", help="Verbose output.")
@CommandArgument( "--port", type=int, default=8000, help="Port to run server on (default=8000)"
)
@CommandArgument( "--host",
default="localhost",
help='Host address to run server on (default="localhost")',
)
@CommandArgument( "-p", "--policies",
dest="policiesPath",
default=None,
help="Write policies JSON to the given path (default=policies JSON dumped to stdout)",
)
@CommandArgument( "--buildID",
default="22221010555555",
help="Build ID to advertise (default=22221010555555, the far future)",
)
@CommandArgument( "--update-type",
choices=("major", "minor"),
default="major",
help='Type of update patch to serve (default="major")',
)
@CommandArgument( "--patch-type",
choices=("complete", "partial"),
default="complete",
help='Type of update patch to serve (default="complete")',
)
@CommandArgument( "mar",
help="URL or path to MAR file to serve",
) def serve(
command_context,
mar,
verbose=False,
port=8000,
host="localhost",
policiesPath=None,
buildID="22221010555555",
update_type="major",
patch_type="complete",
):
command_context._set_log_level(verbose)
log = command_context.log
mar_size = None
url = None try:
url = urlparse(mar) except ValueError: pass if url and url.scheme in ("http", "https"): with requests.get(mar, stream=True) as req:
mar_size = req.headers["Content-Length"] else:
url = None
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.