From c9845da229d93e1ad46fce47b3f0fc68e0bc7c60 Mon Sep 17 00:00:00 2001 From: Joe Ethier Date: Tue, 23 Aug 2016 14:33:27 -0700 Subject: [PATCH] Revise package structure as discussed in issue #314. (#411) --- CONTRIBUTING.md | 90 ++++++----- {openhtf/bin => bin}/units_from_xls.py | 4 +- {openhtf/io => contrib/plugs}/__init__.py | 0 contrib/poll_stations.py | 2 +- examples/all_the_things.py | 60 ++++--- examples/example_plug.py | 2 +- examples/hello_world.py | 18 +-- examples/measurements.py | 32 ++-- openhtf/__init__.py | 24 +-- openhtf/{exe => core}/__init__.py | 9 +- openhtf/{ => core}/history.py | 2 +- openhtf/{util => core}/measurements.py | 0 openhtf/{util => core}/monitors.py | 2 +- openhtf/{exe => core}/phase_executor.py | 0 openhtf/{io => core}/station_api.py | 6 +- openhtf/{io => core}/test_record.py | 0 openhtf/{exe => core}/test_state.py | 6 +- openhtf/{exe => core}/triggers.py | 2 +- openhtf/io/http_api.py | 147 ------------------ openhtf/names.py | 63 -------- openhtf/{io/proto => output}/__init__.py | 0 .../output => output/callbacks}/__init__.py | 1 + .../callbacks}/console_summary.py | 6 +- .../callbacks}/json_factory.py | 9 +- .../callbacks}/mfg_inspector.py | 18 +-- openhtf/output/proto/__init__.py | 0 openhtf/{io => output}/proto/guzzle.proto | 0 openhtf/{io => output}/proto/test_runs.proto | 0 openhtf/{io => output}/proto/units.proto | 0 .../frontend => output/web_gui}/.gitignore | 0 .../frontend => output/web_gui}/__init__.py | 7 +- .../frontend => output/web_gui}/__main__.py | 20 +-- ...ular-012cf6a10129e2275d79d6adac7f3b02.woff | Bin ...lar-570eb83859dc23dd0eec423a49e147fe.woff2 | Bin ...gular-a37b0c01c0baf1888ca812cc0508f6e2.ttf | Bin ...gular-e79bfd88537def476913f3ed52f4f4b3.eot | Bin ...old-39b2c3031be6b4ea96e2e3e95d307814.woff2 | Bin ...Bold-dc81817def276b4f21395f7ea5e88dcd.woff | Bin ...-Bold-e31fcf1885e371e19f5786c2bdfeae1b.ttf | Bin ...ight-3b813c2ae0d04909a33a18d792912ee7.woff | Bin ...Light-46e48ce0628835f68a7369d0254e4283.ttf | Bin ...ght-69f8a0617ac472f78e45841323a3df9e.woff2 | Bin ...ium-574fd0b50367f886d359e8264938fc37.woff2 | Bin ...edium-894a2ede85a483bf9bedefd4db45cdb9.ttf | Bin ...dium-fc78759e93a6cac50458610e3d9d63a0.woff | Bin ...lar-2751ee43015f9884c3642f103b7f70c9.woff2 | Bin ...ular-ba3dcd8903e3d0af5de7792777f8ae0d.woff | Bin ...gular-df7b648ce5356ea1ebce435b3459fd60.ttf | Bin ...Thin-7500519de3d82e33d1587f8042e2afcb.woff | Bin ...-Thin-94998475f6aea65f558494802416c1cf.ttf | Bin ...hin-954bbdeb86483e4ffea00c4591530ece.woff2 | Bin .../web_gui}/prebuilt/index.html | 0 .../web_gui}/prebuilt/scripts/app.bundle.js | 0 .../prebuilt/scripts/app.bundle.js.map | 0 .../prebuilt/scripts/vendor.bundle.js | 0 .../prebuilt/scripts/vendor.bundle.js.map | 0 .../web_gui}/prebuilt/styles.css | 0 .../web_gui}/prebuilt/styles/dashboard.css | 0 .../prebuilt/styles/dashboard.stationcard.css | 0 .../web_gui}/prebuilt/styles/prompt.css | 0 .../web_gui}/prebuilt/styles/station.css | 0 .../prebuilt/styles/station.header.css | 0 .../web_gui}/prebuilt/styles/station.logs.css | 0 .../prebuilt/styles/station.metadata.css | 0 .../prebuilt/styles/station.phases.css | 0 .../prebuilt/styles/station.prompt.css | 0 .../prebuilt/styles/station.testheader.css | 0 .../web_gui}/prebuilt/styles/test.css | 0 .../web_gui}/prebuilt/styles/test.header.css | 0 .../web_gui}/prebuilt/styles/test.logs.css | 0 .../web_gui}/prebuilt/styles/test.phases.css | 0 .../web_gui}/prebuilt/templates/prompt.html | 0 .../prebuilt/templates/station.header.html | 0 .../web_gui/prebuilt/templates}/station.html | 0 .../prebuilt/templates}/station.phases.html | 0 .../prebuilt/templates/station.prompt.html | 0 .../templates/station.testheader.html | 0 .../prebuilt/templates/test.header.html | 0 .../web_gui}/prebuilt/templates/test.html | 0 .../prebuilt/templates/test.phases.html | 0 .../frontend => output/web_gui}/src/.bowerrc | 0 .../web_gui}/src/app/dashboard.css | 0 .../web_gui}/src/app/dashboard.service.ts | 0 .../web_gui}/src/app/dashboard.ts | 0 .../web_gui}/src/app/index.html | 0 .../web_gui}/src/app/main.ts | 0 .../web_gui}/src/app/station.css | 0 .../web_gui}/src/app/station.header.css | 0 .../web_gui}/src/app/station.header.html | 0 .../web_gui}/src/app/station.header.ts | 0 .../web_gui/src/app}/station.html | 0 .../web_gui}/src/app/station.logs.css | 0 .../web_gui}/src/app/station.logs.ts | 0 .../web_gui}/src/app/station.metadata.css | 0 .../web_gui}/src/app/station.metadata.ts | 0 .../web_gui}/src/app/station.phases.css | 0 .../web_gui/src/app}/station.phases.html | 0 .../web_gui}/src/app/station.phases.ts | 0 .../web_gui}/src/app/station.prompt.css | 0 .../web_gui}/src/app/station.prompt.html | 0 .../web_gui}/src/app/station.prompt.ts | 0 .../web_gui}/src/app/station.service.ts | 0 .../web_gui}/src/app/station.testheader.css | 0 .../web_gui}/src/app/station.testheader.html | 0 .../web_gui}/src/app/station.testheader.ts | 0 .../web_gui}/src/app/station.ts | 0 .../web_gui}/src/app/styles.css | 0 .../web_gui}/src/app/utils.ts | 0 .../web_gui}/src/app/vendor.ts | 0 .../src/other_modules/get_other_modules.py | 0 .../web_gui}/src/package.json | 0 .../web_gui}/src/tsconfig.json | 0 .../web_gui}/src/typings.json | 0 .../web_gui}/src/webpack.config.js | 0 openhtf/plugs/__init__.py | 4 +- openhtf/plugs/usb/__init__.py | 2 +- openhtf/{ => util}/conf.py | 24 ++- openhtf/util/test.py | 12 +- openhtf/{io => util}/user_input.py | 0 setup.py | 6 +- test/{exe => core}/exe_test.py | 8 +- .../{util => core}/measurements_record.pickle | Bin 5814 -> 5923 bytes test/{util => core}/measurements_test.py | 36 ++--- test/{util => core}/monitors_test.py | 2 +- .../callbacks/callbacks_test.py} | 6 +- .../output => output/callbacks}/record.json | 52 +++---- .../output => output/callbacks}/record.pickle | 74 ++++----- .../callbacks}/record.testrun | Bin 16463 -> 16684 bytes test/{ => util}/bad_config.txt | 0 test/{ => util}/bad_config.yaml | 0 test/{ => util}/conf_test.py | 6 +- test/{ => util}/test_config.yaml | 0 test/util/test_test.py | 2 +- 133 files changed, 295 insertions(+), 469 deletions(-) rename {openhtf/bin => bin}/units_from_xls.py (99%) rename {openhtf/io => contrib/plugs}/__init__.py (100%) rename openhtf/{exe => core}/__init__.py (97%) rename openhtf/{ => core}/history.py (99%) rename openhtf/{util => core}/measurements.py (100%) rename openhtf/{util => core}/monitors.py (99%) rename openhtf/{exe => core}/phase_executor.py (100%) rename openhtf/{io => core}/station_api.py (99%) rename openhtf/{io => core}/test_record.py (100%) rename openhtf/{exe => core}/test_state.py (99%) rename openhtf/{exe => core}/triggers.py (97%) delete mode 100644 openhtf/io/http_api.py delete mode 100644 openhtf/names.py rename openhtf/{io/proto => output}/__init__.py (100%) rename openhtf/{io/output => output/callbacks}/__init__.py (99%) rename openhtf/{io/output => output/callbacks}/console_summary.py (94%) rename openhtf/{io/output => output/callbacks}/json_factory.py (92%) rename openhtf/{io/output => output/callbacks}/mfg_inspector.py (98%) create mode 100644 openhtf/output/proto/__init__.py rename openhtf/{io => output}/proto/guzzle.proto (100%) rename openhtf/{io => output}/proto/test_runs.proto (100%) rename openhtf/{io => output}/proto/units.proto (100%) rename openhtf/{io/frontend => output/web_gui}/.gitignore (100%) rename openhtf/{io/frontend => output/web_gui}/__init__.py (98%) rename openhtf/{io/frontend => output/web_gui}/__main__.py (74%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/MaterialIcons-Regular-012cf6a10129e2275d79d6adac7f3b02.woff (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/MaterialIcons-Regular-570eb83859dc23dd0eec423a49e147fe.woff2 (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/MaterialIcons-Regular-a37b0c01c0baf1888ca812cc0508f6e2.ttf (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/MaterialIcons-Regular-e79bfd88537def476913f3ed52f4f4b3.eot (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Bold-39b2c3031be6b4ea96e2e3e95d307814.woff2 (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Bold-dc81817def276b4f21395f7ea5e88dcd.woff (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Bold-e31fcf1885e371e19f5786c2bdfeae1b.ttf (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Light-3b813c2ae0d04909a33a18d792912ee7.woff (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Light-46e48ce0628835f68a7369d0254e4283.ttf (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Light-69f8a0617ac472f78e45841323a3df9e.woff2 (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Medium-574fd0b50367f886d359e8264938fc37.woff2 (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Medium-894a2ede85a483bf9bedefd4db45cdb9.ttf (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Medium-fc78759e93a6cac50458610e3d9d63a0.woff (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Regular-2751ee43015f9884c3642f103b7f70c9.woff2 (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Regular-ba3dcd8903e3d0af5de7792777f8ae0d.woff (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Regular-df7b648ce5356ea1ebce435b3459fd60.ttf (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Thin-7500519de3d82e33d1587f8042e2afcb.woff (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Thin-94998475f6aea65f558494802416c1cf.ttf (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/fonts/Roboto-Thin-954bbdeb86483e4ffea00c4591530ece.woff2 (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/index.html (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/scripts/app.bundle.js (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/scripts/app.bundle.js.map (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/scripts/vendor.bundle.js (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/scripts/vendor.bundle.js.map (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/dashboard.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/dashboard.stationcard.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/prompt.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/station.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/station.header.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/station.logs.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/station.metadata.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/station.phases.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/station.prompt.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/station.testheader.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/test.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/test.header.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/test.logs.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/styles/test.phases.css (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/templates/prompt.html (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/templates/station.header.html (100%) rename openhtf/{io/frontend/src/app => output/web_gui/prebuilt/templates}/station.html (100%) rename openhtf/{io/frontend/src/app => output/web_gui/prebuilt/templates}/station.phases.html (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/templates/station.prompt.html (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/templates/station.testheader.html (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/templates/test.header.html (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/templates/test.html (100%) rename openhtf/{io/frontend => output/web_gui}/prebuilt/templates/test.phases.html (100%) rename openhtf/{io/frontend => output/web_gui}/src/.bowerrc (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/dashboard.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/dashboard.service.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/dashboard.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/index.html (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/main.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.header.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.header.html (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.header.ts (100%) rename openhtf/{io/frontend/prebuilt/templates => output/web_gui/src/app}/station.html (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.logs.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.logs.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.metadata.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.metadata.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.phases.css (100%) rename openhtf/{io/frontend/prebuilt/templates => output/web_gui/src/app}/station.phases.html (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.phases.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.prompt.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.prompt.html (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.prompt.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.service.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.testheader.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.testheader.html (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.testheader.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/station.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/styles.css (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/utils.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/app/vendor.ts (100%) rename openhtf/{io/frontend => output/web_gui}/src/other_modules/get_other_modules.py (100%) rename openhtf/{io/frontend => output/web_gui}/src/package.json (100%) rename openhtf/{io/frontend => output/web_gui}/src/tsconfig.json (100%) rename openhtf/{io/frontend => output/web_gui}/src/typings.json (100%) rename openhtf/{io/frontend => output/web_gui}/src/webpack.config.js (100%) rename openhtf/{ => util}/conf.py (98%) rename openhtf/{io => util}/user_input.py (100%) rename test/{exe => core}/exe_test.py (91%) rename test/{util => core}/measurements_record.pickle (55%) rename test/{util => core}/measurements_test.py (74%) rename test/{util => core}/monitors_test.py (98%) rename test/{io/output/output_test.py => output/callbacks/callbacks_test.py} (95%) rename test/{io/output => output/callbacks}/record.json (68%) rename test/{io/output => output/callbacks}/record.pickle (68%) rename test/{io/output => output/callbacks}/record.testrun (67%) rename test/{ => util}/bad_config.txt (100%) rename test/{ => util}/bad_config.yaml (100%) rename test/{ => util}/conf_test.py (97%) rename test/{ => util}/test_config.yaml (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c5a381a51..495debcc9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -128,41 +128,61 @@ If you're adding a new module or feature, put some thought into where it best fits in based on what it does. ``` - .-----------------. - | openhtf | - |-----------------| - | Python package. | - '-----------------' - | - | .---------------------------------. - | | conf | - |--->|---------------------------------| - | | Reads and stores configuration. | - | '---------------------------------' - | - | .-------------------------. - | | exe | - |--->|-------------------------| - | | Manages test execution. | - | '-------------------------' - | - | .----------------------------------------. - | | io | - |--->|----------------------------------------| - | | Manages UI, logging, and test records. | - | '----------------------------------------' - | - | .---------------------------------------------------. - | | plugs | - |--->|---------------------------------------------------| - | | Extensions for interfacing with various hardware. | - | '---------------------------------------------------' - | - | .-----------------------------------. - | | util | - '--->|-----------------------------------| - | Utility functions and misc tools. | - '-----------------------------------' + openhtf + | + | Repository root directory. + | + | + |-> bin + | + | Standalone tools and scripts to help manage the codebase. + | + | + |-> contrib + | + | Standalone scripts that use the OpenHTF package. Nothing in the + | OpenHTF package should depend on these. + | + | + |-> examples + | + | Example OpenHTF tests and plugs. + | + | + |-> openhtf + | | + | | The OpenHTF Python package. + | | + | |-> core + | | + | | Framework internals that manage test state and execution. + | | The contents of this submodule shouldn't normally need to be + | | accessed from outside the package. + | | + | | + | |-> output + | | + | | Manages the framework's output, including UI, logging, and test + | | records. + | | + | | + | |-> plugs + | | + | | Extensions for interfacing with various hardware, such as test + | | equipment and DUT's. + | | + | | + | '-> util + | + | Generic utility functions and miscellaneous tools. + | The contents of this submodule should be general enough to be + | useable outside of OpenHTF, meaning it should not be dependent + | on other code in the OpenHTF package. + | + | + '-> test + + Unittest code. ``` diff --git a/openhtf/bin/units_from_xls.py b/bin/units_from_xls.py similarity index 99% rename from openhtf/bin/units_from_xls.py rename to bin/units_from_xls.py index 2f6ee66ec..c293b8ee1 100644 --- a/openhtf/bin/units_from_xls.py +++ b/bin/units_from_xls.py @@ -176,8 +176,8 @@ def main(): parser.add_argument( '--outfile', type=str, - default=os.path.join(os.path.dirname(__file__), os.path.pardir, 'util', - 'units.py'), + default=os.path.join(os.path.dirname(__file__), os.path.pardir, + 'openhtf','util', 'units.py'), help='where to put the generated .py file.') args = parser.parse_args() diff --git a/openhtf/io/__init__.py b/contrib/plugs/__init__.py similarity index 100% rename from openhtf/io/__init__.py rename to contrib/plugs/__init__.py diff --git a/contrib/poll_stations.py b/contrib/poll_stations.py index 10dec29f0..d46c272b2 100644 --- a/contrib/poll_stations.py +++ b/contrib/poll_stations.py @@ -39,7 +39,7 @@ import time -from openhtf.io import station_api +from openhtf.core import station_api from openhtf.util import threads diff --git a/examples/all_the_things.py b/examples/all_the_things.py index 2eaea9b1b..7b625c69a 100644 --- a/examples/all_the_things.py +++ b/examples/all_the_things.py @@ -22,36 +22,30 @@ import os import time -import example_plug -import openhtf - -from openhtf.io import output -from openhtf.io.output import json_factory -from openhtf.io.output import mfg_inspector -from openhtf.names import * -# Uncomment for mfg-inspector output, requires setup.py build_proto. -#from openhtf.io.output import mfg_inspector -from openhtf.plugs import user_input +import openhtf as htf from openhtf.util import units +from openhtf.util import user_input + +import example_plug -@plug(example=example_plug.ExamplePlug) +@htf.plug(example=example_plug.ExamplePlug) def example_monitor(example): time.sleep(.2) return example.increment() -@measures( - Measurement('unset_meas'), - Measurement( +@htf.measures( + htf.Measurement('unset_meas'), + htf.Measurement( 'widget_type').matches_regex(r'.*Widget$').doc( '''This measurement tracks the type of widgets.'''), - Measurement( + htf.Measurement( 'widget_color').doc('Color of the widget'), - Measurement('widget_size').in_range(1, 4)) -@plug(example=example_plug.ExamplePlug) -@plug(prompts=user_input.UserInput) -def hello_world(test, example, prompts): + htf.Measurement('widget_size').in_range(1, 4)) +@htf.plug(example=example_plug.ExamplePlug) +@htf.plug(prompts=user_input.UserInput) +def hello_world(test, example): """A hello world test phase.""" test.logger.info('Hello World!') test.measurements.widget_type = prompts.prompt( @@ -64,11 +58,11 @@ def hello_world(test, example, prompts): # Timeout if this phase takes longer than 10 seconds. -@TestPhase(timeout_s=10) -@measures( - *(Measurement( +@htf.TestPhase(timeout_s=10) +@htf.measures( + *(htf.Measurement( 'level_%s' % i) for i in ['none', 'some', 'all'])) -@monitors('monitor_measurement', example_monitor) +@htf.monitors('monitor_measurement', example_monitor) def set_measurements(test): """Test phase that sets a measurement.""" test.measurements.level_none = 0 @@ -79,10 +73,10 @@ def set_measurements(test): time.sleep(1) -@measures( - Measurement('unset_dims').with_dimensions(units.HERTZ), - Measurement('dimensions').with_dimensions(units.HERTZ), - Measurement('lots_of_dims').with_dimensions( +@htf.measures( + htf.Measurement('unset_dims').with_dimensions(units.HERTZ), + htf.Measurement('dimensions').with_dimensions(units.HERTZ), + htf.Measurement('lots_of_dims').with_dimensions( units.HERTZ, units.SECOND, units.RADIAN)) def dimensions(test): for dim in range(5): @@ -100,19 +94,23 @@ def teardown(test): if __name__ == '__main__': - test = openhtf.Test(hello_world, set_measurements, dimensions, attachments, + test = htf.Test(hello_world, set_measurements, dimensions, attachments, # Some metadata fields, these in particular are used by mfg-inspector, # but you can include any metadata fields. test_name='MyTest', test_description='OpenHTF Example Test', test_version='1.0.0') - test.add_output_callbacks(output.OutputToFile( + test.add_output_callbacks(htf.output.callbacks.OutputToFile( './{dut_id}.{metadata[test_name]}.{start_time_millis}.pickle')) test.add_output_callbacks( - json_factory.OutputToJSON( + htf.output.callbacks.json_factory.OutputToJSON( './{dut_id}.{metadata[test_name]}.{start_time_millis}.json', indent=4)) - #test.add_output_callbacks(mfg_inspector.OutputToTestRunProto( + + # Example of how to output to testrun protobuf format. + #test.add_output_callbacks( + # htf.output.callbacks.mfg_inspector.OutputToTestRunProto( # './{dut_id}.{start_time_millis}.pb')) + # Example of how to upload to mfg-inspector. Replace filename with your # JSON-formatted private key downloaded from Google Developers Console # when you created the Service Account you intend to use, or name it diff --git a/examples/example_plug.py b/examples/example_plug.py index 69521d536..2e25d9437 100644 --- a/examples/example_plug.py +++ b/examples/example_plug.py @@ -18,8 +18,8 @@ import time -import openhtf.conf as conf import openhtf.plugs as plugs +from openhtf.util import conf conf.declare('example_plug_increment_size', default_value=1, diff --git a/examples/hello_world.py b/examples/hello_world.py index cd32b028f..fa2c8745a 100644 --- a/examples/hello_world.py +++ b/examples/hello_world.py @@ -27,21 +27,21 @@ For more information on output, see the output.py example. """ +# Import openhtf with an abbreviated name, as we'll be using a bunch of stuff +# from it throughout our test scripts. See __all__ at the top of +# openhtf/__init__.py for details on what's in top-of-module namespace. +import openhtf as htf + # Import this output mechanism as it's the specific one we want to use. -from openhtf.io.output import json_factory +from openhtf.output.callbacks import json_factory -# Import a handful of useful names. If you're worried about polluting -# your namespace, you can manually import just the things you want, this -# is just a convenience. See names.py for an exhaustive list. -from openhtf.names import * from openhtf.plugs import user_input - -# The @measures annotation notifies the OpenHTF framework that this test +# The @htf.measures annotation notifies the OpenHTF framework that this test # phase will be taking a measurement that we'd like to call # 'hello_world_measurement'. Measurements can be accessed and set via # the 'test' object, always passed as the first argument to test phases. -@measures(Measurement('hello_world_measurement')) +@htf.measures(htf.Measurement('hello_world_measurement')) def hello_world(test): """A hello world test phase.""" # At the heart of an OpenHTF test script are the test phases, such as @@ -68,7 +68,7 @@ def hello_world(test): # Multiple phases would be passed as additional args, and additional # keyword arguments may be passed as well. See other examples for more # complex uses. - test = Test(hello_world) + test = htf.Test(hello_world) # In order to view the result of the test, we have to output it somewhere, # and a local JSON file is a convenient way to do this. Custom output diff --git a/examples/measurements.py b/examples/measurements.py index 3bb4d0828..a07d610c9 100644 --- a/examples/measurements.py +++ b/examples/measurements.py @@ -44,8 +44,13 @@ measurements, which some output formats require. """ +# Import openhtf with an abbreviated name, as we'll be using a bunch of stuff +# from it throughout our test scripts. See __all__ at the top of +# openhtf/__init__.py for details on what's in top-of-module namespace. +import openhtf as htf + # Import this output mechanism as it's the specific one we want to use. -from openhtf.io.output import json_factory +from openhtf.output.callbacks import json_factory # You won't normally need to import this, see validators.py example for # more details. It's used for the inline measurement declaration example @@ -53,20 +58,15 @@ # measurement validators. from openhtf.util import validators -# Import a handful of useful names. If you're worried about polluting -# your namespace, you can manually import just the things you want, this -# is just a convenience. See names.py for an exhaustive list. -from openhtf.names import * - # Simple example of measurement use, similar to hello_world.py usage. -@measures(Measurement('hello_world_measurement')) +@htf.measures(htf.Measurement('hello_world_measurement')) def hello_phase(test): test.measurements.hello_world_measurement = 'Hello!' # An alternative simpler syntax that creates the Measurement for you. -@measures('hello_again_measurement') +@htf.measures('hello_again_measurement') def again_phase(test): test.measurements.hello_again_measurement = 'Again!' @@ -77,8 +77,8 @@ def again_phase(test): # single decorator call. You'll also note that you can stack multiple # decorations on a single phase. This is useful if you have a handful of simple # measurements, and then one or two with more complex declarations (see below). -@measures('first_measurement', 'second_measurement') -@measures(Measurement('third'), Measurement('fourth')) +@htf.measures('first_measurement', 'second_measurement') +@htf.measures(htf.Measurement('third'), htf.Measurement('fourth')) def lots_of_measurements(test): test.measurements.first_measurement = 'First!' # Measurements can also be access via indexing rather than attributes. @@ -92,7 +92,7 @@ def lots_of_measurements(test): # measurement against some criteria, or specify additional information # describing the measurement. Validators can get quite complex, for more # details, see the validators.py example. -@measures(Measurement('validated_measurement').InRange(0, 10).Doc( +@htf.measures(htf.Measurement('validated_measurement').in_range(0, 10).doc( 'This measurement is validated.').with_units(units.SECOND)) def measure_seconds(test): # The 'outcome' of this measurement in the test_record result will be a PASS @@ -105,9 +105,9 @@ def measure_seconds(test): # specify exactly one measurement with that decorator (ie. the first argument # must be a string containing the measurement name). If you want to specify # multiple measurements this way, you can stack multiple decorators. -@measures('inline_kwargs', docstring='This measurement is declared inline!', - units=units.HERTZ, validators=[validators.InRange(0, 10)]) -@measures('another_inline', docstring='Because why not?') +@htf.measures('inline_kwargs', docstring='This measurement is declared inline!', + units=units.HERTZ, validators=[validators.in_range(0, 10)]) +@htf.measures('another_inline', docstring='Because why not?') def inline_phase(test): # This measurement will have an outcome of FAIL, because the set value of 15 # will not pass the 0 <= x <= 10 validator. @@ -120,8 +120,8 @@ def inline_phase(test): if __name__ == '__main__': # We instantiate our OpenHTF test with the phases we want to run as args. - test = Test(hello_phase, again_phase, lots_of_measurements, measure_seconds, - inline_phase) + test = htf.Test(hello_phase, again_phase, lots_of_measurements, + measure_seconds, inline_phase) # In order to view the result of the test, we have to output it somewhere, # and a local JSON file is a convenient way to do this. Custom output diff --git a/openhtf/__init__.py b/openhtf/__init__.py index b88a855b7..f26af0fae 100644 --- a/openhtf/__init__.py +++ b/openhtf/__init__.py @@ -33,20 +33,22 @@ from enum import Enum -from openhtf import conf -from openhtf import exe -from openhtf import history +from openhtf import core from openhtf import plugs from openhtf import util -from openhtf.exe import phase_executor -from openhtf.exe import triggers -from openhtf.io import station_api -from openhtf.io import test_record -from openhtf.io import user_input +from openhtf.core import history +from openhtf.core.measurements import Measurement, measures +from openhtf.core.monitors import monitors +from openhtf.core import phase_executor +from openhtf.core import station_api +from openhtf.core import test_record +from openhtf.core import triggers +from openhtf.plugs import user_input, plug +from openhtf.util import conf from openhtf.util import data from openhtf.util import functions from openhtf.util import logs -from openhtf.util import measurements +from openhtf.util import units __version__ = util.get_version() @@ -216,7 +218,7 @@ def execute(self, test_start=None): self._test_desc.metadata['config'] = conf._asdict() self.last_run_time_millis = util.time_millis() - self._executor = exe.TestExecutor( + self._executor = core.TestExecutor( self._test_desc, test_start, self._test_options.teardown_function) _LOG.info('Executing test: %s', self.descriptor.code_info.name) self._executor.start() @@ -330,6 +332,8 @@ def __call__(self, phase_func): setattr(phase.options, attr, value) return phase +TestPhase = PhaseOptions + class PhasePlug(mutablerecords.Record( 'PhasePlug', ['name', 'cls'], {'update_kwargs': True})): diff --git a/openhtf/exe/__init__.py b/openhtf/core/__init__.py similarity index 97% rename from openhtf/exe/__init__.py rename to openhtf/core/__init__.py index 346f9fddf..8ca09f8ff 100644 --- a/openhtf/exe/__init__.py +++ b/openhtf/core/__init__.py @@ -23,13 +23,12 @@ import contextlib2 as contextlib import openhtf -from openhtf import conf from openhtf import plugs from openhtf import util -from openhtf.exe import phase_executor -from openhtf.exe import test_state -from openhtf.io import test_record -from openhtf.io import user_input +from openhtf.core import phase_executor +from openhtf.core import test_record +from openhtf.core import test_state +from openhtf.util import conf from openhtf.util import threads _LOG = logging.getLogger(__name__) diff --git a/openhtf/history.py b/openhtf/core/history.py similarity index 99% rename from openhtf/history.py rename to openhtf/core/history.py index f65dcddb3..23b10c8ae 100644 --- a/openhtf/history.py +++ b/openhtf/core/history.py @@ -23,7 +23,7 @@ import sys import threading -from openhtf import conf +from openhtf.util import conf from openhtf.util import data from openhtf.util import threads diff --git a/openhtf/util/measurements.py b/openhtf/core/measurements.py similarity index 100% rename from openhtf/util/measurements.py rename to openhtf/core/measurements.py diff --git a/openhtf/util/monitors.py b/openhtf/core/monitors.py similarity index 99% rename from openhtf/util/monitors.py rename to openhtf/core/monitors.py index e5ec5d362..aae5b4a16 100644 --- a/openhtf/util/monitors.py +++ b/openhtf/core/monitors.py @@ -51,7 +51,7 @@ def MyPhase(test): import openhtf from openhtf import plugs -from openhtf.util import measurements +from openhtf.core import measurements from openhtf.util import threads from openhtf.util import units as uom diff --git a/openhtf/exe/phase_executor.py b/openhtf/core/phase_executor.py similarity index 100% rename from openhtf/exe/phase_executor.py rename to openhtf/core/phase_executor.py diff --git a/openhtf/io/station_api.py b/openhtf/core/station_api.py similarity index 99% rename from openhtf/io/station_api.py rename to openhtf/core/station_api.py index 3a0123a77..580008bbf 100644 --- a/openhtf/io/station_api.py +++ b/openhtf/core/station_api.py @@ -75,10 +75,10 @@ import mutablerecords import openhtf -from openhtf import conf -from openhtf import history from openhtf import util -from openhtf.exe import test_state +from openhtf.core import history +from openhtf.core import test_state +from openhtf.util import conf from openhtf.util import data from openhtf.util import multicast from openhtf.util import threads diff --git a/openhtf/io/test_record.py b/openhtf/core/test_record.py similarity index 100% rename from openhtf/io/test_record.py rename to openhtf/core/test_record.py diff --git a/openhtf/exe/test_state.py b/openhtf/core/test_state.py similarity index 99% rename from openhtf/exe/test_state.py rename to openhtf/core/test_state.py index fd4250a06..38345a72b 100644 --- a/openhtf/exe/test_state.py +++ b/openhtf/core/test_state.py @@ -38,12 +38,12 @@ import openhtf -from openhtf import conf from openhtf import plugs from openhtf import util -from openhtf.io import test_record +from openhtf.core import measurements +from openhtf.core import test_record +from openhtf.util import conf from openhtf.util import logs -from openhtf.util import measurements from openhtf.util import threads conf.declare('allow_unset_measurements', default_value=False, description=\ diff --git a/openhtf/exe/triggers.py b/openhtf/core/triggers.py similarity index 97% rename from openhtf/exe/triggers.py rename to openhtf/core/triggers.py index 471abbda9..c31917996 100644 --- a/openhtf/exe/triggers.py +++ b/openhtf/core/triggers.py @@ -29,7 +29,7 @@ import logging -from openhtf.io import user_input +from openhtf.util import user_input _LOG = logging.getLogger(__name__) diff --git a/openhtf/io/http_api.py b/openhtf/io/http_api.py deleted file mode 100644 index cb8a35b4f..000000000 --- a/openhtf/io/http_api.py +++ /dev/null @@ -1,147 +0,0 @@ -# Copyright 2014 Google Inc. All Rights Reserved. - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -"""Web API to OpenHTF framework. - -Frontends will interact with these handlers to get state and respond to prompts -for an individual instance of OpenHTF. Multiple instances of OpenHTF on the same -host should serve this API on different TCP ports via the --port flag.""" - - -import BaseHTTPServer -import json -import logging -import threading -import uuid - -from openhtf.io import user_input -from openhtf.util import data -from openhtf.util import multicast - - -_LOG = logging.getLogger(__name__) - -PING_STRING = 'OPENHTF_PING' -PING_RESPONSE_KEY = 'OPENHTF_PING_RESPONSE' -DEFAULT_HTTP_PORT = 8888 -PROMPT_ACK = 'ACK' -PROMPT_NACK = 'NACK' - - -class Server(object): - """Frontend API server for openhtf. - - Starts up two services as separate threads. An HTTP server that serves - detailed information about this intance of openhtf, and a multicast station - discovery service that helps frontends find and connect to the HTTP server. - Args: - executor: An openhtf.exe.TestExecutor object. - discovery_info: A dict to specify options for service discovery. - See openhtf.util.multicast.MulticastListener, these are passed in as - keyword-arguments unmodified. - """ - KILL_TIMEOUT_S = 1 # Seconds to wait between service kill attempts. - - - def __init__(self, executor, http_port, multicast_info=None): - super(Server, self).__init__() - - def multicast_response(message): - """Formulate a response to a station discovery ping.""" - if message == PING_STRING: - return json.dumps({PING_RESPONSE_KEY: http_port}) - else: - _LOG.debug( - 'Received non-openhtf traffic on multicast socket: %s' % message) - - self.servers = [HTTPServer(executor, http_port), - multicast.MulticastListener( - multicast_response, **(multicast_info or {}))] - - def start(self): - """Start all service threads.""" - for server in self.servers: - server.start() - - def stop(self): - """Stop all service threads.""" - for server in self.servers: - while server.is_alive(): - server.stop() - server.join(self.KILL_TIMEOUT_S) - - -class HTTPServer(threading.Thread): - """Bare-bones HTTP API server for OpenHTF. - - Args: - executor: An openhtf.exe.TestExecutor object. - """ - def __init__(self, executor, http_port): - super(HTTPServer, self).__init__() - self._HTTPHandler.executor = executor - self._server = None - self._http_port = http_port - - class _HTTPHandler(BaseHTTPServer.BaseHTTPRequestHandler): - """Request handler class for OpenHTF's HTTP API.""" - - executor = None - - def log_message(self, msg_format, *args): - """Override the built-in log_message to log to our logger.""" - _LOG.debug("%s - - [%s] %s\n", - self.client_address[0], - self.log_date_time_string(), - msg_format%args) - - def do_get(self): # pylint: disable=invalid-name - """Reply with a JSON representation of the current framwork and test - states. - """ - result = {'test': data.convert_to_base_types( - self.executor.get_state(), - ignore_keys=('plug_manager',)), - 'framework': data.convert_to_base_types(self.executor)} - self.send_response(200) - self.end_headers() - self.wfile.write(json.dumps(result)) - #command, path, version = self.requestline.split() - - def do_post(self): # pylint: disable=invalid-name - """Parse a prompt response and send it to the PromptManager.""" - length = int(self.headers.getheader('content-length')) - raw = self.rfile.read(length) - request = json.loads(raw) - result = user_input.get_prompt_manager().respond( - uuid.UUID((request['id'])), request['response']) - self.send_response(200) - self.end_headers() - if result: - self.wfile.write(PROMPT_ACK) - else: - self.wfile.write(PROMPT_NACK) - - - def stop(self): - """Stop the HTTP server.""" - if self._server: - self._server.shutdown() - - def run(self): - """Start up a raw HTTPServer based on our HTTPHandler definition.""" - self._server = BaseHTTPServer.HTTPServer( - ('', self._http_port), self._HTTPHandler) - self._server.serve_forever() diff --git a/openhtf/names.py b/openhtf/names.py deleted file mode 100644 index 87dafc325..000000000 --- a/openhtf/names.py +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2015 Google Inc. All Rights Reserved. - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -"""OpenHTF name imports for convenience. - -Use 'from openhtf.names import *' at the top of a test script to map commonly -used names: - -Decorators for test phase functions: - @measures Attach measurements to test phases. - @plug Use a hardware plug in a test phase. - @TestPhase Make a test phase out of any function, using given options. - -Classes for instantiation: - Measurement A measurement to be taken within a test phase. - PhaseResult Return value from phases for controlling the framework. - Test Type to instantiate an OpenHTF test. - -Unit codes for lookup: - UOM Reference for SI units and their codes. -""" - -import openhtf -import openhtf.io.output.json_factory -import openhtf.io.user_input -import openhtf.plugs -import openhtf.util.measurements -import openhtf.util.monitors -import openhtf.util.validators -import openhtf.util.units - - -# pylint: disable=invalid-name - -# Pseudomodules. -prompts = openhtf.io.user_input.get_prompt_manager() -triggers = openhtf.exe.triggers -validators = openhtf.util.validators -output = openhtf.io.output -units = openhtf.util.units - -# Functions used in writing test scripts. -measures = openhtf.util.measurements.measures -monitors = openhtf.util.monitors.monitors -plug = openhtf.plugs.plug - -# Classes used in writing test scripts. -Measurement = openhtf.util.measurements.Measurement -TestPhase = openhtf.PhaseOptions -PhaseResult = openhtf.PhaseResult -Test = openhtf.Test diff --git a/openhtf/io/proto/__init__.py b/openhtf/output/__init__.py similarity index 100% rename from openhtf/io/proto/__init__.py rename to openhtf/output/__init__.py diff --git a/openhtf/io/output/__init__.py b/openhtf/output/callbacks/__init__.py similarity index 99% rename from openhtf/io/output/__init__.py rename to openhtf/output/callbacks/__init__.py index dc8e78efa..92b157df8 100644 --- a/openhtf/io/output/__init__.py +++ b/openhtf/output/callbacks/__init__.py @@ -26,6 +26,7 @@ import os import shutil import tempfile + from openhtf.util import data diff --git a/openhtf/io/output/console_summary.py b/openhtf/output/callbacks/console_summary.py similarity index 94% rename from openhtf/io/output/console_summary.py rename to openhtf/output/callbacks/console_summary.py index 0a4b16587..a1c08c6ba 100644 --- a/openhtf/io/output/console_summary.py +++ b/openhtf/output/callbacks/console_summary.py @@ -3,8 +3,8 @@ import os import sys -from openhtf.io import test_record -from openhtf.util import measurements as measurement +from openhtf.core import test_record +from openhtf.core import measurements as meas_module class ConsoleSummary(): @@ -48,7 +48,7 @@ def __call__(self, record): measurements = phase.measurements for key in measurements: result = measurements[key] - if result.outcome == measurement.Outcome.FAIL: + if result.outcome == meas_module.Outcome.FAIL: if new_phase: output_lines.append('failed phase: %s [ran for %.2f sec]' % (phase.name, phase_time_sec)) diff --git a/openhtf/io/output/json_factory.py b/openhtf/output/callbacks/json_factory.py similarity index 92% rename from openhtf/io/output/json_factory.py rename to openhtf/output/callbacks/json_factory.py index 290586888..41f5e4e3b 100644 --- a/openhtf/io/output/json_factory.py +++ b/openhtf/output/callbacks/json_factory.py @@ -1,18 +1,21 @@ """Module for outputting test record to JSON-formatted files.""" + import base64 from json import JSONEncoder -from openhtf.io import output + +from openhtf.output import callbacks from openhtf.util import data -class OutputToJSON(output.OutputToFile): + +class OutputToJSON(callbacks.OutputToFile): """Return an output callback that writes JSON Test Records. Example filename_patterns might be: '/data/test_records/{dut_id}.{metadata[test_name]}.json', indent=4)) or '/data/test_records/%(dut_id)s.%(start_time_millis)s' To use this output mechanism: test = openhtf.Test(PhaseOne, PhaseTwo) - test.add_output_callback(openhtf.OutputToJson( + test.add_output_callback(openhtf.output.callbacks.OutputToJson( '/data/test_records/{dut_id}.{metadata[test_name]}.json')) Args: diff --git a/openhtf/io/output/mfg_inspector.py b/openhtf/output/callbacks/mfg_inspector.py similarity index 98% rename from openhtf/io/output/mfg_inspector.py rename to openhtf/output/callbacks/mfg_inspector.py index 83916de11..6f377bc0b 100644 --- a/openhtf/io/output/mfg_inspector.py +++ b/openhtf/output/callbacks/mfg_inspector.py @@ -36,14 +36,14 @@ import httplib2 import oauth2client.client -from openhtf.io import output -from openhtf.io.output import json_factory -from openhtf.io.proto import guzzle_pb2 -from openhtf.io.proto import test_runs_pb2 -from openhtf.io.proto import units_pb2 - -from openhtf.io import test_record -from openhtf.util import measurements + +from openhtf.core import measurements +from openhtf.core import test_record +from openhtf.output import callbacks +from openhtf.output.callbacks import json_factory +from openhtf.output.proto import guzzle_pb2 +from openhtf.output.proto import test_runs_pb2 +from openhtf.output.proto import units_pb2 from openhtf.util import validators @@ -342,7 +342,7 @@ def _test_run_from_test_record(record): return testrun -class OutputToTestRunProto(output.OutputToFile): +class OutputToTestRunProto(callbacks.OutputToFile): """Return an output callback that writes mfg-inspector TestRun Protos. Example filename_patterns might be: diff --git a/openhtf/output/proto/__init__.py b/openhtf/output/proto/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openhtf/io/proto/guzzle.proto b/openhtf/output/proto/guzzle.proto similarity index 100% rename from openhtf/io/proto/guzzle.proto rename to openhtf/output/proto/guzzle.proto diff --git a/openhtf/io/proto/test_runs.proto b/openhtf/output/proto/test_runs.proto similarity index 100% rename from openhtf/io/proto/test_runs.proto rename to openhtf/output/proto/test_runs.proto diff --git a/openhtf/io/proto/units.proto b/openhtf/output/proto/units.proto similarity index 100% rename from openhtf/io/proto/units.proto rename to openhtf/output/proto/units.proto diff --git a/openhtf/io/frontend/.gitignore b/openhtf/output/web_gui/.gitignore similarity index 100% rename from openhtf/io/frontend/.gitignore rename to openhtf/output/web_gui/.gitignore diff --git a/openhtf/io/frontend/__init__.py b/openhtf/output/web_gui/__init__.py similarity index 98% rename from openhtf/io/frontend/__init__.py rename to openhtf/output/web_gui/__init__.py index 3aab0cb8d..8c7d2ff77 100644 --- a/openhtf/io/frontend/__init__.py +++ b/openhtf/output/web_gui/__init__.py @@ -61,14 +61,11 @@ import tornado.ioloop import tornado.web -from openhtf import conf from openhtf import plugs -from openhtf.io import station_api -from openhtf.io.http_api import PING_STRING -from openhtf.io.http_api import PING_RESPONSE_KEY +from openhtf.core import station_api from openhtf.util import classproperty +from openhtf.util import conf from openhtf.util import logs -from openhtf.util import multicast from openhtf.util.data import convert_to_base_types diff --git a/openhtf/io/frontend/__main__.py b/openhtf/output/web_gui/__main__.py similarity index 74% rename from openhtf/io/frontend/__main__.py rename to openhtf/output/web_gui/__main__.py index 92189a17b..f9cfc60be 100644 --- a/openhtf/io/frontend/__main__.py +++ b/openhtf/output/web_gui/__main__.py @@ -21,8 +21,8 @@ import logging import signal -import openhtf.io.frontend -from openhtf import conf +import openhtf.output.web_gui +from openhtf.util import conf from openhtf.util import logs @@ -30,10 +30,10 @@ def main(): - """Start the frontend.""" - parser = argparse.ArgumentParser(description='OpenHTF web frontend server.', + """Start the web gui.""" + parser = argparse.ArgumentParser(description='OpenHTF web gui server.', parents=[conf.ARG_PARSER], - prog='python -m openhtf.io.frontend') + prog='python -m openhtf.output.web_gui') parser.add_argument('--port', type=int, default=12000, help='Port on which to serve the frontend.') parser.add_argument('--discovery_interval_s', type=int, default=3, @@ -46,10 +46,10 @@ def main(): logs.setup_logger() - web_server = openhtf.io.frontend.WebGuiServer(args.discovery_interval_s, - args.disable_discovery, - args.port, - args.dev) + web_server = openhtf.output.web_gui.WebGuiServer(args.discovery_interval_s, + args.disable_discovery, + args.port, + args.dev) def sigint_handler(*dummy): """Handle SIGINT by stopping running executor and handler.""" @@ -57,7 +57,7 @@ def sigint_handler(*dummy): web_server.stop() signal.signal(signal.SIGINT, sigint_handler) - print('Starting openhtf web server on http://localhost:%s.' % args.port) + print('Starting openhtf web gui server on http://localhost:%s.' % args.port) web_server.start() diff --git a/openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-012cf6a10129e2275d79d6adac7f3b02.woff b/openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-012cf6a10129e2275d79d6adac7f3b02.woff similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-012cf6a10129e2275d79d6adac7f3b02.woff rename to openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-012cf6a10129e2275d79d6adac7f3b02.woff diff --git a/openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-570eb83859dc23dd0eec423a49e147fe.woff2 b/openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-570eb83859dc23dd0eec423a49e147fe.woff2 similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-570eb83859dc23dd0eec423a49e147fe.woff2 rename to openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-570eb83859dc23dd0eec423a49e147fe.woff2 diff --git a/openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-a37b0c01c0baf1888ca812cc0508f6e2.ttf b/openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-a37b0c01c0baf1888ca812cc0508f6e2.ttf similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-a37b0c01c0baf1888ca812cc0508f6e2.ttf rename to openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-a37b0c01c0baf1888ca812cc0508f6e2.ttf diff --git a/openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-e79bfd88537def476913f3ed52f4f4b3.eot b/openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-e79bfd88537def476913f3ed52f4f4b3.eot similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/MaterialIcons-Regular-e79bfd88537def476913f3ed52f4f4b3.eot rename to openhtf/output/web_gui/prebuilt/fonts/MaterialIcons-Regular-e79bfd88537def476913f3ed52f4f4b3.eot diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Bold-39b2c3031be6b4ea96e2e3e95d307814.woff2 b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Bold-39b2c3031be6b4ea96e2e3e95d307814.woff2 similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Bold-39b2c3031be6b4ea96e2e3e95d307814.woff2 rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Bold-39b2c3031be6b4ea96e2e3e95d307814.woff2 diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Bold-dc81817def276b4f21395f7ea5e88dcd.woff b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Bold-dc81817def276b4f21395f7ea5e88dcd.woff similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Bold-dc81817def276b4f21395f7ea5e88dcd.woff rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Bold-dc81817def276b4f21395f7ea5e88dcd.woff diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Bold-e31fcf1885e371e19f5786c2bdfeae1b.ttf b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Bold-e31fcf1885e371e19f5786c2bdfeae1b.ttf similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Bold-e31fcf1885e371e19f5786c2bdfeae1b.ttf rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Bold-e31fcf1885e371e19f5786c2bdfeae1b.ttf diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Light-3b813c2ae0d04909a33a18d792912ee7.woff b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Light-3b813c2ae0d04909a33a18d792912ee7.woff similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Light-3b813c2ae0d04909a33a18d792912ee7.woff rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Light-3b813c2ae0d04909a33a18d792912ee7.woff diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Light-46e48ce0628835f68a7369d0254e4283.ttf b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Light-46e48ce0628835f68a7369d0254e4283.ttf similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Light-46e48ce0628835f68a7369d0254e4283.ttf rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Light-46e48ce0628835f68a7369d0254e4283.ttf diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Light-69f8a0617ac472f78e45841323a3df9e.woff2 b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Light-69f8a0617ac472f78e45841323a3df9e.woff2 similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Light-69f8a0617ac472f78e45841323a3df9e.woff2 rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Light-69f8a0617ac472f78e45841323a3df9e.woff2 diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Medium-574fd0b50367f886d359e8264938fc37.woff2 b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Medium-574fd0b50367f886d359e8264938fc37.woff2 similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Medium-574fd0b50367f886d359e8264938fc37.woff2 rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Medium-574fd0b50367f886d359e8264938fc37.woff2 diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Medium-894a2ede85a483bf9bedefd4db45cdb9.ttf b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Medium-894a2ede85a483bf9bedefd4db45cdb9.ttf similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Medium-894a2ede85a483bf9bedefd4db45cdb9.ttf rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Medium-894a2ede85a483bf9bedefd4db45cdb9.ttf diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Medium-fc78759e93a6cac50458610e3d9d63a0.woff b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Medium-fc78759e93a6cac50458610e3d9d63a0.woff similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Medium-fc78759e93a6cac50458610e3d9d63a0.woff rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Medium-fc78759e93a6cac50458610e3d9d63a0.woff diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Regular-2751ee43015f9884c3642f103b7f70c9.woff2 b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Regular-2751ee43015f9884c3642f103b7f70c9.woff2 similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Regular-2751ee43015f9884c3642f103b7f70c9.woff2 rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Regular-2751ee43015f9884c3642f103b7f70c9.woff2 diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Regular-ba3dcd8903e3d0af5de7792777f8ae0d.woff b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Regular-ba3dcd8903e3d0af5de7792777f8ae0d.woff similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Regular-ba3dcd8903e3d0af5de7792777f8ae0d.woff rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Regular-ba3dcd8903e3d0af5de7792777f8ae0d.woff diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Regular-df7b648ce5356ea1ebce435b3459fd60.ttf b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Regular-df7b648ce5356ea1ebce435b3459fd60.ttf similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Regular-df7b648ce5356ea1ebce435b3459fd60.ttf rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Regular-df7b648ce5356ea1ebce435b3459fd60.ttf diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Thin-7500519de3d82e33d1587f8042e2afcb.woff b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Thin-7500519de3d82e33d1587f8042e2afcb.woff similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Thin-7500519de3d82e33d1587f8042e2afcb.woff rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Thin-7500519de3d82e33d1587f8042e2afcb.woff diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Thin-94998475f6aea65f558494802416c1cf.ttf b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Thin-94998475f6aea65f558494802416c1cf.ttf similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Thin-94998475f6aea65f558494802416c1cf.ttf rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Thin-94998475f6aea65f558494802416c1cf.ttf diff --git a/openhtf/io/frontend/prebuilt/fonts/Roboto-Thin-954bbdeb86483e4ffea00c4591530ece.woff2 b/openhtf/output/web_gui/prebuilt/fonts/Roboto-Thin-954bbdeb86483e4ffea00c4591530ece.woff2 similarity index 100% rename from openhtf/io/frontend/prebuilt/fonts/Roboto-Thin-954bbdeb86483e4ffea00c4591530ece.woff2 rename to openhtf/output/web_gui/prebuilt/fonts/Roboto-Thin-954bbdeb86483e4ffea00c4591530ece.woff2 diff --git a/openhtf/io/frontend/prebuilt/index.html b/openhtf/output/web_gui/prebuilt/index.html similarity index 100% rename from openhtf/io/frontend/prebuilt/index.html rename to openhtf/output/web_gui/prebuilt/index.html diff --git a/openhtf/io/frontend/prebuilt/scripts/app.bundle.js b/openhtf/output/web_gui/prebuilt/scripts/app.bundle.js similarity index 100% rename from openhtf/io/frontend/prebuilt/scripts/app.bundle.js rename to openhtf/output/web_gui/prebuilt/scripts/app.bundle.js diff --git a/openhtf/io/frontend/prebuilt/scripts/app.bundle.js.map b/openhtf/output/web_gui/prebuilt/scripts/app.bundle.js.map similarity index 100% rename from openhtf/io/frontend/prebuilt/scripts/app.bundle.js.map rename to openhtf/output/web_gui/prebuilt/scripts/app.bundle.js.map diff --git a/openhtf/io/frontend/prebuilt/scripts/vendor.bundle.js b/openhtf/output/web_gui/prebuilt/scripts/vendor.bundle.js similarity index 100% rename from openhtf/io/frontend/prebuilt/scripts/vendor.bundle.js rename to openhtf/output/web_gui/prebuilt/scripts/vendor.bundle.js diff --git a/openhtf/io/frontend/prebuilt/scripts/vendor.bundle.js.map b/openhtf/output/web_gui/prebuilt/scripts/vendor.bundle.js.map similarity index 100% rename from openhtf/io/frontend/prebuilt/scripts/vendor.bundle.js.map rename to openhtf/output/web_gui/prebuilt/scripts/vendor.bundle.js.map diff --git a/openhtf/io/frontend/prebuilt/styles.css b/openhtf/output/web_gui/prebuilt/styles.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles.css rename to openhtf/output/web_gui/prebuilt/styles.css diff --git a/openhtf/io/frontend/prebuilt/styles/dashboard.css b/openhtf/output/web_gui/prebuilt/styles/dashboard.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/dashboard.css rename to openhtf/output/web_gui/prebuilt/styles/dashboard.css diff --git a/openhtf/io/frontend/prebuilt/styles/dashboard.stationcard.css b/openhtf/output/web_gui/prebuilt/styles/dashboard.stationcard.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/dashboard.stationcard.css rename to openhtf/output/web_gui/prebuilt/styles/dashboard.stationcard.css diff --git a/openhtf/io/frontend/prebuilt/styles/prompt.css b/openhtf/output/web_gui/prebuilt/styles/prompt.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/prompt.css rename to openhtf/output/web_gui/prebuilt/styles/prompt.css diff --git a/openhtf/io/frontend/prebuilt/styles/station.css b/openhtf/output/web_gui/prebuilt/styles/station.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/station.css rename to openhtf/output/web_gui/prebuilt/styles/station.css diff --git a/openhtf/io/frontend/prebuilt/styles/station.header.css b/openhtf/output/web_gui/prebuilt/styles/station.header.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/station.header.css rename to openhtf/output/web_gui/prebuilt/styles/station.header.css diff --git a/openhtf/io/frontend/prebuilt/styles/station.logs.css b/openhtf/output/web_gui/prebuilt/styles/station.logs.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/station.logs.css rename to openhtf/output/web_gui/prebuilt/styles/station.logs.css diff --git a/openhtf/io/frontend/prebuilt/styles/station.metadata.css b/openhtf/output/web_gui/prebuilt/styles/station.metadata.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/station.metadata.css rename to openhtf/output/web_gui/prebuilt/styles/station.metadata.css diff --git a/openhtf/io/frontend/prebuilt/styles/station.phases.css b/openhtf/output/web_gui/prebuilt/styles/station.phases.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/station.phases.css rename to openhtf/output/web_gui/prebuilt/styles/station.phases.css diff --git a/openhtf/io/frontend/prebuilt/styles/station.prompt.css b/openhtf/output/web_gui/prebuilt/styles/station.prompt.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/station.prompt.css rename to openhtf/output/web_gui/prebuilt/styles/station.prompt.css diff --git a/openhtf/io/frontend/prebuilt/styles/station.testheader.css b/openhtf/output/web_gui/prebuilt/styles/station.testheader.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/station.testheader.css rename to openhtf/output/web_gui/prebuilt/styles/station.testheader.css diff --git a/openhtf/io/frontend/prebuilt/styles/test.css b/openhtf/output/web_gui/prebuilt/styles/test.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/test.css rename to openhtf/output/web_gui/prebuilt/styles/test.css diff --git a/openhtf/io/frontend/prebuilt/styles/test.header.css b/openhtf/output/web_gui/prebuilt/styles/test.header.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/test.header.css rename to openhtf/output/web_gui/prebuilt/styles/test.header.css diff --git a/openhtf/io/frontend/prebuilt/styles/test.logs.css b/openhtf/output/web_gui/prebuilt/styles/test.logs.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/test.logs.css rename to openhtf/output/web_gui/prebuilt/styles/test.logs.css diff --git a/openhtf/io/frontend/prebuilt/styles/test.phases.css b/openhtf/output/web_gui/prebuilt/styles/test.phases.css similarity index 100% rename from openhtf/io/frontend/prebuilt/styles/test.phases.css rename to openhtf/output/web_gui/prebuilt/styles/test.phases.css diff --git a/openhtf/io/frontend/prebuilt/templates/prompt.html b/openhtf/output/web_gui/prebuilt/templates/prompt.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/prompt.html rename to openhtf/output/web_gui/prebuilt/templates/prompt.html diff --git a/openhtf/io/frontend/prebuilt/templates/station.header.html b/openhtf/output/web_gui/prebuilt/templates/station.header.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/station.header.html rename to openhtf/output/web_gui/prebuilt/templates/station.header.html diff --git a/openhtf/io/frontend/src/app/station.html b/openhtf/output/web_gui/prebuilt/templates/station.html similarity index 100% rename from openhtf/io/frontend/src/app/station.html rename to openhtf/output/web_gui/prebuilt/templates/station.html diff --git a/openhtf/io/frontend/src/app/station.phases.html b/openhtf/output/web_gui/prebuilt/templates/station.phases.html similarity index 100% rename from openhtf/io/frontend/src/app/station.phases.html rename to openhtf/output/web_gui/prebuilt/templates/station.phases.html diff --git a/openhtf/io/frontend/prebuilt/templates/station.prompt.html b/openhtf/output/web_gui/prebuilt/templates/station.prompt.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/station.prompt.html rename to openhtf/output/web_gui/prebuilt/templates/station.prompt.html diff --git a/openhtf/io/frontend/prebuilt/templates/station.testheader.html b/openhtf/output/web_gui/prebuilt/templates/station.testheader.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/station.testheader.html rename to openhtf/output/web_gui/prebuilt/templates/station.testheader.html diff --git a/openhtf/io/frontend/prebuilt/templates/test.header.html b/openhtf/output/web_gui/prebuilt/templates/test.header.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/test.header.html rename to openhtf/output/web_gui/prebuilt/templates/test.header.html diff --git a/openhtf/io/frontend/prebuilt/templates/test.html b/openhtf/output/web_gui/prebuilt/templates/test.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/test.html rename to openhtf/output/web_gui/prebuilt/templates/test.html diff --git a/openhtf/io/frontend/prebuilt/templates/test.phases.html b/openhtf/output/web_gui/prebuilt/templates/test.phases.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/test.phases.html rename to openhtf/output/web_gui/prebuilt/templates/test.phases.html diff --git a/openhtf/io/frontend/src/.bowerrc b/openhtf/output/web_gui/src/.bowerrc similarity index 100% rename from openhtf/io/frontend/src/.bowerrc rename to openhtf/output/web_gui/src/.bowerrc diff --git a/openhtf/io/frontend/src/app/dashboard.css b/openhtf/output/web_gui/src/app/dashboard.css similarity index 100% rename from openhtf/io/frontend/src/app/dashboard.css rename to openhtf/output/web_gui/src/app/dashboard.css diff --git a/openhtf/io/frontend/src/app/dashboard.service.ts b/openhtf/output/web_gui/src/app/dashboard.service.ts similarity index 100% rename from openhtf/io/frontend/src/app/dashboard.service.ts rename to openhtf/output/web_gui/src/app/dashboard.service.ts diff --git a/openhtf/io/frontend/src/app/dashboard.ts b/openhtf/output/web_gui/src/app/dashboard.ts similarity index 100% rename from openhtf/io/frontend/src/app/dashboard.ts rename to openhtf/output/web_gui/src/app/dashboard.ts diff --git a/openhtf/io/frontend/src/app/index.html b/openhtf/output/web_gui/src/app/index.html similarity index 100% rename from openhtf/io/frontend/src/app/index.html rename to openhtf/output/web_gui/src/app/index.html diff --git a/openhtf/io/frontend/src/app/main.ts b/openhtf/output/web_gui/src/app/main.ts similarity index 100% rename from openhtf/io/frontend/src/app/main.ts rename to openhtf/output/web_gui/src/app/main.ts diff --git a/openhtf/io/frontend/src/app/station.css b/openhtf/output/web_gui/src/app/station.css similarity index 100% rename from openhtf/io/frontend/src/app/station.css rename to openhtf/output/web_gui/src/app/station.css diff --git a/openhtf/io/frontend/src/app/station.header.css b/openhtf/output/web_gui/src/app/station.header.css similarity index 100% rename from openhtf/io/frontend/src/app/station.header.css rename to openhtf/output/web_gui/src/app/station.header.css diff --git a/openhtf/io/frontend/src/app/station.header.html b/openhtf/output/web_gui/src/app/station.header.html similarity index 100% rename from openhtf/io/frontend/src/app/station.header.html rename to openhtf/output/web_gui/src/app/station.header.html diff --git a/openhtf/io/frontend/src/app/station.header.ts b/openhtf/output/web_gui/src/app/station.header.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.header.ts rename to openhtf/output/web_gui/src/app/station.header.ts diff --git a/openhtf/io/frontend/prebuilt/templates/station.html b/openhtf/output/web_gui/src/app/station.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/station.html rename to openhtf/output/web_gui/src/app/station.html diff --git a/openhtf/io/frontend/src/app/station.logs.css b/openhtf/output/web_gui/src/app/station.logs.css similarity index 100% rename from openhtf/io/frontend/src/app/station.logs.css rename to openhtf/output/web_gui/src/app/station.logs.css diff --git a/openhtf/io/frontend/src/app/station.logs.ts b/openhtf/output/web_gui/src/app/station.logs.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.logs.ts rename to openhtf/output/web_gui/src/app/station.logs.ts diff --git a/openhtf/io/frontend/src/app/station.metadata.css b/openhtf/output/web_gui/src/app/station.metadata.css similarity index 100% rename from openhtf/io/frontend/src/app/station.metadata.css rename to openhtf/output/web_gui/src/app/station.metadata.css diff --git a/openhtf/io/frontend/src/app/station.metadata.ts b/openhtf/output/web_gui/src/app/station.metadata.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.metadata.ts rename to openhtf/output/web_gui/src/app/station.metadata.ts diff --git a/openhtf/io/frontend/src/app/station.phases.css b/openhtf/output/web_gui/src/app/station.phases.css similarity index 100% rename from openhtf/io/frontend/src/app/station.phases.css rename to openhtf/output/web_gui/src/app/station.phases.css diff --git a/openhtf/io/frontend/prebuilt/templates/station.phases.html b/openhtf/output/web_gui/src/app/station.phases.html similarity index 100% rename from openhtf/io/frontend/prebuilt/templates/station.phases.html rename to openhtf/output/web_gui/src/app/station.phases.html diff --git a/openhtf/io/frontend/src/app/station.phases.ts b/openhtf/output/web_gui/src/app/station.phases.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.phases.ts rename to openhtf/output/web_gui/src/app/station.phases.ts diff --git a/openhtf/io/frontend/src/app/station.prompt.css b/openhtf/output/web_gui/src/app/station.prompt.css similarity index 100% rename from openhtf/io/frontend/src/app/station.prompt.css rename to openhtf/output/web_gui/src/app/station.prompt.css diff --git a/openhtf/io/frontend/src/app/station.prompt.html b/openhtf/output/web_gui/src/app/station.prompt.html similarity index 100% rename from openhtf/io/frontend/src/app/station.prompt.html rename to openhtf/output/web_gui/src/app/station.prompt.html diff --git a/openhtf/io/frontend/src/app/station.prompt.ts b/openhtf/output/web_gui/src/app/station.prompt.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.prompt.ts rename to openhtf/output/web_gui/src/app/station.prompt.ts diff --git a/openhtf/io/frontend/src/app/station.service.ts b/openhtf/output/web_gui/src/app/station.service.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.service.ts rename to openhtf/output/web_gui/src/app/station.service.ts diff --git a/openhtf/io/frontend/src/app/station.testheader.css b/openhtf/output/web_gui/src/app/station.testheader.css similarity index 100% rename from openhtf/io/frontend/src/app/station.testheader.css rename to openhtf/output/web_gui/src/app/station.testheader.css diff --git a/openhtf/io/frontend/src/app/station.testheader.html b/openhtf/output/web_gui/src/app/station.testheader.html similarity index 100% rename from openhtf/io/frontend/src/app/station.testheader.html rename to openhtf/output/web_gui/src/app/station.testheader.html diff --git a/openhtf/io/frontend/src/app/station.testheader.ts b/openhtf/output/web_gui/src/app/station.testheader.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.testheader.ts rename to openhtf/output/web_gui/src/app/station.testheader.ts diff --git a/openhtf/io/frontend/src/app/station.ts b/openhtf/output/web_gui/src/app/station.ts similarity index 100% rename from openhtf/io/frontend/src/app/station.ts rename to openhtf/output/web_gui/src/app/station.ts diff --git a/openhtf/io/frontend/src/app/styles.css b/openhtf/output/web_gui/src/app/styles.css similarity index 100% rename from openhtf/io/frontend/src/app/styles.css rename to openhtf/output/web_gui/src/app/styles.css diff --git a/openhtf/io/frontend/src/app/utils.ts b/openhtf/output/web_gui/src/app/utils.ts similarity index 100% rename from openhtf/io/frontend/src/app/utils.ts rename to openhtf/output/web_gui/src/app/utils.ts diff --git a/openhtf/io/frontend/src/app/vendor.ts b/openhtf/output/web_gui/src/app/vendor.ts similarity index 100% rename from openhtf/io/frontend/src/app/vendor.ts rename to openhtf/output/web_gui/src/app/vendor.ts diff --git a/openhtf/io/frontend/src/other_modules/get_other_modules.py b/openhtf/output/web_gui/src/other_modules/get_other_modules.py similarity index 100% rename from openhtf/io/frontend/src/other_modules/get_other_modules.py rename to openhtf/output/web_gui/src/other_modules/get_other_modules.py diff --git a/openhtf/io/frontend/src/package.json b/openhtf/output/web_gui/src/package.json similarity index 100% rename from openhtf/io/frontend/src/package.json rename to openhtf/output/web_gui/src/package.json diff --git a/openhtf/io/frontend/src/tsconfig.json b/openhtf/output/web_gui/src/tsconfig.json similarity index 100% rename from openhtf/io/frontend/src/tsconfig.json rename to openhtf/output/web_gui/src/tsconfig.json diff --git a/openhtf/io/frontend/src/typings.json b/openhtf/output/web_gui/src/typings.json similarity index 100% rename from openhtf/io/frontend/src/typings.json rename to openhtf/output/web_gui/src/typings.json diff --git a/openhtf/io/frontend/src/webpack.config.js b/openhtf/output/web_gui/src/webpack.config.js similarity index 100% rename from openhtf/io/frontend/src/webpack.config.js rename to openhtf/output/web_gui/src/webpack.config.js diff --git a/openhtf/plugs/__init__.py b/openhtf/plugs/__init__.py index 1f08315d5..44199d974 100644 --- a/openhtf/plugs/__init__.py +++ b/openhtf/plugs/__init__.py @@ -75,7 +75,7 @@ def TestPhase(test, example): of doing this is with the conf.inject_positional_args decorator: from openhtf import plugs - from openhtf import conf + from openhtf.util import conf conf.declare('my_config_key', default_value='my_config_value') @@ -109,7 +109,7 @@ def __init__(self, my_config_key) import sockjs.tornado import openhtf -from openhtf import conf +from openhtf.util import conf from openhtf.util import logs from openhtf.util import timeouts from openhtf.util import xmlrpcutil diff --git a/openhtf/plugs/usb/__init__.py b/openhtf/plugs/usb/__init__.py index 537c67d07..527756135 100644 --- a/openhtf/plugs/usb/__init__.py +++ b/openhtf/plugs/usb/__init__.py @@ -32,13 +32,13 @@ def MyPhase(test, adb): import time import openhtf.plugs as plugs -from openhtf import conf from openhtf.plugs.usb import adb_device from openhtf.plugs.usb import fastboot_device from openhtf.plugs.usb import local_usb from openhtf.plugs.usb import usb_exceptions from openhtf.plugs import cambrionix from openhtf.triggers import prompt_for_test_start +from openhtf.util import conf _LOG = logging.getLogger(__name__) diff --git a/openhtf/conf.py b/openhtf/util/conf.py similarity index 98% rename from openhtf/conf.py rename to openhtf/util/conf.py index 57d2f1dd0..3d127dc4d 100644 --- a/openhtf/conf.py +++ b/openhtf/util/conf.py @@ -166,8 +166,8 @@ def do_stuff(): import mutablerecords -from openhtf.util import argv -from openhtf.util import threads +import argv +import threads # If provided, --config-file will cause the given file to be load()ed when the # conf module is initially imported. @@ -239,17 +239,27 @@ def __init__(self, logger, lock, parser, **kwargs): self._modules = kwargs self._declarations = {} self.ARG_PARSER = parser - + # Parse just the flags we care about, since this happens at import time. self._flags, _ = parser.parse_known_args() - - # Populate flag_values from flags now. self._flag_values = {} - for keyval in self._flags.config_value: - self._flag_values.setdefault(*keyval.split('=', 1)) + + # Populate flag_values from flags now. + self.load_flag_values() # Initialize self._loaded_values and load from --config-file if it's set. self.reset() + + def load_flag_values(self, flags=None): + """Load flag values given from command line flags. + + Args: + flags: An argparse Namespace containing the command line flags. + """ + if flags is None: + flags = self._flags + for keyval in flags.config_value: + self._flag_values.setdefault(*keyval.split('=', 1)) @staticmethod def _is_valid_key(key): diff --git a/openhtf/util/test.py b/openhtf/util/test.py index dc2261b3a..0347edf67 100644 --- a/openhtf/util/test.py +++ b/openhtf/util/test.py @@ -39,7 +39,7 @@ A few isolated examples, also see test/util/test_test.py for some usage: - from openhtf import conf + from openhtf.util import conf from openhtf.util import test import mytest # Contains phases under test. @@ -122,13 +122,13 @@ def test_multiple(self, mock_my_plug): import mock import openhtf -from openhtf import conf from openhtf import plugs from openhtf import util -from openhtf.exe import phase_executor -from openhtf.exe import test_state -from openhtf.io import test_record -from openhtf.util import measurements +from openhtf.core import measurements +from openhtf.core import phase_executor +from openhtf.core import test_record +from openhtf.core import test_state +from openhtf.util import conf class InvalidTestError(Exception): diff --git a/openhtf/io/user_input.py b/openhtf/util/user_input.py similarity index 100% rename from openhtf/io/user_input.py rename to openhtf/util/user_input.py diff --git a/setup.py b/setup.py index 8166a4946..0beb3df16 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ def run(self): targets = [ './dist', './*.egg-info', - './openhtf/io/proto/*_pb2.py', + './openhtf/output/proto/*_pb2.py', './openhtf/**/*.pyc', ] os.system('shopt -s globstar; rm -vrf %s' % ' '.join(targets)) @@ -68,8 +68,8 @@ def initialize_options(self): self.protoc = os.path.join(prefix, 'bin', 'protoc') self.protodir = os.path.join(prefix, 'include') - self.indir = os.path.join(os.getcwd(), 'openhtf', 'io', 'proto') - self.outdir = os.path.join(os.getcwd(), 'openhtf', 'io', 'proto') + self.indir = os.path.join(os.getcwd(), 'openhtf', 'output', 'proto') + self.outdir = os.path.join(os.getcwd(), 'openhtf', 'output', 'proto') def finalize_options(self): pass diff --git a/test/exe/exe_test.py b/test/core/exe_test.py similarity index 91% rename from test/exe/exe_test.py rename to test/core/exe_test.py index cc2c4cc03..e40a088ba 100644 --- a/test/exe/exe_test.py +++ b/test/core/exe_test.py @@ -18,9 +18,9 @@ import mock import openhtf -from openhtf import exe -from openhtf import conf +from openhtf import core from openhtf import plugs +from openhtf.util import conf class UnittestPlug(plugs.BasePlug): @@ -61,14 +61,14 @@ def test_plug_map(self): # Mock test execution. def test_test_executor(self): - mock_starter = mock.Mock(spec=exe.TestExecutor) + mock_starter = mock.Mock(spec=core.TestExecutor) mock_starter.start() mock_starter.wait() mock_starter.stop() def test_class_string(self): check_list = ['PhaseExecutorThread', 'phase_one'] - phase_thread = exe.phase_executor.PhaseExecutorThread(phase_one, ' ') + phase_thread = core.phase_executor.PhaseExecutorThread(phase_one, ' ') name = str(phase_thread) found = True for item in check_list: diff --git a/test/util/measurements_record.pickle b/test/core/measurements_record.pickle similarity index 55% rename from test/util/measurements_record.pickle rename to test/core/measurements_record.pickle index d19e63704d8a3db54dc934b3782f131f30675b81..85050ddf57ac0bee89f6a8a1050905a065eb1f47 100644 GIT binary patch delta 934 zcmdm{yI7CEfhjq^AT=+eBuy_lzbJJguO$nZ_ORwQH?*`cH8Hm^Fff_e=LHeI(*UL? zCon?PO`gkGuY^!&#uds|lv-SxQ&OmcZ0=-RrZ9-csZ7qo9S$Jta#ItFOM!|tK%B{s znfj3|G@o3{T!h58nEZ=bkF6Z6Z?YCkH03=9zE-E5}X z820%>EYD5NE74Fd$;d29QP$!rEjWU_c!($>I!U1zDYLNKwM6!UxW+~4mB;!msC-G`C za=`=LaPo9M1I`GT8I#ZOO^0Yp=09NwS7l(#70RDqT9TZfn;M^zT9TNVQ(SmBw(v-X zvZtX5T$$nK7=awdkef^l3Hz@BIWPbK delta 874 zcmY*Y%}*0S6z?vjrQ1R)4TeJ#OQM2`O+WZ*)P#r_t56Ub5{$`Y+YWTo?QUmh7AO}; zFh+xksdMn6A!_0u;3i%?OE`GaqoVlz?ZL#G2e&P4mziYp-f!Ofz2BRUhoL9OTUYtC zT0lyc&V?kk2I!TXSjF`Tm9d*J9lQ0E`77Rn=q_H@&%q-DB~^ac&yd3aB{5o-xpfj)NG z6?H$i=-hA}YDy?mY|CX>>h`m1!o|ud7_WpWD?>jU^7MJYKMTd0XO``F9$V4}jC-xe zIH7TP>_uC+d9u=m+k1yS@@_SvBSWm{3s{1U4WG=}mwB6w!S;3byZtB&`1`toyUjy_ z(yEdny+UyBV7ebVRGk)dYHa)0tf~iDu4AlxO;0;cuC&a_;ylcuB7O~oioGDpI>Ota z6DeX!MvzdEN~!`g5=pBINGswu*MYBwiUkQ4RE^@dNzf_EvbqR$g&+!d1(q*`;GG+w zogz`osEZ1uQXZMgAi?i0uq*omEAN3b9I8zGA^R-52|8=+^_r#%O;YCZN3d^Vax{5v z`Yb$?xHK{`GdeYkKLJ6dS){?Te*77@t6sH{FQBcO3o~d=EWg;Vz*#fD0gs|46ja~) zo&^59xCFBjp{iDdL|R5LpTa-JZJZ8V6cGv)F^}+1;F&Q0lPM%PZG!lhuBSr(0e8D3 AJpcdz diff --git a/test/util/measurements_test.py b/test/core/measurements_test.py similarity index 74% rename from test/util/measurements_test.py rename to test/core/measurements_test.py index 47756c618..d4a005189 100644 --- a/test/util/measurements_test.py +++ b/test/core/measurements_test.py @@ -23,11 +23,11 @@ import os.path import unittest -import openhtf.conf as conf import openhtf.util as util -from openhtf.io import output -from openhtf.names import * +import openhtf as htf +from openhtf.output import callbacks +from openhtf.util import conf from openhtf.util import data from openhtf.util import units @@ -41,18 +41,18 @@ # Phases copied from the measurements example in examples/, because they # cover the various ways a user might use measurements. -@measures(Measurement('hello_world_measurement')) +@htf.measures(htf.Measurement('hello_world_measurement')) def hello_phase(test): test.measurements.hello_world_measurement = 'Hello!' -@measures('hello_again_measurement') +@htf.measures('hello_again_measurement') def again_phase(test): test.measurements.hello_again_measurement = 'Again!' -@measures('first_measurement', 'second_measurement') -@measures(Measurement('third'), Measurement('fourth')) +@htf.measures('first_measurement', 'second_measurement') +@htf.measures(htf.Measurement('third'), htf.Measurement('fourth')) def lots_of_measurements(test): test.measurements.first_measurement = 'First!' test.measurements['second_measurement'] = 'Second :(' @@ -60,22 +60,22 @@ def lots_of_measurements(test): test.measurements[measurement] = measurement + ' is the best!' -@measures(Measurement('validated_measurement').InRange(0, 10).doc( +@htf.measures(htf.Measurement('validated_measurement').in_range(0, 10).doc( 'This measurement is validated.').with_units(units.SECOND)) def measure_seconds(test): test.measurements.validated_measurement = 5 -@measures(Measurement('dimensioned_measurement').with_dimensions( +@htf.measures(htf.Measurement('dimensioned_measurement').with_dimensions( units.SECOND, units.HERTZ)) -@measures('unset_dimensions', dimensions=(units.SECOND, units.HERTZ)) +@htf.measures('unset_dimensions', dimensions=(units.SECOND, units.HERTZ)) def measure_dimensions(test): test.measurements.dimensioned_measurement[1, 2] = 5 -@measures('inline_kwargs', docstring='This measurement is declared inline!', +@htf.measures('inline_kwargs', docstring='This measurement is declared inline!', units=units.HERTZ, validators=[util.validators.InRange(0, 10)]) -@measures('another_inline', docstring='Because why not?') +@htf.measures('another_inline', docstring='Because why not?') def inline_phase(test): test.measurements.inline_kwargs = 15 test.measurements.another_inline = 'This one is unvalidated.' @@ -87,25 +87,25 @@ class TestMeasurements(unittest.TestCase): @classmethod def setUpClass(cls): - conf.load(station_id='measurements_test', station_api_port=None) if not cls.UPDATE_OUTPUT: with open(RECORD_FILENAME, 'rb') as picklefile: cls.record = pickle.load(picklefile) def test_unit_enforcement(self): """Creating a measurement with invalid units should raise.""" - self.assertRaises(TypeError, Measurement('bad_units').with_units, 1701) + self.assertRaises(TypeError, htf.Measurement('bad_units').with_units, 1701) + @conf.save_and_restore(station_id='measurements_test', station_api_port=None) def test_measurements(self): result = util.NonLocalResult() def _save_result(test_record): result.result = test_record - Test.uid = 'UNITTEST:MOCK:UID' - test = Test(hello_phase, again_phase, lots_of_measurements, measure_seconds, - measure_dimensions, inline_phase) + htf.Test.uid = 'UNITTEST:MOCK:UID' + test = htf.Test(hello_phase, again_phase, lots_of_measurements, + measure_seconds, measure_dimensions, inline_phase) if self.UPDATE_OUTPUT: - test.add_output_callbacks(output.OutputToFile(RECORD_FILENAME)) + test.add_output_callbacks(callbacks.OutputToFile(RECORD_FILENAME)) else: test.add_output_callbacks(_save_result) test.execute(test_start=lambda: 'TestDUT') diff --git a/test/util/monitors_test.py b/test/core/monitors_test.py similarity index 98% rename from test/util/monitors_test.py rename to test/core/monitors_test.py index 78a0baa89..fda1279e9 100644 --- a/test/util/monitors_test.py +++ b/test/core/monitors_test.py @@ -17,7 +17,7 @@ import mock from openhtf import plugs -from openhtf.util import monitors +from openhtf.core import monitors class EmptyPlug(plugs.BasePlug): diff --git a/test/io/output/output_test.py b/test/output/callbacks/callbacks_test.py similarity index 95% rename from test/io/output/output_test.py rename to test/output/callbacks/callbacks_test.py index c1f16a4f4..54a4b1d0f 100644 --- a/test/io/output/output_test.py +++ b/test/output/callbacks/callbacks_test.py @@ -39,9 +39,9 @@ def _pickle(test_record): import google.protobuf.text_format as text_format -from openhtf.io.output import json_factory -from openhtf.io.output import mfg_inspector -from openhtf.io.proto import test_runs_pb2 +from openhtf.output.callbacks import json_factory +from openhtf.output.callbacks import mfg_inspector +from openhtf.output.proto import test_runs_pb2 from openhtf.util import data diff --git a/test/io/output/record.json b/test/output/callbacks/record.json similarity index 68% rename from test/io/output/record.json rename to test/output/callbacks/record.json index c725924f6..8df76e207 100644 --- a/test/io/output/record.json +++ b/test/output/callbacks/record.json @@ -2,41 +2,41 @@ "code_info": { "docstring": "Example OpenHTF test logic.\n\nRun with (your virtualenv must be activated first):\npython all_the_things.py", "name": "all_the_things.py", - "sourcecode": "# Copyright 2014 Google Inc. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Example OpenHTF test logic.\n\nRun with (your virtualenv must be activated first):\npython all_the_things.py\n\"\"\"\n\nimport json\nimport os\nimport time\n\nimport example_plug\nimport openhtf\n\nfrom openhtf.io import output\nfrom openhtf.io.output import json_factory\nfrom openhtf.io.output import mfg_inspector\nfrom openhtf.names import *\n# Uncomment for mfg-inspector output, requires setup.py build_proto.\n#from openhtf.io.output import mfg_inspector\nfrom openhtf.util import units\n\n\n@plug(example=example_plug.ExamplePlug)\ndef example_monitor(example):\n time.sleep(.2)\n return example.Increment()\n" + "sourcecode": "# Copyright 2014 Google Inc. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Example OpenHTF test logic.\n\nRun with (your virtualenv must be activated first):\npython all_the_things.py\n\"\"\"\n\nimport json\nimport os\nimport time\n\nimport openhtf as htf\nfrom openhtf.output.callbacks import OutputToFile\nfrom openhtf.output.callbacks.json_factory import OutputToJSON\n# Uncomment the following line for Testrun output.\n# from openhtf.output.callbacks.mfg_inspector import OutputToTestRunProto\nfrom openhtf.plugs import user_input\nfrom openhtf.util import units\n\nimport example_plug\n\n\n@htf.plug(example=example_plug.ExamplePlug)\ndef example_monitor(example):\n time.sleep(.2)\n return example.increment()\n" }, "dut_id": "TestDUT", - "end_time_millis": 1469817115604, + "end_time_millis": 1471981975722, "log_records": [ { "level": 20, "lineno": 54, - "logger_name": "openhtf.test_record.19894:1469817107163:140397771233168", + "logger_name": "openhtf.test_record.25870:1471981964613:140039026113872", "message": "Hello World!", "source": "all_the_things.py", - "timestamp_millis": 1469817110391 + "timestamp_millis": 1471981967851 }, { "level": 20, "lineno": 61, - "logger_name": "openhtf.test_record.19894:1469817107163:140397771233168", + "logger_name": "openhtf.test_record.25870:1471981964613:140039026113872", "message": "Plug value: 0", "source": "all_the_things.py", - "timestamp_millis": 1469817112550 + "timestamp_millis": 1471981972631 }, { "level": 10, - "lineno": 272, - "logger_name": "openhtf.test_record.19894:1469817107163:140397771233168", + "lineno": 279, + "logger_name": "openhtf.test_record.25870:1471981964613:140039026113872", "message": "Finishing test execution normally with outcome FAIL.", "source": "test_state.py", - "timestamp_millis": 1469817115604 + "timestamp_millis": 1471981975721 } ], "metadata": { "config": { "allow_unset_measurements": false, "enable_station_discovery": true, - "example_plug_increment": 1, + "example_plug_increment_size": 1, "max_history_size_mb": 256, "station_api_bind_address": "0.0.0.0", "station_api_port": 8888, @@ -56,9 +56,9 @@ "codeinfo": { "docstring": "A hello world test phase.", "name": "hello_world", - "sourcecode": "@measures(\n Measurement('unset_meas'),\n Measurement(\n 'widget_type').MatchesRegex(r'.*Widget$').Doc(\n '''This measurement tracks the type of widgets.'''),\n Measurement(\n 'widget_color').Doc('Color of the widget'),\n Measurement('widget_size').InRange(1, 4))\n@plug(example=example_plug.ExamplePlug)\ndef hello_world(test, example):\n \"\"\"A hello world test phase.\"\"\"\n test.logger.info('Hello World!')\n test.measurements.widget_type = prompts.DisplayPrompt(\n 'What\\'s the widget type?', text_input=True)\n if test.measurements.widget_type == 'raise':\n raise Exception()\n test.measurements.widget_color = 'Black'\n test.measurements.widget_size = 3\n test.logger.info('Plug value: %s', example.Increment())\n" + "sourcecode": "@htf.measures(\n htf.Measurement('unset_meas'),\n htf.Measurement(\n 'widget_type').matches_regex(r'.*Widget$').doc(\n '''This measurement tracks the type of widgets.'''),\n htf.Measurement(\n 'widget_color').doc('Color of the widget'),\n htf.Measurement('widget_size').in_range(1, 4))\n@htf.plug(example=example_plug.ExamplePlug)\n@htf.plug(prompts=user_input.UserInput)\ndef hello_world(test, example, prompts):\n \"\"\"A hello world test phase.\"\"\"\n test.logger.info('Hello World!')\n test.measurements.widget_type = prompts.prompt(\n 'What\\'s the widget type?', text_input=True)\n if test.measurements.widget_type == 'raise':\n raise Exception()\n test.measurements.widget_color = 'Black'\n test.measurements.widget_size = 3\n test.logger.info('Plug value: %s', example.increment())\n" }, - "end_time_millis": 1469817112560, + "end_time_millis": 1471981972676, "measurements": { "unset_meas": { "name": "unset_meas", @@ -92,16 +92,16 @@ "result": { "phase_result": "CONTINUE" }, - "start_time_millis": 1469817110391 + "start_time_millis": 1471981967850 }, { "attachments": {}, "codeinfo": { "docstring": "Test phase that sets a measurement.", "name": "set_measurements", - "sourcecode": " @openhtf.PhaseOptions(requires_state=True)\n @plugs.plug(update_kwargs=False, **monitor_plugs)\n @measurements.measures(\n measurements.Measurement(measurement_name).WithUnits(\n units).WithDimensions(uom.MILLISECOND))\n @functools.wraps(phase_desc.func)\n def MonitoredPhaseFunc(test_state, *args, **kwargs):\n # Start monitor thread, it will run monitor_desc periodically.\n monitor_thread = _MonitorThread(\n measurement_name, monitor_desc, phase_desc.extra_kwargs, test_state,\n poll_interval_ms)\n monitor_thread.start()\n try:\n return phase_desc(test_state, *args, **kwargs)\n finally:\n monitor_thread.Kill()\n" + "sourcecode": " @openhtf.PhaseOptions(requires_state=True)\n @plugs.plug(update_kwargs=False, **monitor_plugs)\n @measurements.measures(\n measurements.Measurement(measurement_name).with_units(\n units).with_dimensions(uom.MILLISECOND))\n @functools.wraps(phase_desc.func)\n def monitored_phase_func(test_state, *args, **kwargs):\n # Start monitor thread, it will run monitor_desc periodically.\n monitor_thread = _MonitorThread(\n measurement_name, monitor_desc, phase_desc.extra_kwargs, test_state,\n poll_interval_ms)\n monitor_thread.start()\n try:\n return phase_desc(test_state, *args, **kwargs)\n finally:\n monitor_thread.kill()\n" }, - "end_time_millis": 1469817115584, + "end_time_millis": 1471981975700, "measurements": { "level_all": { "measured_value": 9, @@ -128,19 +128,19 @@ ], "measured_value": [ [ - 200.5770206451416, + 200.88601112365723, 1 ], [ - 1000.615119934082, + 1000.6160736083984, 2 ], [ - 2000.8540153503418, + 2000.6470680236816, 3 ], [ - 3000.8180141448975, + 3000.675916671753, 4 ] ], @@ -157,16 +157,16 @@ "result": { "phase_result": "CONTINUE" }, - "start_time_millis": 1469817112562 + "start_time_millis": 1471981972678 }, { "attachments": {}, "codeinfo": { "docstring": null, "name": "dimensions", - "sourcecode": "@measures(\n Measurement('unset_dims').WithDimensions(units.HERTZ),\n Measurement('dimensions').WithDimensions(units.HERTZ),\n Measurement('lots_of_dims').WithDimensions(\n units.HERTZ, units.SECOND, units.RADIAN))\ndef dimensions(test):\n for dim in range(5):\n test.measurements.dimensions[dim] = 1 << dim\n for x, y, z in zip(range(1, 5), range(21, 25), range (101, 105)):\n test.measurements.lots_of_dims[x, y, z] = x + y + z\n" + "sourcecode": "@htf.measures(\n htf.Measurement('unset_dims').with_dimensions(units.HERTZ),\n htf.Measurement('dimensions').with_dimensions(units.HERTZ),\n htf.Measurement('lots_of_dims').with_dimensions(\n units.HERTZ, units.SECOND, units.RADIAN))\ndef dimensions(test):\n for dim in range(5):\n test.measurements.dimensions[dim] = 1 << dim\n for x, y, z in zip(range(1, 5), range(21, 25), range (101, 105)):\n test.measurements.lots_of_dims[x, y, z] = x + y + z\n" }, - "end_time_millis": 1469817115587, + "end_time_millis": 1471981975704, "measurements": { "dimensions": { "dimensions": [ @@ -264,7 +264,7 @@ "result": { "phase_result": "CONTINUE" }, - "start_time_millis": 1469817115584 + "start_time_millis": 1471981975702 }, { "attachments": { @@ -282,15 +282,15 @@ "name": "attachments", "sourcecode": "def attachments(test):\n test.attach('test_attachment', 'This is test attachment data.')\n test.attach_from_file('example_attachment.txt')\n" }, - "end_time_millis": 1469817115604, + "end_time_millis": 1471981975721, "measurements": {}, "name": "attachments", "result": { "phase_result": "CONTINUE" }, - "start_time_millis": 1469817115587 + "start_time_millis": 1471981975705 } ], - "start_time_millis": 1469817110389, + "start_time_millis": 1471981967848, "station_id": "jethier.mtv.corp.google.com" } \ No newline at end of file diff --git a/test/io/output/record.pickle b/test/output/callbacks/record.pickle similarity index 68% rename from test/io/output/record.pickle rename to test/output/callbacks/record.pickle index b418717dc..e16c3fdac 100644 --- a/test/io/output/record.pickle +++ b/test/output/callbacks/record.pickle @@ -1,7 +1,7 @@ ccopy_reg _reconstructor p1 -(copenhtf.io.test_record +(copenhtf.core.test_record TestRecord p2 c__builtin__ @@ -13,7 +13,7 @@ S'phases' p6 (lp7 g1 -(copenhtf.io.test_record +(copenhtf.core.test_record PhaseRecord p8 g3 @@ -21,7 +21,7 @@ NtRp9 (dp10 S'start_time_millis' p11 -I1469817110391 +I1471981967850 sS'attachments' p12 (dp13 @@ -31,7 +31,7 @@ p14 S'widget_type' p16 g1 -(copenhtf.util.measurements +(copenhtf.core.measurements Measurement p17 g3 @@ -72,7 +72,7 @@ sbasS'units' p34 NsS'outcome' p35 -copenhtf.util.measurements +copenhtf.core.measurements Outcome p36 (I1 @@ -80,7 +80,7 @@ tRp37 sS'measured_value' p38 g1 -(copenhtf.util.measurements +(copenhtf.core.measurements MeasuredValue p39 g3 @@ -203,11 +203,11 @@ I3 sbsg45 NsbssS'end_time_millis' p72 -I1469817112560 +I1471981972676 sS'result' p73 g1 -(copenhtf.exe.phase_executor +(copenhtf.core.phase_executor PhaseOutcome p74 c__builtin__ @@ -222,7 +222,7 @@ ttRp78 sS'codeinfo' p79 g1 -(copenhtf.io.test_record +(copenhtf.core.test_record CodeInfo p80 g3 @@ -236,7 +236,7 @@ S'hello_world' p84 sS'sourcecode' p85 -S'@measures(\n Measurement(\'unset_meas\'),\n Measurement(\n \'widget_type\').MatchesRegex(r\'.*Widget$\').Doc(\n \'\'\'This measurement tracks the type of widgets.\'\'\'),\n Measurement(\n \'widget_color\').Doc(\'Color of the widget\'),\n Measurement(\'widget_size\').InRange(1, 4))\n@plug(example=example_plug.ExamplePlug)\ndef hello_world(test, example):\n """A hello world test phase."""\n test.logger.info(\'Hello World!\')\n test.measurements.widget_type = prompts.DisplayPrompt(\n \'What\\\'s the widget type?\', text_input=True)\n if test.measurements.widget_type == \'raise\':\n raise Exception()\n test.measurements.widget_color = \'Black\'\n test.measurements.widget_size = 3\n test.logger.info(\'Plug value: %s\', example.Increment())\n' +S'@htf.measures(\n htf.Measurement(\'unset_meas\'),\n htf.Measurement(\n \'widget_type\').matches_regex(r\'.*Widget$\').doc(\n \'\'\'This measurement tracks the type of widgets.\'\'\'),\n htf.Measurement(\n \'widget_color\').doc(\'Color of the widget\'),\n htf.Measurement(\'widget_size\').in_range(1, 4))\n@htf.plug(example=example_plug.ExamplePlug)\n@htf.plug(prompts=user_input.UserInput)\ndef hello_world(test, example, prompts):\n """A hello world test phase."""\n test.logger.info(\'Hello World!\')\n test.measurements.widget_type = prompts.prompt(\n \'What\\\'s the widget type?\', text_input=True)\n if test.measurements.widget_type == \'raise\':\n raise Exception()\n test.measurements.widget_color = \'Black\'\n test.measurements.widget_size = 3\n test.logger.info(\'Plug value: %s\', example.increment())\n' p86 sbsg20 g84 @@ -246,7 +246,7 @@ g3 NtRp87 (dp88 g11 -I1469817112562 +I1471981972678 sg12 (dp89 sg14 @@ -277,7 +277,7 @@ sg35 g37 sg38 g1 -(copenhtf.util.measurements +(copenhtf.core.measurements DimensionedMeasuredValue p98 g3 @@ -290,19 +290,19 @@ OrderedDict p102 ((lp103 (lp104 -(F200.5770206451416 +(F200.88601112365723 tp105 aI1 aa(lp106 -(F1000.615119934082 +(F1000.6160736083984 tp107 aI2 aa(lp108 -(F2000.8540153503418 +(F2000.6470680236816 tp109 aI3 aa(lp110 -(F3000.8180141448975 +(F3000.6759166717529 tp111 aI4 aatRp112 @@ -413,7 +413,7 @@ sg43 I8 sbsg45 Nsbssg72 -I1469817115584 +I1471981975700 sg73 g1 (g74 @@ -433,7 +433,7 @@ sg20 S'set_measurements' p142 sg85 -S' @openhtf.PhaseOptions(requires_state=True)\n @plugs.plug(update_kwargs=False, **monitor_plugs)\n @measurements.measures(\n measurements.Measurement(measurement_name).WithUnits(\n units).WithDimensions(uom.MILLISECOND))\n @functools.wraps(phase_desc.func)\n def MonitoredPhaseFunc(test_state, *args, **kwargs):\n # Start monitor thread, it will run monitor_desc periodically.\n monitor_thread = _MonitorThread(\n measurement_name, monitor_desc, phase_desc.extra_kwargs, test_state,\n poll_interval_ms)\n monitor_thread.start()\n try:\n return phase_desc(test_state, *args, **kwargs)\n finally:\n monitor_thread.Kill()\n' +S' @openhtf.PhaseOptions(requires_state=True)\n @plugs.plug(update_kwargs=False, **monitor_plugs)\n @measurements.measures(\n measurements.Measurement(measurement_name).with_units(\n units).with_dimensions(uom.MILLISECOND))\n @functools.wraps(phase_desc.func)\n def monitored_phase_func(test_state, *args, **kwargs):\n # Start monitor thread, it will run monitor_desc periodically.\n monitor_thread = _MonitorThread(\n measurement_name, monitor_desc, phase_desc.extra_kwargs, test_state,\n poll_interval_ms)\n monitor_thread.start()\n try:\n return phase_desc(test_state, *args, **kwargs)\n finally:\n monitor_thread.kill()\n' p143 sbsg20 g142 @@ -443,7 +443,7 @@ g3 NtRp144 (dp145 g11 -I1469817115584 +I1471981975702 sg12 (dp146 sg14 @@ -633,7 +633,7 @@ g166 ttRp202 tp203 sbssg72 -I1469817115587 +I1471981975704 sg73 g1 (g74 @@ -650,7 +650,7 @@ g21 Nsg20 g45 sg85 -S"@measures(\n Measurement('unset_dims').WithDimensions(units.HERTZ),\n Measurement('dimensions').WithDimensions(units.HERTZ),\n Measurement('lots_of_dims').WithDimensions(\n units.HERTZ, units.SECOND, units.RADIAN))\ndef dimensions(test):\n for dim in range(5):\n test.measurements.dimensions[dim] = 1 << dim\n for x, y, z in zip(range(1, 5), range(21, 25), range (101, 105)):\n test.measurements.lots_of_dims[x, y, z] = x + y + z\n" +S"@htf.measures(\n htf.Measurement('unset_dims').with_dimensions(units.HERTZ),\n htf.Measurement('dimensions').with_dimensions(units.HERTZ),\n htf.Measurement('lots_of_dims').with_dimensions(\n units.HERTZ, units.SECOND, units.RADIAN))\ndef dimensions(test):\n for dim in range(5):\n test.measurements.dimensions[dim] = 1 << dim\n for x, y, z in zip(range(1, 5), range(21, 25), range (101, 105)):\n test.measurements.lots_of_dims[x, y, z] = x + y + z\n" p207 sbsg20 g45 @@ -660,13 +660,13 @@ g3 NtRp208 (dp209 g11 -I1469817115587 +I1471981975705 sg12 (dp210 S'test_attachment' p211 g1 -(copenhtf.io.test_record +(copenhtf.core.test_record Attachment p212 g75 @@ -686,7 +686,7 @@ ttRp218 ssg14 (dp219 sg72 -I1469817115604 +I1471981975721 sg73 g1 (g74 @@ -708,12 +708,12 @@ p223 sbsg20 g12 sbasg11 -I1469817110389 +I1471981967848 sS'outcome_details' p224 (lp225 sg72 -I1469817115604 +I1471981975722 sS'station_id' p226 S'jethier.mtv.corp.google.com' @@ -736,7 +736,7 @@ sg20 S'all_the_things.py' p234 sg85 -S'# Copyright 2014 Google Inc. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the "License");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an "AS IS" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n"""Example OpenHTF test logic.\n\nRun with (your virtualenv must be activated first):\npython all_the_things.py\n"""\n\nimport json\nimport os\nimport time\n\nimport example_plug\nimport openhtf\n\nfrom openhtf.io import output\nfrom openhtf.io.output import json_factory\nfrom openhtf.io.output import mfg_inspector\nfrom openhtf.names import *\n# Uncomment for mfg-inspector output, requires setup.py build_proto.\n#from openhtf.io.output import mfg_inspector\nfrom openhtf.util import units\n\n\n@plug(example=example_plug.ExamplePlug)\ndef example_monitor(example):\n time.sleep(.2)\n return example.Increment()\n' +S'# Copyright 2014 Google Inc. All Rights Reserved.\n\n# Licensed under the Apache License, Version 2.0 (the "License");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n\n# http://www.apache.org/licenses/LICENSE-2.0\n\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an "AS IS" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n"""Example OpenHTF test logic.\n\nRun with (your virtualenv must be activated first):\npython all_the_things.py\n"""\n\nimport json\nimport os\nimport time\n\nimport openhtf as htf\nfrom openhtf.output.callbacks import OutputToFile\nfrom openhtf.output.callbacks.json_factory import OutputToJSON\n# Uncomment the following line for Testrun output.\n# from openhtf.output.callbacks.mfg_inspector import OutputToTestRunProto\nfrom openhtf.plugs import user_input\nfrom openhtf.util import units\n\nimport example_plug\n\n\n@htf.plug(example=example_plug.ExamplePlug)\ndef example_monitor(example):\n time.sleep(.2)\n return example.increment()\n' p235 sbsS'log_records' p236 @@ -747,12 +747,12 @@ LogRecord p238 g75 (I20 -S'openhtf.test_record.19894:1469817107163:140397771233168' +S'openhtf.test_record.25870:1471981964613:140039026113872' p239 S'all_the_things.py' p240 I54 -I1469817110391 +I1471981967851 VHello World! p241 ttRp242 @@ -763,7 +763,7 @@ g75 g239 g240 I61 -I1469817112550 +I1471981972631 VPlug value: 0 p243 ttRp244 @@ -774,13 +774,13 @@ g75 g239 S'test_state.py' p245 -I272 -I1469817115604 +I279 +I1471981975721 VFinishing test execution normally with outcome FAIL. p246 ttRp247 asg35 -copenhtf.io.test_record +copenhtf.core.test_record Outcome p248 (I2 @@ -807,13 +807,13 @@ I00 sS'teardown_timeout_s' p259 I3 -sS'station_api_bind_address' +sS'example_plug_increment_size' p260 -S'0.0.0.0' +I1 +sS'station_api_bind_address' p261 -sS'example_plug_increment' +S'0.0.0.0' p262 -I1 sg226 g227 sS'station_discovery_string' diff --git a/test/io/output/record.testrun b/test/output/callbacks/record.testrun similarity index 67% rename from test/io/output/record.testrun rename to test/output/callbacks/record.testrun index a424a63933b7d3dbb1db128e8949766d667933f6..6167b9b98d3611f35073c907b1921d9e0e690adc 100644 GIT binary patch delta 2149 zcma)7U2NM_6qZw(HtxEnX_wHhX}$iWNg6!=#dg}Y8)8&#LA2XCF_jK4OPthQVq3Pe zu5{`qgm?lp=^|Rh-vdt+ggW^NsgDRGUKl(Sh5*5yfJq=E9;lEI_c~6S7Imwm$hqg- zbI$#~bH9@>Z(<+4h^=4sdU;Aof7GkkQ5jOjQX`6CMgQkAkCHS zJjc^4Tu~I8q8Og0Sy5oXo#r6;-GA1N$ALc)Bpz{o%m@3z z#k7@~lTCQ*^76H)(ND&oRkC^6>g|t_S@2=-smj()Uq&lvhGPzg+zda9M}vwg8EG{y zN9hE?#bP@oMULJ1u)HMEDYfy9In4TEcXje$<1(CUI?C z1tP->JQ$Dm+AD3#HC60WkbTj<5I%}U78GkvDyfQ9!HY1X$Fapo$Dai&oliFxHMmVP zOh1d1TzITj<&H05MI^W@W_6iZzCOUjJ*|ka=RwP#@XZ1AL=THfCk23X%*=(|OeF~VVuE;%rYMT!=_<++1cMxm z<8X(l!(4)3k%M&{?m$HZ+LzhyJx6}A?|yziKDPEJdd=kP@1r$1$M+pbKX36JwJUc~ z#0DQ3JAm$q)_60VuM!-5@C%2YN$QK#u-H2D3ReGtbBF*3CCP#3g&=>Bgm}Esf&)%6 zt+XYhWGi4zh{eA0;tg{$oUGDqQXN&ly)9r1hEkF~hplr70cj5eBqPinzNm;|w*m;0(z?x06}pl7$pzaEk3G!;!X19xinV}6$aJIW(+m-Jj)mFN~n Z+Ob1#IEDPH=mp+8`F`V@WkdP?{0BYju3rEE delta 2024 zcma)6TWs4@7?x9d^VT&@*Q6~?bJC`{Esbo)j-AqtO3S8|QYjQlQOOjA)Ja?=cCejo zT}Qj|G7v&k`yW7)CKx>MGQ=hH0f|c`Bp%^~y-byWF~JjTLP89IfaADHn+{dYi*x?} z`)}X*zjNb7;+u=a2WMJZIGT>dB5&WuDTa!&91OI+(I#*#MRO4jJ~a-sK+!DC zLb7eS^R9(#$tZGG%8lKzER*nlcL;3l$6&VoPs`g0NRYjjmlBml@>bKTcrINm6~t7j zP|hV~saR4}9VsPI&g9g%B^3v1 zqFyeAOH1gvvQ$_|l~hGn!Z=G-4Kz%*tNn(KV6oHFl$0mnM&}|i2@dP=1JRg3^EAyx zDHcSlGEB#W7&}I@rk&#HXat|ANQ~!snu$c{r~r4n?9kCQLvF=lCrDkHeTGW4k_^XD zu-G*SmuwD#fj7HG_nE;C|Ju&fvQ!(t*nO>iXbjOIL?Q&q_K`~BaHplSD5kYC=FXp# z5&pr7&<|_&7C7PIm=n+WRbMzbCoSYe-Qx>{%- z$CU!UAtj6SyokG49dtGkqydIxpfZlk!Yj&WV297#j$f#E0N-M;{FK zF1N)ctyD-aB`Q~YEd;)fYkh2uQih9y%RTZ@|4LJBP|Px2dD;0Sad1x3^Ru#~8*{;> z@$P2B5QnSd4};T1cTOwVr>NpWBA?d8la-X~GC@qi&nR3=#c={#LGHIK9d$8c*+t>& z;gh7PRF)DLaCzb#HGNVMmKLC7ShhsU3NfCmYzJ@U)Al#wj*~xSeTW%jT3lyh4CJ$Z?zD^`*ejIeTaO4xexc4AzA;z#XhP{Ew5Q-R%NY&9m=$*)>rRVp5KK|mz;HhulUB{pK zT-zVU8E!^L_N5RfKhXTsYd92+@!ow!T;`o^W-%L!#l^z+ygj;)mjIE$4qeprl%}V3 z5kF4U8ia&^`_&fmKwc~ql+;;8EiBl6X`ZMr16F8NiY~Y=c+g%F#KI%t2m3^`8FF24 z!sD?vA`Y`L*O7)z*-Le#@!EL_67D;k;2cxyvV*m;zqm;`ql#7O1_I>JA(QE#^`1dr z@HTO)nY0>rmhfw*?17br%uc~H6I973EL4$`F-0(YJ%G