console.print

This commit is contained in:
Samuel Sloniker 2022-12-01 12:19:32 -08:00
parent 63c5ad520d
commit 133cf044c4
Signed by: kj7rrv
GPG Key ID: 1BB4029E66285A62
7 changed files with 14 additions and 13 deletions

View File

@ -11,9 +11,9 @@ def get_app_class(template):
except OSError as e: except OSError as e:
try: try:
os.listdir(file) os.listdir(file)
console.write_str(self.console, f"cat: {file}: Is a directory\n") console.print(self.console, f"cat: {file}: Is a directory")
except OSError: except OSError:
console.write_str(self.console, f"cat: {file}: No such file or directory\n") console.print(self.console, f"cat: {file}: No such file or directory")
self.exit() self.exit()

View File

@ -16,9 +16,9 @@ def get_app_class(template):
except OSError as e: except OSError as e:
try: try:
os.listdir(file) os.listdir(file)
console.write_str(self.console, f"grep: {file}: Is a directory\n") console.print(self.console, f"grep: {file}: Is a directory")
except OSError: except OSError:
console.write_str(self.console, f"grep: {file}: No such file or directory\n") console.print(self.console, f"grep: {file}: No such file or directory")
self.exit() self.exit()

View File

@ -11,13 +11,13 @@ def get_app_class(template):
try: try:
for file in os.listdir(path): for file in os.listdir(path):
console.write_str(self.console, file + "\n") console.print(self.console, file)
except OSError as e: except OSError as e:
try: try:
os.stat(path) os.stat(path)
console.write_str(self.console, path + "\n") console.print(self.console, path)
except OSError: except OSError:
console.write_str(self.console, f"ls: cannot access '{path}': No such file or directory\n") console.print(self.console, f"ls: cannot access '{path}': No such file or directory")
self.exit() self.exit()

View File

@ -7,7 +7,7 @@ def get_app_class(template):
for pid, app in apps.items(): for pid, app in apps.items():
args = app.argv[1:] args = app.argv[1:]
name = app.name name = app.name
console.write_str(self.console, f'{pid} {name} {args}\n') console.print(self.console, f'{pid} {name} {args}')
self.exit() self.exit()
return App return App

View File

@ -4,7 +4,7 @@ import console
def get_app_class(template): def get_app_class(template):
class App(template): class App(template):
def F_main(self): def F_main(self):
console.write_str(self.console, os.getcwd() + "\n") console.print(self.console, os.getcwd())
self.exit() self.exit()
return App return App

View File

@ -8,7 +8,7 @@ def get_app_class(template):
self.jump('prompt') self.jump('prompt')
def F_prompt(self): def F_prompt(self):
self.console.write(b'FibonacciOS sh # ') console.print(self.console, 'FibonacciOS sh # ', end="")
self.store['buf'] = [] self.store['buf'] = []
self.jump('input') self.jump('input')
@ -29,9 +29,7 @@ def get_app_class(template):
self.wait(pid) self.wait(pid)
self.transfer_console(pid) self.transfer_console(pid)
except fibonaccios.exceptions.AppNotFound as e: except fibonaccios.exceptions.AppNotFound as e:
print('error: app not found') console.print(self.console, 'error: app not found')
self.jump('prompt') self.jump('prompt')
def F_loop(self):
pass
return App return App

View File

@ -19,3 +19,6 @@ def read(console, buffer):
def write_str(console, string, encoding="utf-8"): def write_str(console, string, encoding="utf-8"):
console.write(string.encode(encoding)) console.write(string.encode(encoding))
def print(console, *values, sep=" ", end="\n"):
write_str(console, sep.join(str(value) for value in values) + end)