-
Notifications
You must be signed in to change notification settings - Fork 1
/
pyshell.py
executable file
·95 lines (84 loc) · 3.32 KB
/
pyshell.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
#!/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.py - Last Update: 7/10/2024 Ver. 0.13.12 RC 1 - Author: cooldude2k $
'''
from __future__ import division, absolute_import, print_function;
import sys, os, traceback, code, re, readline, 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+os.linesep+"Loaded Python module "+pycatfile.__program_name__+" "+pycatfile.__version__+os.linesep);
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+os.linesep+"Loaded Python module "+pycatfile.__program_name__+" "+pycatfile.__version__+os.linesep);
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]+os.linesep+"arguments: "+sys.argv[1]+os.linesep+"error: 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]=="version" or sys.argv[1]=="ver" or sys.argv[1]=="getversion" or sys.argv[1]=="getver"):
taskfound=True;
print(pycatfile.__version__);
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]+os.linesep+"arguments: "+sys.argv[1]+os.linesep+"error: syntax error missing arguments"));
sys.exit(0);