@21natzil/

Jam5 (elias#7990)

Python

its called BomOS

fork
loading
Files
  • main.py
  • bomlang
  • files
  • bomos.py
  • docs.txt
  • filesys.py
  • proc.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# All scores out of 5
# File System: 4
#   - Works like a charm, no complaints there. The colors to identify files vs folders are great along side listing .. and . as options. My only complaint, is that you start in the root dir, and not the user dir.
# Coding: 4
#   - I loved your language, it was amazing, and makes up most your points. Writing the terminal comands in bomlang is even more awesome. The only issue I had was that there was no editor, no great way to write to files.
# Login: 4
#   - The login was simple and sweet, and the locking of other people's files was awesome. I just wish you had added commands to logout, and switch user.
# Interface: 3
#   - The interface was fine, you had so much wasted potential by not utilizing the ability to move your cursor with arrow keys.
# EOO: 3
#   - Some of the commands were a bit quirky, however the power of stuff like piping makes up for that.
# Docs: 3
#   - The docs in the file were great, and very descriptive. However, this does not diminish the need for a help command. Being able to quickly lookup a command rather than look at the file would be much better.
# Extras: 4
#   - I'll just list the extras. chmod, piping, procs, and a custom language, all amazing features.
# TOTAL: 26


# open in repl.run for best performance
# docs in docs.txt, there's no help command

import threading
import time
import sys
import tty

import filesys as fs
import proc
import bomos

def in_thread(in_):
  while True:
    char = sys.stdin.read(1)
    if char == "\r":
      char = "\n"
    # print(char)
    in_.write(char)

def out_thread(out):
  while True:
      exists, char = out.read()
      if not exists:
        if not running:
          return
        time.sleep(0)
        continue

      if char == b"\r":
        char = b""
      elif char == b"\n":
        char = b"\r\n"
      sys.stdout.write(char.decode())
      sys.stdout.flush()

tty.setraw(sys.stdin)

term_in = proc.PipeIn(None)
in_thread = threading.Thread(target=in_thread, args=(term_in,))

term_out = proc.PipeOut(None)
out_thread = threading.Thread(target=out_thread, args=(term_out,))

root_dir = fs.FSObj(uuid=fs.ROOT_ID)
os = bomos.OS(root_dir)
init = list(os.procs)[0]
proc.pair_pipes(term_in, init.stdin)
proc.pair_pipes(init.stdout, term_out)
running = True
in_thread.start()
out_thread.start()
os.run()

running = False
out_thread.join() # if os dies, in_thread is useless
                  # but out_thread might still have stuff in it