Add code
This commit is contained in:
parent
7d13506b46
commit
163b0093a0
5
bin/__init__.py
Normal file
5
bin/__init__.py
Normal 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
6
bin/background.py
Normal 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
16
bin/init.py
Normal 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
6
bin/kill.py
Normal 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
10
bin/ps.py
Normal 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
33
bin/sh.py
Normal 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
|
1
etc/init/start
Normal file
1
etc/init/start
Normal file
|
@ -0,0 +1 @@
|
|||
sh
|
Loading…
Reference in New Issue
Block a user