transfer.py 937 Bytes
import psutil
import urllib.request
import os
import shutil

disks = [x.mountpoint for x in psutil.disk_partitions(
) if 'TRINKEY' in x.mountpoint.upper() or 'CIRCUIT' in x.mountpoint.upper()]

if len(disks) != 1:
    print("Could not find the trinkey.  Did you click the reset button twice and connect it?")
    exit(1)

disk = disks[0]

if 'TRINKEY' in disk:
    urllib.request.urlretrieve(
        "https://downloads.circuitpython.org/bin/adafruit_proxlight_trinkey_m0/en_US/adafruit-circuitpython-adafruit_proxlight_trinkey_m0-en_US-9.1.4.uf2", os.path.join(
            disk, 'trinkey.uf2'))
else:
    shutil.rmtree(os.path.join(disk, 'lib'), True)
    shutil.rmtree(os.path.join(disk, 'src'), True)
    shutil.rmtree(os.path.join(disk, 'boot_out.txt'), True)
    shutil.rmtree(os.path.join('src', '__pycache__'), True)
    shutil.copytree('src', os.path.join(disk, 'src'))
    shutil.copy('code.py', os.path.join(disk, 'code.py'))