Skip to content

Config Output Auto-update Script #948

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 21 commits into from
Feb 27, 2019

Conversation

kegilbert
Copy link
Contributor

@kegilbert kegilbert commented Feb 11, 2019

Add a manually run script that will replace the config system verbose output in the docs with the output from the config list command. Bit of a simple implementation without many automated checks at the moment, I'd still recommend double checking the output pretty closely until after some more review.

The LWIP page had to be consolidated for this to work but everything else should be unchanged.

Tested mainly with Python3, Python2 worked but ran into an occasional UTF-8 encoding error (I can poke around that more if need be).

@kegilbert kegilbert force-pushed the config-doc-update-script branch from 630c727 to c002c64 Compare February 11, 2019 22:24
@kegilbert kegilbert requested a review from cmonr February 14, 2019 20:46
@kegilbert
Copy link
Contributor Author

@cmonr, @geky is busy and can't review this atm. Left Geky on so he can double check the LWIP file changes if you'd be free to double check the scripty-boi. Thanks!

exc_type, exc_obj, exc_tb = sys.exc_info()
fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
print(exc_type, fname, exc_tb.tb_lineno)
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

I asked offline why this has exception handling here as it looks like it doesn't do anything. I was wrong, this one passes (is there another way to do this?). You may want a comment to explain this for idiots like me :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updooted, I'm also OK with removing this section as its more of a vestigial hold out from development (although can still be helpful, let me catch minor exceptions that didn't cause issues without exiting and provided a full list of all files that caused issues).

Copy link
Contributor

@AnotherButler AnotherButler left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. This looks great 👍

@AnotherButler
Copy link
Contributor

@cmonr Is this ready to merge?

@kegilbert kegilbert force-pushed the config-doc-update-script branch from efbd3c3 to 3ac0648 Compare February 20, 2019 20:08
@AnotherButler
Copy link
Contributor

@cmonr It was this one.

if ('Name: ' in blocks[i]):
lib = blocks[i].split('Name: ')[1].split('.')[0]
print("================= %s =================" % lib)
out = subprocess.check_output(["mbed", "compile", "--config", "-v", "--prefix", lib]).decode()
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably want:

Suggested change
out = subprocess.check_output(["mbed", "compile", "--config", "-v", "--prefix", lib]).decode()
out = subprocess.check_output(["mbed", "compile", "--config", "-v", "--prefix", lib]).encode('utf-8')

For Py2/Py3 compat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The subprocess output in Python3 is a Bytes object that I cannot encode. I had added the decode initially to allow it to run in both Python2/3 (although I did run the following error in nvstore in Python2):

'ascii' codec can't decode byte 0xe2 in position 996: ordinal not in range(128)

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/ARMmbed/mbed-os/pulls?q=is%3Apr+is%3Aclosed+author%3Acmonr

A couple of my recent PRs were Python 2/3 compat related if you want to take a look.

Imo, it might be better if this works with Py3 if you had to choose one.

Also, I might be confusing encode and decode.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to know what causes the occasional convert error.


if (os.path.isfile(path)):
main(path)
else:
Copy link
Contributor

Choose a reason for hiding this comment

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

Due to the arg parsing in https://github.com/ARMmbed/mbed-os-5-docs/pull/948/files#diff-e52e11a85f5305dc93291efd2f777122R54, this should verify that path is a directory or throw an error.

@cmonr
Copy link
Contributor

cmonr commented Feb 22, 2019

Add a manually run script

If this is manually run, how is this expected to be used? When, where, by who, and how often?

@AnotherButler
Copy link
Contributor

The longterm goal is to get this into CI, so it's completely automated. In the short term, the docs team can run it every feature release if given written, detailed instructions.

@kegilbert
Copy link
Contributor Author

kegilbert commented Feb 22, 2019

Correct I'd love to see this in CI, but until then it should be as simple to run as:

# Run from the check_tools directory or pass in the docs/reference/configuration path manually
python config-update.py 
#OR  
python check_tools/config-update.py docs/reference/configuration

# View the results with git diff locally first or just push up the changes as a new PR and view
# from there. Feel free to use whatever git methodology you'd like, just showing an example here
git diff
git checkout -b <BRANCH>
git add docs/reference/configuration/*.md
git commit 
git push <REMOTE> <BRANCH>
# Create PR

@AnotherButler
Copy link
Contributor

@cmonr Have all of your concerns been addressed?

@kegilbert
Copy link
Contributor Author

@cmonr Fixed the string formatting, runs on Python 2.7/3.5

@cmonr
Copy link
Contributor

cmonr commented Feb 27, 2019

I personally feel like the script could use more documentation, but I'm not going to block the PR on it.

https://blog.codinghorror.com/coding-for-violent-psychopaths/

@kegilbert We'll see how well this comment ages 😁

@AnotherButler AnotherButler merged commit af2f22d into ARMmbed:development Feb 27, 2019
@kegilbert
Copy link
Contributor Author

I'll put up another a bit with some better docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants