Skip to content

Comments

Fix mikrotik_routeros_system_resource_print#2286

Open
kwood92 wants to merge 4 commits intonetworktocode:masterfrom
kwood92:mikrotik_routeros_system_resource_print
Open

Fix mikrotik_routeros_system_resource_print#2286
kwood92 wants to merge 4 commits intonetworktocode:masterfrom
kwood92:mikrotik_routeros_system_resource_print

Conversation

@kwood92
Copy link
Contributor

@kwood92 kwood92 commented Feb 17, 2026

Build time regex to support RouterOS v7.13+

Build time regex to support v7.16+
Swap out \s* regex (between date and time) for a single literal space since there is always a space.
Both old and new build time formats use the same time format for hour:minute:second.
So we can reduce the duplication by adjusting the build time regex.
mjbear
mjbear previously approved these changes Feb 18, 2026
Newer versions of RouterOS7 contains whitespace at the end of strings to pad it out to the end of the build-time string.

New regex fixes that.
@kwood92
Copy link
Contributor Author

kwood92 commented Feb 18, 2026

Thanks @mjbear
I've commited some additional changes that fix lines containing extra (unneeded) whitespace introduced in newer versions of RouterOS 7

Value FACTORY_SOFTWARE (\S+)
Value VERSION (\S+(?:\s+\S+)*)
Value BUILD_TIME ((\d{4}-\d{2}-\d{2}|[A-Za-z]{3}\/\d{1,2}\/\d{4}) \d{2}:\d{2}:\d{2})
Value FACTORY_SOFTWARE (\S+(?:\s+\S+)*)
Copy link
Collaborator

@mjbear mjbear Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The factory software data provided does not require a change to the regex as there only appears to be one word (not two words/strings separated with a space).
Do you have data that shows a version separated with a space?

Value ARCHITECTURE_NAME (\S*)
Value BOARD_NAME (.+)
Value PLATFORM (.+)
Value ARCHITECTURE_NAME (\S+(?:\s+\S+)*)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the architecture name in the provided data has a space and a second word. There doesn't appear to be a reason to change the regex unless there's test data we haven't seen.

Value PLATFORM (.+)
Value ARCHITECTURE_NAME (\S+(?:\s+\S+)*)
Value BOARD_NAME (\S+(?:\s+\S+)*)
Value PLATFORM (\S+(?:\s+\S+)*)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

platform only shows up as a single word in the test data. There doesn't appear to be a reason to change the regex. Is there more test data?

@mjbear mjbear dismissed their stale review February 19, 2026 01:34

There are questions about changes made after the initial approval.

@kwood92
Copy link
Contributor Author

kwood92 commented Feb 19, 2026

@mjbear The example data is in tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.raw

All the lines aside from build-time are padded out with spaces to the end of the build-time string

For a visual reference, see the screenshot below:
image

As for the comments about platform, architecture name & factory software, right now I do not have any examples, it's just defensive changes in case Mikrotik changes their minds again.

@mjbear
Copy link
Collaborator

mjbear commented Feb 21, 2026

@mjbear The example data is in tests/mikrotik_routeros/system_resource_print/mikrotik_routeros_system_resource_print_6.raw

All the lines aside from build-time are padded out with spaces to the end of the build-time string

For a visual reference, see the screenshot below: image

I agree, the furthest right whitespace regex (at the end of the line) may as well just be \s*. Those elsewhere within the line can be \s+ as long as there are 1+ spaces there reliably.

As for the comments about platform, architecture name & factory software, right now I do not have any examples, it's just defensive changes in case Mikrotik changes their minds again.

@jvanderaa @jmcgill298
Thoughts on anticipating future changes when we don't have test data for these situations today (on this PR)?

@mjbear mjbear changed the title Fix: mikrotik_routeros_system_resource_print Fix mikrotik_routeros_system_resource_print Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants