From adda6613d7fdf47967d5d55057044ac618d40d1a Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 30 Jan 2021 10:28:42 +0200 Subject: refactor: use Subplot's lib/files --- ewww.md | 9 ++++++++- subplot/ewww.py | 7 +++++++ subplot/ewww.yaml | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ewww.md b/ewww.md index 6352c02..d1c9faf 100644 --- a/ewww.md +++ b/ewww.md @@ -92,7 +92,8 @@ for static content only. Every other method returns an error. ~~~scenario given a self-signed certificate as snakeoil.pem, using key snakeoil.key -and file webroot/foo.html with "this is your web page" +and directory webroot +and file webroot/foo.html from webpage.html and a running server using config file smoke.yaml when I request GET https://example.com/foo.html then I get status code 200 @@ -110,6 +111,10 @@ tls_cert: snakeoil.pem tls_key: snakeoil.key ~~~ +~~~{#webpage.html .file add-newline=no} +this is your web page +~~~ + ## Performance test ~~~scenario-disabled @@ -147,11 +152,13 @@ template: python bindings: - subplot/ewww.yaml - subplot/vendored/daemon.yaml + - subplot/vendored/files.yaml - subplot/vendored/runcmd.yaml functions: - subplot/ewww.py - subplot/http.py - subplot/vendored/daemon.py + - subplot/vendored/files.py - subplot/vendored/runcmd.py classes: - scenario-disabled diff --git a/subplot/ewww.py b/subplot/ewww.py index d53b74c..6c93733 100644 --- a/subplot/ewww.py +++ b/subplot/ewww.py @@ -40,6 +40,13 @@ def fixme(*args, **kwargs): assert 0 +# Create a directory. +def create_directory(ctx, dirname=None): + dirname = "./" + dirname + if not os.path.exists(dirname): + os.makedirs(dirname) + + # Create a file. def create_file(ctx, filename=None, content=None): logging.debug(f"Creating file {filename} with {content}") diff --git a/subplot/ewww.yaml b/subplot/ewww.yaml index 375558d..ec5395f 100644 --- a/subplot/ewww.yaml +++ b/subplot/ewww.yaml @@ -8,6 +8,9 @@ - given: "{count} files in {dirname}" function: fixme +- given: directory {dirname} + function: create_directory + - given: file (?P\S+) with "(?P.*)" regex: true function: create_file -- cgit v1.2.1