Skip to content
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

Make the MICROBIT volume detection more robust #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nviennot
Copy link
Contributor

On MacOS, the volume names can have spaces (e.g., "MICROBIT 1")

@virtualabs
Copy link
Owner

Cette modification provoque une régression sur ma machine (Linux Debian), mon Micro:Bit n'est plus détecté. Cela est dû à une mauvaise expression régulière, AMHA.

Il faudrait utiliser

re.match(r'^\S+ on (.*MICROBIT\s?([0-9]+)?)', line)

à la place de

re.match(r'^[^ ]+ on (.*MICROBIT+( [0-9]+)?)', line)

@nviennot
Copy link
Contributor Author

ici r'^\S+ on (.*MICROBIT( [0-9]+)?)' fonctionne, mais pas celle que tu as proposé.

Essaie de faire un mv /mnt/MICROBIT "/mnt/MICROBIT 1" pour tester

@virtualabs
Copy link
Owner

Bizarre ...

>>> re.match(r'^\S+ on (.*MICROBIT\s?([0-9]+)?)', '/dev/sdb1 on /mnt/MICROBIT 1').group(1)
'/mnt/MICROBIT 1'

Quelle est la ligne correspondant au Microbit dans la sortie de l'appel à mount ?

@nviennot
Copy link
Contributor Author

>>> import re
>>> line = "/dev/disk2 on /Volumes/MICROBIT 1 (msdos, local, nodev, nosuid, noowners)"
>>> re.match(r'^\S+ on (.*MICROBIT\s?([0-9]+)?)', line).group(1)
'/Volumes/MICROBIT 1'
>>> line = "/dev/disk2 on /Volumes/MICROBIT (msdos, local, nodev, nosuid, noowners)"
>>> re.match(r'^\S+ on (.*MICROBIT\s?([0-9]+)?)', line).group(1)
'/Volumes/MICROBIT '
>>>

Sur le 2eme example, l'espace en trop est un problème.

@virtualabs
Copy link
Owner

Je vois, donc la regexp suivante devrait résoudre le problème:

re.match(r'^\S+ on (.*MICROBIT(\s?[0-9]+)?)', line).group(1)

On MacOS, the volume names can have spaces (e.g., "MICROBIT 1")
@nviennot
Copy link
Contributor Author

C'est beau

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