Skip to content

Remove default -m and -i options for project.py #3537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2017

Conversation

bridadan
Copy link
Contributor

@bridadan bridadan commented Jan 5, 2017

Description

This was spurred by ARMmbed/mbed-cli#410.

Having a default target and ide in the project.py script is inconsistent with the rest of the tools. This PR removes them and makes -m and -i required arguments.

Status

READY

Migrations

If this PR changes any APIs or behaviors, give a short description of what API users should do when this PR is merged.

YES - Though I doubt it will affect anyone. There is now no longer a default value for the target and the IDE. It will now error if neither of them are provided.

Todos

  • Exporter tests

Reviewer Notes

@theotherjimmy - Could you please make sure I haven't done anything with argparse settings?
@0xc0170 and/or @sarahmarshy - Will removing the default target and IDE cause any issues to your knowledge?

Also moves the check for -m and -i before any file system actions are
taken (error faster)
@bridadan bridadan force-pushed the remove_project_defaults branch from 78e0e9f to d32e3d8 Compare January 5, 2017 23:20
@bridadan
Copy link
Contributor Author

bridadan commented Jan 5, 2017

@theotherjimmy I broke project.py -S, so I guess its a good thing we actually keep that in Travis haha. I've pushed a new commit.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 6, 2017

What about any error? This removes the default values, so if anyone was using it, it would break without any warning/error? I assume you warn a user in the upper layer (mbed-cli)? but what about a user who using this as it (mbed 2 for instance, directly this tool) ?

A quick check - mbed compile with this change works as it should (when target and toolchain is set separately via mbed-cli) ?

@bridadan
Copy link
Contributor Author

bridadan commented Jan 6, 2017

Silly me, I meant to post what the new logs look like!

$ mbed config -L
[mbed] Global config:
No global configuration is set

[mbed] Local config (C:\Users\bridan01\Documents\dev\mbed-os-example-blinky):
No local configuration is set
$ mbed export
[mbed] ERROR: Please specify target using the -m switch or set default target using command 'mbed target'
---
$ mbed export -m LPC1768
c:\python27\lib\site-packages\fuzzywuzzy\fuzz.py:35: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning
  warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')
usage: project.py [-h] [-m MCU] [-i IDE] [-c] [-p PROGRAM] [-n PROGRAM] [-b]
                  [-L] [-S] [-E] [--source SOURCE_DIR] [-D MACROS]
                  [--profile PROFILE] [--update-packs]
project.py: error: argument -m/--mcu is required
[mbed] ERROR: "python" returned error code 2.
[mbed] ERROR: Command "python -u C:\Users\bridan01\Documents\dev\mbed-os-example-blinky\mbed-os\tools\project.py --source ." in "C:\Users\bridan01\Documents\dev\mbed-os-example-blinky"
---

That's the error they'd see when using the scripts directly. The error is almost identical for the -i argument.

The last error becomes much nicer when paired with these changes: ARMmbed/mbed-cli#412

$ mbed export -m LPC1768
[mbed] ERROR: Please specify ide using the -i switch
---

And then of course if you supply all the required arguments:

$ mbed export -m LPC1768 -i uvision
c:\python27\lib\site-packages\fuzzywuzzy\fuzz.py:35: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning
  warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')
Scan: .
Scan: FEATURE_BLE
Scan: FEATURE_COMMON_PAL
Scan: FEATURE_LWIP
Scan: FEATURE_UVISOR
Scan: FEATURE_LOWPAN_BORDER_ROUTER
Scan: FEATURE_LOWPAN_HOST
Scan: FEATURE_LOWPAN_ROUTER
Scan: FEATURE_NANOSTACK
Scan: FEATURE_NANOSTACK_FULL
Scan: FEATURE_THREAD_BORDER_ROUTER
Scan: FEATURE_THREAD_END_DEVICE
Scan: FEATURE_THREAD_ROUTER
Scan: FEATURE_STORAGE

No errors 😄

@bridadan
Copy link
Contributor Author

bridadan commented Jan 6, 2017

/morph export-build

@theotherjimmy
Copy link
Contributor

theotherjimmy commented Jan 6, 2017

$ mbed export -m LPC1768
c:\python27\lib\site-packages\fuzzywuzzy\fuzz.py:35: UserWarning: Using slow pure-python >SequenceMatcher. Install python-Levenshtein to remove this warning
 warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to >remove this warning')
usage: project.py [-h] [-m MCU] [-i IDE] [-c] [-p PROGRAM] [-n PROGRAM] [-b]
                 [-L] [-S] [-E] [--source SOURCE_DIR] [-D MACROS]
                 [--profile PROFILE] [--update-packs]
project.py: error: argument -m/--mcu is required
[mbed] ERROR: "python" returned error code 2.
[mbed] ERROR: Command "python -u C:\Users\bridan01\Documents\dev\mbed-os-example-blinky\mbed-os\tools\project.py --source ." in "C:\Users\bridan01\Documents\dev\mbed-os-example-blinky"

This output is wrong. It should say error: argument -i/--ide is required.

@mbed-bot
Copy link

mbed-bot commented Jan 6, 2017

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph export-build

Output

mbed Build Number: 73

All exports and builds passed!

@bridadan
Copy link
Contributor Author

bridadan commented Jan 6, 2017

@theotherjimmy good point, that's actually a bug in the released version of mbed-cli at the moment. You can see the bad line here: https://github.com/ARMmbed/mbed-cli/blob/e25da20743223be4781318dc96c3696aa1728270/mbed/mbed.py#L2341

For some reason if the -i argument isn't supplied it also doesn't supply the -m argument. Funky!

@sg- sg- merged commit 1816f0b into ARMmbed:master Jan 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants