-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommands.py
More file actions
58 lines (38 loc) · 932 Bytes
/
Commands.py
File metadata and controls
58 lines (38 loc) · 932 Bytes
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
import os
import shutil
def ls():
dirs = os.listdir()
for obj in dirs:
print(f" {obj}")
def pwd():
return os.getcwd()
def whoami():
return os.getlogin()
def cd(directory):
try:
os.chdir(str(directory))
except PermissionError:
print("Access Denied")
except FileNotFoundError:
print("Incorrect file directory")
def mkdir(path):
try:
os.mkdir(path)
except FileNotFoundError:
print("File Already Exists")
except FileExistsError:
print("File Already Exists")
def rm(path, mode):
if mode == "dir":
shutil.rmtree(path)
elif mode == "file":
try:
os.remove(path)
except FileNotFoundError:
print("File does not exist exists")
# MISC
commandList = ["ls", "pwd", "whoami", "cd", "ls"]
def cmd_list():
return commandList
# commandCheck()
# rm("./hello.txt", "file")