eric6/eric6_shell.py

Wed, 29 May 2019 22:14:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 29 May 2019 22:14:02 +0200
branch
Variables Viewer
changeset 7030
73779c4c135a
parent 6949
a5255f1ba3f0
child 7192
a22eee00b052
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.

5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 #!/usr/bin/env python3
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6581
diff changeset
4 # Copyright (c) 2017 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 #
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 Eric6 Shell.
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 This is the main Python script that performs the necessary initialization
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 of the ShellWindow module and starts the Qt event loop.
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 """
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from __future__ import unicode_literals
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
16 import sys
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
17 import os
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
18
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
19 originalPathString = os.getenv("PATH")
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
20
6949
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
21 sys.path.insert(1, os.path.dirname(__file__))
a5255f1ba3f0 setup.py: continued implementing support for setup.py.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
22
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import Toolbox.PyQt4ImportHook # __IGNORE_WARNING__
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 try: # Only for Py2
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 import Globals.compatibility_fixes # __IGNORE_WARNING__
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 except (ImportError):
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 pass
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 for arg in sys.argv[:]:
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 if arg.startswith("--config="):
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 import Globals
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 configDir = arg.replace("--config=", "")
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 Globals.setConfigDir(configDir)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 sys.argv.remove(arg)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 elif arg.startswith("--settings="):
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 from PyQt5.QtCore import QSettings
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 settingsDir = os.path.expanduser(arg.replace("--settings=", ""))
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 if not os.path.isdir(settingsDir):
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 os.makedirs(settingsDir)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 QSettings.setPath(QSettings.IniFormat, QSettings.UserScope,
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 settingsDir)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 sys.argv.remove(arg)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 from Globals import AppInfo
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 from Toolbox import Startup
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 def createMainWidget(argv):
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 Function to create the main widget.
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @param argv list of commandline parameters (list of strings)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @return reference to the main widget (QWidget)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 from QScintilla.ShellWindow import ShellWindow
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
6581
8eb6220f2bb7 Shell: changed code to start the shell/debugger backend with an unmodified PATH setting and added some more special commands (see what's this help of the shell).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
59 return ShellWindow(originalPathString)
5709
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 def main():
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 Main entry point into the application.
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 """
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 options = [
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 ("--config=configDir",
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 "use the given directory as the one containing the config files"),
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 ("--settings=settingsDir",
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 "use the given directory to store the settings files"),
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 ]
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 appinfo = AppInfo.makeAppInfo(sys.argv,
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 "Eric6 Shell",
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 "",
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 "Stand alone version of the eric6"
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 " interpreter shell",
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 options)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 res = Startup.simpleAppStartup(sys.argv,
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 appinfo,
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 createMainWidget)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 sys.exit(res)
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 if __name__ == '__main__':
f81d0eca2c62 Started implementing the standalone shell window.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 main()

eric ide

mercurial