Skip to content

Conversation

@bridadan
Copy link
Contributor

If you call os.path.exists on a removable drive that is currently in the
"ejected" state (which often happens when flashing multiple devices at the
same time), then an error dialog will be shown that blocks the python
process until the user interacts with it. You can globally disable these
error boxes, but this is undesirable as it may mask other errors that occur.

Windows has APIs that allow it to check if a device is ready before
accessing the filesystem, however this is hard to access from Python.
Instead, we use the dir command, which will error but not cause a blocking
error dialog.

Note: We aren't currently checking the mount point via the file system for other OSes, but I've added the base function in lstools_base.py. If this is unnecessary I can remove this.

If you call `os.path.exists` on a removable drive that is currently in the
"ejected" state (which often happens when flashing multiple devices at the
same time), then an error dialog will be shown that blocks the python
process until the user interacts with it. You can globally disable these
error boxes, but this is undesirable as it may mask other errors that occur.

Windows has APIs that allow it to check if a device is ready before
accessing the file system, however this is hard to access from Python.
Instead, we use the `dir` command, which will error but not cause a blocking
error dialog. For other OSes, we just use `os.path.exists`.
`dir` prevents this since it uses the Windows API to determine if the
device is ready before accessing the file system.
"""
stdout, stderr, retcode = self.run_cli_process('dir %s' % path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does dir command behave same on all platforms? I guess it will have different behaviour on Windows and Linux.

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 dir command will only be used on Windows. On Linux it looks like it never actually checks to see if the file system has that mount point via os.path.exists, it just checks the mount point using the mount command.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright I see that it is in Windows implementation.

@mazimkhan mazimkhan merged commit 1fb0b7e into ARMmbed:master Sep 9, 2016
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.

2 participants