-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
207 lines (175 loc) · 5.21 KB
/
main.py
File metadata and controls
207 lines (175 loc) · 5.21 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
import cmd
import os
import sys
import termcolor as tc
from ext import *
from time import sleep
import term
def start():
print('sys1.0.0')
term.pos(1,0)
def cipher():
# Caesar Cipher
MAX_KEY_SIZE = 26
def getMode():
while True:
print('Do you wish to encrypt or decrypt a message?')
mode = input().lower()
if mode in 'encrypt e decrypt d'.split():
return mode
else:
print('Enter either "encrypt" or "e" or "decrypt" or "d".')
def getMessage():
print('Enter your message:')
return input()
def getKey():
key = 0
while True:
print('Enter the key number (1-%s)' % (MAX_KEY_SIZE))
key = int(input())
if (key >= 1 and key <= MAX_KEY_SIZE):
return key
def getTranslatedMessage(mode, message, key):
if mode[0] == 'd':
key = -key
translated = ''
for symbol in message:
if symbol.isalpha():
num = ord(symbol)
num += key
if symbol.isupper():
if num > ord('Z'):
num -= 26
elif num < ord('A'):
num += 26
elif symbol.islower():
if num > ord('z'):
num -= 26
elif num < ord('a'):
num += 26
translated += chr(num)
else:
translated += symbol
return translated
mode = getMode()
message = getMessage()
key = getKey()
print('Result:')
print(getTranslatedMessage(mode, message, key))
acc = 'user/' + input('Login $ ')
type = getExtIndex(f'{acc}/info.ext', 1)
def check():
if type.lower() == 'root':
ps = input('Password $ ')
password = getExtIndex(f'{acc}/info.ext', 2)
if ps == password:
pass
else:
print(tc.colored(f'Password {ps} is incorrect', 'red'))
check()
check()
os.system('clear')
start()
class CMD(cmd.Cmd):
intro = 'Simple command processor\nType "help" for a list of commands'
type = getExtIndex(f'{acc}/info.ext', 1)
if type.lower() == 'dev':
prompt = tc.colored("CMD ", 'green') + '- DEV $ '
elif type.lower() == 'root':
prompt = tc.colored("CMD ", 'green') + '- ROOT $ '
else:
prompt = tc.colored("CMD ", 'green') + '$ '
def do_echo(self, text):
"""echo [text]
Echo [text] to terminal"""
if text:
print(text)
else:
print()
def do_enc(self, any):
"""enc
Open cipher tool"""
cipher()
def do_eval(self, problem):
"""eval [problem]
Solve [problem] and echo result to terminal"""
if problem:
print(eval(problem))
else:
pass
def do_cls(self, any):
"""cls
Clear terminal screen"""
os.system('clear')
type = getExtIndex(f'{acc}/info.ext', 1)
start()
print('Simple command processor\nType "help" for a list of commands')
def do_2048(self, any):
"""2048
Open 2048 game"""
os.system('py2048')
def do_new(self, username):
"""new [username]
Make a new account"""
if type.lower() == 'root':
if username:
try:
os.mkdir('user/' + username)
file = open(f'user/{username}/info.ext', 'a')
file.write(f'{username}&dev')
file.close()
except:
pass
def do_app(self, file):
"""app [file]
Open app named [file]"""
os.system(f'python apps/{file}.py')
def do_python(self, any):
"""python
Open Python command interpreter"""
os.system('python')
def do_system(self, cmd):
"""system [cmd]
Run Linux command [cmd]"""
os.system(cmd)
def do_user(self, any):
"""user
Change user"""
os.system('clear')
os.system('python term.py')
def do_zx(self, file):
"""zx [file]
Run ZX script [file]"""
os.system(f'python zx.py {acc}/{file}.zx')
def do_info(self, tag):
"""info [tag]
Echo info from catagory [tag] to terminal
Tags: sys, cmd"""
if tag:
if tag.lower() == "sys":
user = getExtIndex(f'{acc}/info.ext', 0)
type = getExtIndex(f'{acc}/info.ext', 1)
print(f'ⓘ System:\n- Name: {user}\n- Type: {type}')
elif tag.lower() == 'cmd':
print('ⓘ CMD:\n- Version: v1.0.0\n- Build: 787839')
else:
pass
def do_whoami(self, any):
"""whoami
Echo username to terminal"""
user = getExtIndex(f'{acc}/info.ext', 0)
print(user)
def do_wait(self, time):
"""wait [time]
Wait for [time] seconds"""
sleep(int(time))
def do_restart(self, any):
"""restart
Restart CMD"""
sleep(int(1))
os.system('clear')
os.system('python term.py')
def postloop(self):
print()
if __name__ == '__main__':
CMD().cmdloop()