11 |
11 |
12 import ast |
12 import ast |
13 import time |
13 import time |
14 import os |
14 import os |
15 |
15 |
16 from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject, QThread, QTimer, QCoreApplication, QEventLoop |
16 from PyQt5.QtCore import ( |
|
17 pyqtSlot, pyqtSignal, QObject, QThread, QTimer, QCoreApplication, |
|
18 QEventLoop |
|
19 ) |
17 |
20 |
18 from .MicroPythonSerialPort import MicroPythonSerialPort |
21 from .MicroPythonSerialPort import MicroPythonSerialPort |
19 |
22 |
20 import Preferences |
23 import Preferences |
21 |
24 |
22 |
25 |
|
26 # TODO: change code sent to the boards to functions and retrieve them using |
|
27 # inspect.getsource() or inspect.getsourcelines() |
23 class MicroPythonCommandsInterface(QObject): |
28 class MicroPythonCommandsInterface(QObject): |
24 """ |
29 """ |
25 Class implementing some file system commands for MicroPython. |
30 Class implementing some file system commands for MicroPython. |
26 |
31 |
27 Commands are provided to perform operations on the file system of a |
32 Commands are provided to perform operations on the file system of a |
316 """ |
321 """ |
317 commands = [ |
322 commands = [ |
318 "import os as __os_", |
323 "import os as __os_", |
319 "\n".join([ |
324 "\n".join([ |
320 "def is_visible(filename):", |
325 "def is_visible(filename):", |
321 " return (not filename.startswith('.') and" |
326 " return filename[0] != '.' and filename[-1] != '~'", |
322 " not filename.endswith('~'))", |
|
323 ]), |
327 ]), |
324 "\n".join([ |
328 "\n".join([ |
325 "def stat(filename):", |
329 "def stat(filename):", |
326 " try:", |
330 " try:", |
327 " rstat = __os_.lstat(filename)", |
331 " rstat = __os_.lstat(filename)", |