|
|
@ -54,7 +54,9 @@ def parse_cli_arguments(): |
|
|
|
|
|
|
|
|
|
|
|
def parse_gui_arguments(): |
|
|
|
def parse_gui_arguments(): |
|
|
|
from gooey import GooeyParser |
|
|
|
from gooey import GooeyParser |
|
|
|
|
|
|
|
|
|
|
|
""" parses command line interface arguments """ |
|
|
|
""" parses command line interface arguments """ |
|
|
|
|
|
|
|
desktop_path = Path.home() / "Desktop" |
|
|
|
parser = GooeyParser( |
|
|
|
parser = GooeyParser( |
|
|
|
description="Make time series measurements with a Sartorius scale.", |
|
|
|
description="Make time series measurements with a Sartorius scale.", |
|
|
|
epilog=( |
|
|
|
epilog=( |
|
|
@ -63,10 +65,36 @@ def parse_gui_arguments(): |
|
|
|
"A relative directory path starts at the Desktop." |
|
|
|
"A relative directory path starts at the Desktop." |
|
|
|
), |
|
|
|
), |
|
|
|
) |
|
|
|
) |
|
|
|
parser.add_argument("port", nargs="?", default="COM4", metavar="COMPORT", help="Serial Port that connects the Scale, defaults to 'COM4'") |
|
|
|
parser.add_argument( |
|
|
|
parser.add_argument("-d", "--duration", nargs="?", default="30m", help="Measurement duration, e.g. 10s, 30m, 2h") |
|
|
|
"port", |
|
|
|
parser.add_argument("-i", "--interval", nargs="?", default="10s", help="Measurement interval, e.g. 5s, 1m, 1h") |
|
|
|
nargs="?", |
|
|
|
parser.add_argument("-o", "--output", nargs="?", metavar="DIRECTORY", widget='DirChooser', help="Select Output Directory, defaults to 'Desktop'") |
|
|
|
default="COM4", |
|
|
|
|
|
|
|
metavar="COMPORT", |
|
|
|
|
|
|
|
help="Serial Port that connects the Scale, defaults to 'COM4'", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
parser.add_argument( |
|
|
|
|
|
|
|
"-d", |
|
|
|
|
|
|
|
"--duration", |
|
|
|
|
|
|
|
nargs="?", |
|
|
|
|
|
|
|
default="30m", |
|
|
|
|
|
|
|
help="Measurement duration, e.g. 10s, 30m, 2h", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
parser.add_argument( |
|
|
|
|
|
|
|
"-i", |
|
|
|
|
|
|
|
"--interval", |
|
|
|
|
|
|
|
nargs="?", |
|
|
|
|
|
|
|
default="10s", |
|
|
|
|
|
|
|
help="Measurement interval, e.g. 5s, 1m, 1h", |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
parser.add_argument( |
|
|
|
|
|
|
|
"-o", |
|
|
|
|
|
|
|
"--output", |
|
|
|
|
|
|
|
nargs="?", |
|
|
|
|
|
|
|
metavar="DIRECTORY", |
|
|
|
|
|
|
|
widget="DirChooser", |
|
|
|
|
|
|
|
help="Select Output Directory, defaults to 'Desktop'", |
|
|
|
|
|
|
|
gooey_options={"default_path": str(desktop_path)}, |
|
|
|
|
|
|
|
) |
|
|
|
raw_arguments = parser.parse_args() |
|
|
|
raw_arguments = parser.parse_args() |
|
|
|
return _normalize_cli_arguments(raw_arguments) |
|
|
|
return _normalize_cli_arguments(raw_arguments) |
|
|
|
|
|
|
|
|
|
|
@ -91,11 +119,11 @@ def _normalize_cli_arguments(raw_arguments): |
|
|
|
# directory stuff |
|
|
|
# directory stuff |
|
|
|
dir_path = _check_output_directory_path(raw_arguments.output) |
|
|
|
dir_path = _check_output_directory_path(raw_arguments.output) |
|
|
|
|
|
|
|
|
|
|
|
measurements = 1 + ( |
|
|
|
measurements = 1 + (duration.seconds // interval.seconds) |
|
|
|
duration.seconds // interval.seconds |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Settings(duration, interval, dir_path, raw_arguments.port, measurements) |
|
|
|
return Settings( |
|
|
|
|
|
|
|
duration, interval, dir_path, raw_arguments.port, measurements |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _check_output_directory_path(raw_path): |
|
|
|
def _check_output_directory_path(raw_path): |
|
|
|