Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dyldonahue committed Sep 3, 2024
1 parent 9e18ac8 commit 7746773
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions launchpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import sys
import os
import platform
import shutil

def install_platformio(venv_path):
"""Install PlatformIO package and set up aliases."""
Expand Down Expand Up @@ -43,6 +44,9 @@ def uninstall_platformio(venv_path):
# Uninstall the platformio package
subprocess.check_call([sys.executable, '-m', 'pip', 'uninstall', '-y', 'platformio'])

# Remove PlatformIO directory
remove_platformio_directory()

# Determine OS and adjust alias handling
os_type = platform.system()
if os_type == 'Windows':
Expand Down Expand Up @@ -76,6 +80,18 @@ def remove_aliases(activate_path):
print(f"Failed to remove aliases: {e}", file=sys.stderr)
sys.exit(1)

def remove_platformio_directory():
"""Remove the PlatformIO directory."""
platformio_dir = os.path.expanduser('~/.platformio')
if os.path.isdir(platformio_dir):
try:
shutil.rmtree(platformio_dir)
print("PlatformIO directory removed.")
except OSError as e:
print(f"Failed to remove PlatformIO directory: {e}", file=sys.stderr)
sys.exit(1)
else:
print("PlatformIO directory does not exist.")
def main():
if len(sys.argv) != 2:
print("Usage: launchpad.py [install|uninstall]", file=sys.stderr)
Expand Down
2 changes: 1 addition & 1 deletion miniterm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def list_usb_devices():
def run_miniterm(device, baudrate=9600):
"""Run pyserial-miniterm with the specified device and baudrate."""
try:
subprocess.run(['pyserial-miniterm', device, '-b', str(baudrate)], check=True)
subprocess.run(['pyserial-miniterm', device, '--baud', str(baudrate)], check=True)
except subprocess.CalledProcessError as e:
print(f"Failed to run pyserial-miniterm: {e}", file=sys.stderr)
sys.exit(1)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
distro
pre-commit
pyserial
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def parse_requirements(filename):
setup(
name='ner-setup',
version='0.1',
py_modules=['ner_setup'],
py_modules=['ner_setup', 'launchpad', 'clang_restage', 'miniterm'],
install_requires=parse_requirements('requirements.txt'),
entry_points={
'console_scripts': [
Expand Down

0 comments on commit 7746773

Please sign in to comment.