This commit is contained in:
Samuel Sloniker 2022-11-30 03:18:17 +00:00
parent 7d13506b46
commit 163b0093a0
8 changed files with 79 additions and 0 deletions

5
bin/__init__.py Normal file
View File

@ -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}')

6
bin/background.py Normal file
View File

@ -0,0 +1,6 @@
import circuitos
class App(circuitos.App):
def F_main(self):
self.os.launch(*self.argv[1:])
self.exit()

16
bin/init.py Normal file
View File

@ -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

6
bin/kill.py Normal file
View File

@ -0,0 +1,6 @@
import circuitos
class App(circuitos.App):
def F_main(self):
self.os.kill(int(self.argv[1]))
self.exit()

10
bin/ps.py Normal file
View File

@ -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()

33
bin/sh.py Normal file
View File

@ -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

2
code.py Normal file
View File

@ -0,0 +1,2 @@
import circuitos
circuitos.run()

1
etc/init/start Normal file
View File

@ -0,0 +1 @@
sh