-
Notifications
You must be signed in to change notification settings - Fork 1
/
pyshell-old.py
executable file
·103 lines (93 loc) · 3.59 KB
/
pyshell-old.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
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
#!/usr/bin/env python
'''
This program is free software; you can redistribute it and/or modify
it under the terms of the Revised BSD License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Revised BSD License for more details.
Copyright 2018-2024 Cool Dude 2k - http://idb.berlios.de/
Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
$FileInfo: pyshell-old.py - ast Update: 10/22/2024 Ver. 0.14.2 RC 1 - Author: cooldude2k $
'''
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
import sys
import traceback
import code
import re
import readline
import pycatfile
from sys import argv
from pycatfile import *
taskfound = False
if(len(sys.argv) < 2):
taskfound = True
ps1 = "PyShell " + \
str(sys.version_info[0])+"."+str(sys.version_info[1]
)+"."+str(sys.version_info[2])+"> "
cmdinput = None
print("PyShell "+sys.version+" on "+sys.platform +
"\nLoaded Python module PyCatFile "+pycatfile.__version__+"\n")
while(True):
try:
cmdinput = code.InteractiveConsole().raw_input(ps1)
except KeyboardInterrupt:
print("\nKeyboardInterrupt")
except EOFError:
print("")
sys.exit(0)
except Exception:
traceback.print_exc()
# exec(str(cmdinput));
try:
exec(code.compile_command(str(cmdinput)))
except Exception:
traceback.print_exc()
sys.exit(0)
if(sys.argv[1] == "sh" or sys.argv[1] == "shell" or sys.argv[1] == "pysh" or sys.argv[1] == "pyshell" or sys.argv[1] == "python"):
taskfound = True
ps1 = "PyShell " + \
str(sys.version_info[0])+"."+str(sys.version_info[1]
)+"."+str(sys.version_info[2])+"> "
cmdinput = None
print("PyShell "+sys.version+" on "+sys.platform +
"\nLoaded Python module PyCatFile "+pycatfile.__version__+"\n")
while(True):
try:
cmdinput = code.InteractiveConsole().raw_input(ps1)
except KeyboardInterrupt:
print("\nKeyboardInterrupt")
except EOFError:
print("")
sys.exit(0)
except Exception:
traceback.print_exc()
# exec(str(cmdinput));
try:
exec(code.compile_command(str(cmdinput)))
except Exception:
traceback.print_exc()
sys.exit(0)
if(sys.argv[1] == "shebang" or sys.argv[1] == "shabang" or sys.argv[1] == "hashbang" or sys.argv[1] == "poundbang" or sys.argv[1] == "hashexclam" or sys.argv[1] == "hashpling"):
taskfound = True
if(len(sys.argv) < 3):
print(str("command: "+sys.argv[0]+"\narguments: " +
sys.argv[1]+"\nerror: syntax error missing arguments"))
sys.exit(0)
shebang = "".join(open(sys.argv[2], "r").readlines())
exec(compile(str(shebang), "", "exec"))
sys.exit(0)
if(sys.argv[1] == "exec" or sys.argv[1] == "run" or sys.argv[1] == "execute"):
taskfound = True
argcmd = list(sys.argv)
argcmd[0:1] = []
argcmd = list(argcmd)
argcmd[0:1] = []
argcmd = list(argcmd)
argcmd = " ".join(argcmd)
exec(argcmd)
if(not taskfound):
print(str("command: "+sys.argv[0]+"\narguments: " +
sys.argv[1]+"\nerror: syntax error missing arguments"))
sys.exit(0)