Fixed wording and icons
This commit is contained in:
@@ -584,9 +584,25 @@ class Files(object):
|
|||||||
chunk = "b" + chunk
|
chunk = "b" + chunk
|
||||||
self._pyboard.exec_(f"f.write({chunk})")
|
self._pyboard.exec_(f"f.write({chunk})")
|
||||||
self._pyboard.exec_("f.close()")
|
self._pyboard.exec_("f.close()")
|
||||||
except Exception as ex:
|
except Exception as e:
|
||||||
print(' [x]')
|
print(' [x]')
|
||||||
raise ex
|
message = str(e)
|
||||||
|
|
||||||
|
if message.find('OSError: [Errno 2] ENOENT') != -1:
|
||||||
|
reason = f'"{filename}" does not exists!'
|
||||||
|
elif message.find('OSError: [Errno 13] EACCES') != -1:
|
||||||
|
reason = f'"{filename}" access denied!'
|
||||||
|
elif message.find('OSError: [Errno 21] EISDIR') != -1:
|
||||||
|
reason = f'"{filename}" is a directory!'
|
||||||
|
else:
|
||||||
|
reason = 'Traceback (most recent call last):'
|
||||||
|
traceback = message.split(reason)
|
||||||
|
|
||||||
|
if len(traceback) == 2:
|
||||||
|
for call in traceback[1][:-2].split('\\r\\n'):
|
||||||
|
reason += f'{call}\n'
|
||||||
|
|
||||||
|
raise Exception(reason.strip())
|
||||||
finally:
|
finally:
|
||||||
self._pyboard.exit_raw_repl()
|
self._pyboard.exit_raw_repl()
|
||||||
self.__raw_repl_on = False
|
self.__raw_repl_on = False
|
||||||
@@ -645,7 +661,7 @@ class Files(object):
|
|||||||
import uos as os
|
import uos as os
|
||||||
os.remove('{filename}')
|
os.remove('{filename}')
|
||||||
"""
|
"""
|
||||||
print(f'↶ {filename}', end='')
|
print(f'– {filename}', end='')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.__raw_repl_on = True
|
self.__raw_repl_on = True
|
||||||
@@ -698,7 +714,7 @@ class Files(object):
|
|||||||
os.rmdir(directory)
|
os.rmdir(directory)
|
||||||
rmdir('{directory}')
|
rmdir('{directory}')
|
||||||
"""
|
"""
|
||||||
print(f'↶ {directory}', end='')
|
print(f'– {directory}', end='')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.__raw_repl_on = True
|
self.__raw_repl_on = True
|
||||||
@@ -864,7 +880,7 @@ def upload(source: str = '', destination: str = ''):
|
|||||||
|
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Exeception: upload({source}, {destination}): {str(e)}')
|
print(f'Exception: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
def download(source: str = '/'):
|
def download(source: str = '/'):
|
||||||
@@ -889,7 +905,7 @@ def download(source: str = '/'):
|
|||||||
|
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Exeception: download({source}): {str(e)}')
|
print(f'Exception: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
def contents(filename: str):
|
def contents(filename: str):
|
||||||
@@ -897,7 +913,7 @@ def contents(filename: str):
|
|||||||
for ln in pico.get(filename).decode('utf-8').split('\n'):
|
for ln in pico.get(filename).decode('utf-8').split('\n'):
|
||||||
print(ln)
|
print(ln)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Exeception: contents({filename}): {str(e)}')
|
print(f'Exception: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
def delete(source: str):
|
def delete(source: str):
|
||||||
@@ -907,7 +923,7 @@ def delete(source: str):
|
|||||||
else:
|
else:
|
||||||
pico.rm(source)
|
pico.rm(source)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Exeception: delete({source}): {str(e)}')
|
print(f'Exception: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
def ls(source: str = '/'):
|
def ls(source: str = '/'):
|
||||||
@@ -922,14 +938,14 @@ def ls(source: str = '/'):
|
|||||||
if len(filename) > 5:
|
if len(filename) > 5:
|
||||||
print('→', filename)
|
print('→', filename)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Exeception: ls({source}): {str(e)}')
|
print(f'Exception: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
def launch(filename: str = 'main.py'):
|
def launch(filename: str = 'main.py'):
|
||||||
try:
|
try:
|
||||||
pico.run_on_board(filename)
|
pico.run_on_board(filename)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Exeception: launch({filename}): {str(e)}')
|
print(f'Exception: {str(e)}')
|
||||||
|
|
||||||
|
|
||||||
sessions = {'deleted': set(), 'modified': set()}
|
sessions = {'deleted': set(), 'modified': set()}
|
||||||
@@ -1006,10 +1022,10 @@ try:
|
|||||||
watchdog_callback()
|
watchdog_callback()
|
||||||
case ['status' | 'staged']:
|
case ['status' | 'staged']:
|
||||||
for filename in sessions['deleted']:
|
for filename in sessions['deleted']:
|
||||||
print('del:', filename)
|
print('–', filename)
|
||||||
|
|
||||||
for filename in sessions['modified']:
|
for filename in sessions['modified']:
|
||||||
print('mod:', filename)
|
print('+', filename)
|
||||||
case ['cancel' | 'unstaged']:
|
case ['cancel' | 'unstaged']:
|
||||||
sessions['deleted'] = set()
|
sessions['deleted'] = set()
|
||||||
sessions['modified'] = set()
|
sessions['modified'] = set()
|
||||||
|
|||||||
Reference in New Issue
Block a user