#: List of supported board USB IDs. Each board is a tuple of unique USB vendor # ID, USB product ID. BOARD_IDS = set([ (0x0D28, 0x0204), # micro:bit USB VID, PID (0x239A, 0x800B), # Adafruit Feather M0 CDC only USB VID, PID (0x239A, 0x8016), # Adafruit Feather M0 CDC + MSC USB VID, PID (0x239A, 0x8013), # Adafruit Metro M0 CDC only USB VID, PID (0x239A, 0x8015) # Adafruit Metro Mo CDC + MSC USB VID, PID ]) #: The user's home directory. HOME_DIRECTORY = os.path.expanduser('~') # Name of the directory within the home folder to use by default WORKSPACE_NAME = 'mu_code' #: The default directory for application data (i.e., configuration). DATA_DIR = appdirs.user_data_dir(appname='mu', appauthor='python') #: The default directory for application logs. LOG_DIR = appdirs.user_log_dir(appname='mu', appauthor='python') #: The path to the log file for the application. LOG_FILE = os.path.join(LOG_DIR, 'mu.log') #: Regex to match pycodestyle (PEP8) output. STYLE_REGEX = re.compile(r'.*:(\d+):(\d+):\s+(.*)') #: Regex to match flake8 output. FLAKE_REGEX = re.compile(r'.*:(\d+):\s+(.*)') #: Regex to match false positive flake errors if microbit.* is expanded. EXPAND_FALSE_POSITIVE = re.compile(r"^'microbit\.(\w+)' imported but unused$") #: The text to which "from microbit import *" should be expanded. EXPANDED_IMPORT = ("from microbit import pin15, pin2, pin0, pin1, " " pin3, pin6, pin4, i2c, pin5, pin7, pin8, Image, " "pin9, pin14, pin16, reset, pin19, temperature, " "sleep, pin20, button_a, button_b, running_time, "
except ImportError: from pep8 import StyleGuide, Checker from mu.contrib import uflash, appdirs, microfs from mu import __version__ #: USB product ID. MICROBIT_PID = 516 #: USB vendor ID. MICROBIT_VID = 3368 #: The user's home directory. HOME_DIRECTORY = os.path.expanduser('~') #: The default directory for Python scripts. PYTHON_DIRECTORY = os.path.join(HOME_DIRECTORY, 'python') #: The default directory for application data. DATA_DIR = appdirs.user_data_dir('mu', 'python') #: The default directory for application logs. LOG_DIR = appdirs.user_log_dir('mu', 'python') #: The path to the JSON file containing application settings. SETTINGS_FILE = os.path.join(DATA_DIR, 'settings.json') #: The path to the log file for the application. LOG_FILE = os.path.join(LOG_DIR, 'mu.log') #: Regex to match pycodestyle (PEP8) output. STYLE_REGEX = re.compile(r'.*:(\d+):(\d+):\s+(.*)') #: Regex to match flake8 output. FLAKE_REGEX = re.compile(r'.*:(\d+):\s+(.*)') #: Regex to match false positive flake errors if microbit.* is expanded. EXPAND_FALSE_POSITIVE = re.compile(r"^'microbit\.(\w+)' imported but unused$") #: The text to which "from microbit import *" should be expanded. EXPANDED_IMPORT = ("from microbit import pin15, pin2, pin0, pin1, " " pin3, pin6, pin4, i2c, pin5, pin7, pin8, Image, "
from PyQt5.QtSerialPort import QSerialPortInfo from pyflakes.api import check from pycodestyle import StyleGuide, Checker from mu.contrib import uflash, appdirs, microfs from mu import __version__ #: USB product ID. MICROBIT_PID = 516 #: USB vendor ID. MICROBIT_VID = 3368 #: The user's home directory. HOME_DIRECTORY = os.path.expanduser('~') #: The default directory for Python scripts. PYTHON_DIRECTORY = os.path.join(HOME_DIRECTORY, 'python') #: The default directory for application data. DATA_DIR = appdirs.user_data_dir('mu', 'python') #: The default directory for application logs. LOG_DIR = appdirs.user_log_dir('mu', 'python') #: The path to the JSON file containing application settings. SETTINGS_FILE = os.path.join(DATA_DIR, 'settings.json') #: The path to the log file for the application. LOG_FILE = os.path.join(LOG_DIR, 'mu.log') #: Regex to match pycodestyle (PEP8) output. STYLE_REGEX = re.compile(r'.*:(\d+):(\d+):\s+(.*)') #: Regex to match flake8 output. FLAKE_REGEX = re.compile(r'.*:(\d+):\s+(.*)') logger = logging.getLogger(__name__) def find_microbit():
along with this program. If not, see <http://www.gnu.org/licenses/>. """ import os import os.path import sys import json from PyQt5.QtWidgets import QMessageBox from mu.repl import find_microbit from mu.contrib import uflash, appdirs HOME_DIRECTORY = os.path.expanduser("~") MICROPYTHON_DIRECTORY = os.path.join(HOME_DIRECTORY, "micropython") if not os.path.exists(MICROPYTHON_DIRECTORY): os.mkdir(MICROPYTHON_DIRECTORY) DATA_DIR = appdirs.user_data_dir("mu", "python") if not os.path.exists(DATA_DIR): os.mkdir(DATA_DIR) SESSION_FILE = os.path.join(DATA_DIR, "tabs.json") class REPL: """ Read, Evaluate, Print, Loop. Represents the REPL. Since the logic for the REPL is simply a USB/serial based widget this class only contains a reference to the associated port. """ def __init__(self, port): if os.name == "posix":