-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpyshell.py
executable file
·110 lines (97 loc) · 3.86 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/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 2015-2024 Game Maker 2k - https://github.com/GameMaker2k
Copyright 2015-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
$FileInfo: pyshell.py - Last Update: 10/17/2024 Ver. 0.9.6 RC 1 - Author: cooldude2k $
'''
from __future__ import absolute_import, division, print_function, unicode_literals, generators, with_statement, nested_scopes
import code
import os
import re
import readline
import sys
import traceback
from sys import argv
import pyhockeystats
from pyhockeystats 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 " +
pyhockeystats.__program_name__+" "+pyhockeystats.__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 " +
pyhockeystats.__program_name__+" "+pyhockeystats.__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(pyhockeystats.__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)