From 95f250442a4c6e9e30870342ab833c744efd9d83 Mon Sep 17 00:00:00 2001 From: halkver Date: Fri, 18 Oct 2019 14:56:29 +0200 Subject: [PATCH 1/5] Add check for application version string format --- nordicsemi/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index 1df882d..592805a 100755 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -1240,6 +1240,8 @@ def ant(package, port, connect_delay, packet_receipt_notification, period, def convert_version_string_to_int(s): """Convert from semver string "1.2.3", to integer 10203""" numbers = s.split(".") + if len(numbers) != 3: + raise click.BadParameter("Must be on the format x.y.z", param_hint='application-version-string') js = [10000, 100, 1] return sum([js[i] * int(numbers[i]) for i in range(3)]) From d83cd9659959604768bf4c10db78fb7002481488 Mon Sep 17 00:00:00 2001 From: halkver Date: Fri, 18 Oct 2019 15:19:14 +0200 Subject: [PATCH 2/5] Add warning when application version is provided with both int and str --- nordicsemi/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index 592805a..553223a 100755 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -329,6 +329,8 @@ def generate(hex_file, # "10.21.30". Internally we convert to integer. if application_version_string: application_version_internal = convert_version_string_to_int(application_version_string) + if application_version: + click.echo('Warning: When both application-version-string and application-version are provided, only the string will be used.') else: application_version_internal = application_version @@ -658,6 +660,8 @@ def generate(zipfile, # "10.21.30". Internally we convert to integer. if application_version_string: application_version_internal = convert_version_string_to_int(application_version_string) + if application_version: + click.echo('Warning: When both application-version-string and application-version are provided, only the string will be used.') else: application_version_internal = application_version From 23eeff6c8f43c886120697aeac37f53eafecd4de Mon Sep 17 00:00:00 2001 From: halkver Date: Fri, 18 Oct 2019 15:24:54 +0200 Subject: [PATCH 3/5] Add integer conversion description in help for application-version-string --- nordicsemi/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index 553223a..84151ff 100755 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -263,7 +263,7 @@ def settings(): help='The application version.', type=BASED_INT_OR_NONE) @click.option('--application-version-string', - help='The application version string, e.g "2.7.31".', + help='The application version string, e.g "2.7.31". Will be converted to an integer, e.g 207031.', type=click.STRING) @click.option('--bootloader-version', help='The bootloader version.', @@ -490,7 +490,7 @@ def pkg(): help='The application version.', type=BASED_INT_OR_NONE) @click.option('--application-version-string', - help='The application version string, e.g "2.7.31".', + help='The application version string, e.g "2.7.31". Will be converted to an integer, e.g 207031.', type=click.STRING) @click.option('--bootloader', help='The bootloader firmware file.', From 383731c63488fbeff658d8e8c42de6b65fe38536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Inge=20Hanssen?= Date: Fri, 18 Oct 2019 15:44:36 +0200 Subject: [PATCH 4/5] Update nordicsemi/__main__.py --- nordicsemi/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index 84151ff..91d6e75 100755 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -263,7 +263,7 @@ def settings(): help='The application version.', type=BASED_INT_OR_NONE) @click.option('--application-version-string', - help='The application version string, e.g "2.7.31". Will be converted to an integer, e.g 207031.', + help='The application version string, e.g. "2.7.31". Will be converted to an integer, e.g. 207031.', type=click.STRING) @click.option('--bootloader-version', help='The bootloader version.', From fd6467878d8de7ae194ff12ad45a5e7963ab7fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Inge=20Hanssen?= Date: Fri, 18 Oct 2019 15:44:41 +0200 Subject: [PATCH 5/5] Update nordicsemi/__main__.py --- nordicsemi/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nordicsemi/__main__.py b/nordicsemi/__main__.py index 91d6e75..fbb8749 100755 --- a/nordicsemi/__main__.py +++ b/nordicsemi/__main__.py @@ -490,7 +490,7 @@ def pkg(): help='The application version.', type=BASED_INT_OR_NONE) @click.option('--application-version-string', - help='The application version string, e.g "2.7.31". Will be converted to an integer, e.g 207031.', + help='The application version string, e.g. "2.7.31". Will be converted to an integer, e.g. 207031.', type=click.STRING) @click.option('--bootloader', help='The bootloader firmware file.',