Samuel Sloniker
1 year ago
8 changed files with 79 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||||||
|
import os |
||||||
|
|
||||||
|
imports = [ i[:-3] for i in os.listdir('/bin/') if i.endswith('.py') and not '__' in i ] |
||||||
|
for module in imports: |
||||||
|
exec(f'import bin.{module} as {module}') |
@ -0,0 +1,6 @@ |
|||||||
|
import circuitos |
||||||
|
|
||||||
|
class App(circuitos.App): |
||||||
|
def F_main(self): |
||||||
|
self.os.launch(*self.argv[1:]) |
||||||
|
self.exit() |
@ -0,0 +1,16 @@ |
|||||||
|
import circuitos |
||||||
|
import shlex |
||||||
|
|
||||||
|
class App(circuitos.App): |
||||||
|
def F_main(self): |
||||||
|
with open('/etc/init/start') as f: |
||||||
|
lines = f.readlines() |
||||||
|
for line in lines: |
||||||
|
if line.strip(): |
||||||
|
last_pid = self.os.launch(*shlex.split(line)) |
||||||
|
|
||||||
|
self.transfer_console(last_pid) |
||||||
|
self.next_function = 'loop' |
||||||
|
|
||||||
|
def F_loop(self): |
||||||
|
pass |
@ -0,0 +1,6 @@ |
|||||||
|
import circuitos |
||||||
|
|
||||||
|
class App(circuitos.App): |
||||||
|
def F_main(self): |
||||||
|
self.os.kill(int(self.argv[1])) |
||||||
|
self.exit() |
@ -0,0 +1,10 @@ |
|||||||
|
import circuitos |
||||||
|
|
||||||
|
class App(circuitos.App): |
||||||
|
def F_main(self): |
||||||
|
apps = self.os.apps |
||||||
|
for pid, app in apps.items(): |
||||||
|
args = app.argv[1:] |
||||||
|
name = app.name |
||||||
|
print(f'{pid} {name} {args}') |
||||||
|
self.exit() |
@ -0,0 +1,33 @@ |
|||||||
|
import circuitos |
||||||
|
import shlex |
||||||
|
import console |
||||||
|
|
||||||
|
class App(circuitos.App): |
||||||
|
def F_main(self): |
||||||
|
self.jump('prompt') |
||||||
|
|
||||||
|
def F_prompt(self): |
||||||
|
self.console.write(b'CicuitOS sh # ') |
||||||
|
self.store['buf'] = [] |
||||||
|
self.jump('input') |
||||||
|
|
||||||
|
def F_input(self): |
||||||
|
raw_line = console.read(self.console, self.store['buf']) |
||||||
|
if raw_line is not None: |
||||||
|
line = shlex.split(raw_line.decode('ascii')) |
||||||
|
if line: |
||||||
|
try: |
||||||
|
if line[0] == 'bg': |
||||||
|
self.os.launch(*line[1:]) |
||||||
|
elif line[0] == 'exit': |
||||||
|
self.exit() |
||||||
|
else: |
||||||
|
pid = self.os.launch(*line) |
||||||
|
self.wait(pid) |
||||||
|
self.transfer_console(pid) |
||||||
|
except circuitos.AppNotFound as e: |
||||||
|
print('error: app not found') |
||||||
|
self.jump('prompt') |
||||||
|
|
||||||
|
def F_loop(self): |
||||||
|
pass |
Loading…
Reference in new issue