Add files via upload
[PyCatFile.git] / pyshell-old.py
blob24a8d27bc444021db345cf4e5f2836a303678312
1 #!/usr/bin/env python
3 '''
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Revised BSD License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 Revised BSD License for more details.
12 Copyright 2018-2024 Cool Dude 2k - http://idb.berlios.de/
13 Copyright 2018-2024 Game Maker 2k - http://intdb.sourceforge.net/
14 Copyright 2018-2024 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16 $FileInfo: pyshell-old.py - Last Update: 5/2/2024 Ver. 0.9.8 RC 1 - Author: cooldude2k $
17 '''
19 from __future__ import print_function
20 import sys, traceback, code, re, readline, pycatfile;
21 from sys import argv;
22 from pycatfile import *;
24 taskfound=False;
25 if(len(sys.argv)<2):
26 taskfound=True;
27 ps1="PyShell "+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+"> ";
28 cmdinput=None;
29 print("PyShell "+sys.version+" on "+sys.platform+"\nLoaded Python module PyCatFile "+pycatfile.__version__+"\n");
30 while(True):
31 try:
32 cmdinput = code.InteractiveConsole().raw_input(ps1);
33 except KeyboardInterrupt:
34 print("\nKeyboardInterrupt");
35 except EOFError:
36 print("");
37 sys.exit(0);
38 except Exception:
39 traceback.print_exc();
40 ## exec(str(cmdinput));
41 try:
42 exec(code.compile_command(str(cmdinput)));
43 except Exception:
44 traceback.print_exc();
45 sys.exit(0);
47 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"):
48 taskfound=True;
49 ps1="PyShell "+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2])+"> ";
50 cmdinput=None;
51 print("PyShell "+sys.version+" on "+sys.platform+"\nLoaded Python module PyCatFile "+pycatfile.__version__+"\n");
52 while(True):
53 try:
54 cmdinput = code.InteractiveConsole().raw_input(ps1);
55 except KeyboardInterrupt:
56 print("\nKeyboardInterrupt");
57 except EOFError:
58 print("");
59 sys.exit(0);
60 except Exception:
61 traceback.print_exc();
62 ## exec(str(cmdinput));
63 try:
64 exec(code.compile_command(str(cmdinput)));
65 except Exception:
66 traceback.print_exc();
67 sys.exit(0);
69 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"):
70 taskfound=True;
71 if(len(sys.argv)<3):
72 print(str("command: "+sys.argv[0]+"\narguments: "+sys.argv[1]+"\nerror: syntax error missing arguments"));
73 sys.exit(0);
74 shebang = "".join(open(sys.argv[2], "r").readlines());
75 exec(compile(str(shebang), "", "exec"));
76 sys.exit(0);
78 if(sys.argv[1]=="exec" or sys.argv[1]=="run" or sys.argv[1]=="execute"):
79 taskfound=True;
80 argcmd = list(sys.argv);
81 argcmd[0:1] = [];
82 argcmd = list(argcmd);
83 argcmd[0:1] = [];
84 argcmd = list(argcmd);
85 argcmd = " ".join(argcmd);
86 exec(argcmd);
88 if(not taskfound):
89 print(str("command: "+sys.argv[0]+"\narguments: "+sys.argv[1]+"\nerror: syntax error missing arguments"));
90 sys.exit(0);