Skip to content

Commit 324084a

Browse files
added 4 files and 1 folder
1 parent 8ce2708 commit 324084a

File tree

4 files changed

+174
-0
lines changed

4 files changed

+174
-0
lines changed

animation.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from rich.progress import track
2+
from rich.console import Console
3+
from rich.theme import Theme
4+
import pattern, time
5+
import termcolor, os
6+
console = Console()
7+
8+
def animate():
9+
console.print(pattern._prnt())
10+
time.sleep(0.5)
11+
for i in track(range(10), description="Preparing BIOS", style="bold orange_red1"):
12+
time.sleep(0.5)
13+
for i in track(range(7), description="Getting Bootloader Ready", style="bold white"):
14+
time.sleep(0.5)
15+
for i in track(range(15), description="Getting Kernel Setup", style="bold chartreuse1"):
16+
print(termcolor.colored(f"setup.tar.gz {i}", "yellow"))
17+
time.sleep(1)
18+
textF = ["Logging In", "Getting Tools", "Checking for updates", "Checking for known vulnerabilities", "Setting up Ubuntu", "Initializing Window", "Getting Kernel Ready", "Preparing Shell"]
19+
for text in textF:
20+
console.log(text, style='bold cyan')
21+
time.sleep(1)
22+
os.system("cls")

pattern.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import rich
2+
from rich.console import Console
3+
console = Console()
4+
5+
U = ['* *',
6+
'* *',
7+
'* *',
8+
'* *',
9+
' * * * ']
10+
N = ['* *',
11+
'* * *',
12+
'* * *',
13+
'* * *',
14+
'* *']
15+
I = [
16+
'**********',
17+
' * ',
18+
' * ',
19+
' * ',
20+
'**********',]
21+
X = ['* * ',
22+
' * * ',
23+
' * ',
24+
' * * ',
25+
'* * ']
26+
line0 = ' '.join(i[0] for i in (U,N,I,X))
27+
line1 = ' '.join(i[1] for i in (U,N,I,X))
28+
line2 = ' '.join(i[2] for i in (U,N,I,X))
29+
line3 = ' '.join(i[3] for i in (U,N,I,X))
30+
line4 = ' '.join(i[4] for i in (U,N,I,X))
31+
32+
def _prnt():
33+
for l in (line0, line1, line2, line3, line4):
34+
console.print(l, style="bold chartreuse1")

tests/test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from rich.console import Console
2+
import socket, os, datetime
3+
console = Console()
4+
commands = ["touch", "mkdir", "ls", "cat"]
5+
path = os.getcwd()
6+
name = socket.gethostname()
7+
user = os.getlogin()
8+
path = path.replace("\\", "/")
9+
path = path.removeprefix("C:/Users/DEBARKA NASKAR/")
10+
now = datetime.datetime.now()
11+
day = now.strftime("%d")
12+
month = now.strftime("%m")
13+
year = now.strftime("%Y")
14+
date = day + "-" + month + "-" + year
15+
time = datetime.datetime.now().strftime("%H:%M")
16+
console.print(f"[bold][chartreuse1]{user}@{name}[/] [magenta2]UNIX[/] [gold1]~{'/' + path}[/]\n$[/]", new_line_start=False)
17+
command = input(" ")

unix_commands.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import os, animation, termcolor
2+
import socket
3+
from rich import print
4+
from rich.console import Console
5+
import time
6+
import datetime
7+
from colorama import Fore
8+
from rich.table import Table
9+
from rich.syntax import Syntax
10+
11+
console = Console()
12+
commands = ["touch", "mkdir", "ls", "cat"]
13+
path = os.getcwd()
14+
name = socket.gethostname()
15+
user = os.getlogin()
16+
path = path.replace("\\", "/")
17+
path = path.removeprefix("C:/Users/DEBARKA NASKAR/")
18+
now = datetime.datetime.now()
19+
day = now.strftime("%d")
20+
month = now.strftime("%m")
21+
year = now.strftime("%Y")
22+
date = day + "-" + month + "-" + year
23+
time = datetime.datetime.now().strftime("%H:%M")
24+
animation.animate()
25+
while True:
26+
console.print(f"[bold][chartreuse1]{user}@{name}[/] [magenta2]UNIX[/] [gold1]~{'/' + path}[/]\n$[/]", end='')
27+
command = input(" ")
28+
if command.startswith("touch"):
29+
file = command.split()
30+
try:
31+
with open(file[1], "w") as f:
32+
f.write("")
33+
length = os.stat(file[1]).st_size
34+
table = Table(title=f"Directory: {os.getcwd()}")
35+
table.add_column("Mode", style="chartreuse1")
36+
table.add_column("LastWriteTime", style="light_green")
37+
table.add_column("Length", style="aquamarine1")
38+
table.add_column("Name", style="dark_slate_gray1")
39+
table.add_row("-a----", f"{str(date)}\t{str(time)}", str(length), file[1])
40+
console.print(table)
41+
except IndexError:
42+
print(f"{file[0]}: missing file operand")
43+
if command.startswith("mkdir"):
44+
file = command.split()
45+
nPath = os.path.join(os.getcwd(), file[1])
46+
os.mkdir(nPath)
47+
name = file[1]
48+
table = Table(title=f"Directory: {os.getcwd()}")
49+
table.add_column("Mode", style="chartreuse1")
50+
table.add_column("LastWriteTime", style="light_green")
51+
table.add_column("Length", style="aquamarine1")
52+
table.add_column("Name", style="dark_slate_gray1")
53+
table.add_row("-a----", f"{str(date)}\t{str(time)}", "", file[1])
54+
console.print(table)
55+
56+
if command == commands[2]:
57+
listDir = os.listdir()
58+
for i in listDir:
59+
ifDir = os.path.isdir(i)
60+
if ifDir:
61+
index = listDir.index(i)
62+
listDir[index] = termcolor.colored(f"{listDir[index]}/", "green")
63+
else: console.print("unix: mkdir: file doesn't exist")
64+
print(' '.join(listDir))
65+
66+
if command.startswith("cat"):
67+
file = command.split()
68+
with open(file[1], "r") as f:
69+
syntax = Syntax.from_path(file[1], line_numbers=True)
70+
console.print(syntax)
71+
72+
if command.startswith("cp"):
73+
file = command.split()
74+
length = file.__len__()
75+
if length == 1: console.print("[magenta2]unix: [gold1]cp: missing file operand")
76+
if length == 2: console.print("[magenta2]unix: [gold1]cp: missing file to copy content")
77+
else:
78+
with open(file[1], "r") as f:
79+
content = f.read()
80+
with open(file[2], 'a') as q:
81+
q.write(f"\n{content}")
82+
83+
if command.startswith("del"):
84+
file = command.split()
85+
length = file.__len__()
86+
if length == 1: console.print("[magenta2]unix: [gold1]del: missing file operand")
87+
else: os.remove(file[1])
88+
89+
if command.startswith('mv'):
90+
file = command.split()
91+
length = file.__len__()
92+
if length == 1: console.print("[magenta2]unix: [gold1]mv: missing file operand")
93+
if length == 2: console.print("[magenta2]unix: [gold1]mv: missing file to move content")
94+
else:
95+
try:
96+
with open(file[1], "r") as f:
97+
content = f.read()
98+
with open(file[2], 'a') as q:
99+
q.write(f"\n{content}")
100+
os.remove(file[1])
101+
except: ...

0 commit comments

Comments
 (0)