-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathXaviShell.py
More file actions
151 lines (133 loc) · 3.85 KB
/
XaviShell.py
File metadata and controls
151 lines (133 loc) · 3.85 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
'''
Xavi Standard Audio Service
Shell Service
Author:: Sam F // PyGoose // https://github.com/SimLoads
'''
Version = '030620.5x0010'
'''
Release Version:: 0.0.2
/NOTES/
'''
import os,sys,cmd,inspect,ctypes
asLogo='''
__ __ _ ____ _ ____
\ \/ /__ ___ _(_) ___| / \ / ___|
\ // _` \ \ / / \___ \ / _ \ \___ \
/ \ (_| |\ V /| |___) / ___ \ ___) |
/_/\_\__,_| \_/ |_|____/_/ \_\____/
'''
def reboot():
print("Restarting shell...")
os.startfile(sys.argv[0])
exit()
def errorHandle(error):
print("An error occured.")
print("Reason given:")
print("")
print(error)
return()
def query(command):
try:
print(helpdict.get(command))
except:
print("Unrecognized command")
def startupCheck():
print("Xavi Shell Service")
print("Version %s" % Version)
ctypes.windll.kernel32.SetConsoleTitleW("Xavi Shell %s" % Version)
print("")
if os.path.exists("xavi"):
sys.path.insert(0, 'xavi')
import Xavi,XaviSNS
else:
errorHandle("Xavi Directory is missing.")
input()
exit()
print(asLogo)
takeInput()
def xs_help():
print("XaviShell Help\n\nCommands:\n")
for key, value in helpdict.items():
print('%s: %s' %(key, value))
def execdir(request=False):
if request:
with open('.xaviconf', 'r') as xfc:
current = xfc.read()
xfc.close()
return(current.split(' >< ')[0])
with open('.xaviconf', 'r') as xfc:
current = xfc.read()
print("Current directory: " + (current.split(' >< ')[0]))
xfc.close()
with open('.xaviconf', 'w') as xfc:
ndir = input("Enter absolute directory of Python executable or 'python' to reset: ")
if os.path.exists(ndir) and '.exe' in ndir or ndir == 'python':
cr = current.split(' >< ')
del cr[0]
cr.insert(0,ndir)
toWrite = ' >< '.join(cr)
xfc.write(toWrite)
else:
xfc.write(current)
print("Invalid")
def cmod():
os.startfile('.xaviconf')
def execCm(process):
run = ("%s XaviSNS.py -c %s" %((execdir(True)), process))
os.system(run)
return
def forceExec(process):
run = ("%s XaviSNS.py %s" %((execdir(True)), process))
os.system(run)
return
def takeInput():
try:
print("")
process = input("xavi|>")
if "query" in process:
com = input("command >> ")
query(com)
takeInput()
elif process in cmList:
(cmList[process])()
takeInput()
else:
if process == "exit":
exit()
if process[:2] == '--':
forceExec(process[1:])
execCm(process)
takeInput()
except EOFError:
exit()
except KeyboardInterrupt:
exit()
cmList = {
"exit": exit,
"reboot": reboot,
"edir": execdir,
"help": xs_help,
"query": query
}
helpdict = {
"exit": "Closes the program.",
"reboot": "Closes the program, then opens a new instance of it.",
"force": "Forces a command to pass directly into XaviSNS. Use 'return' to return.",
"edir": "Set where XaviShell calls python from, either $PATH or an absolute directoy.",
"query": "Get help for specific command",
"help": "Displays the help menu.",
"livebridge": "See XaviSNS for help.",
"testwave": "See XaviSNS for help.",
"tempo": "See XaviSNS for help.",
"getsamples": "See XaviSNS for help."
}
if __name__ == "__main__":
defaultItems = "python >< true >< true"
if os.path.exists(".xaviconf"):
with open('.xaviconf', 'r') as xfc:
confItems = (xfc.read()).split(" >< ")
else:
with open('.xaviconf', 'w') as xfc:
xfc.write(defaultItems)
confItems = defaultItems.split(" >< ")
startupCheck()