scripts/install-debugclients.py

Tue, 23 Jun 2020 17:24:18 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 23 Jun 2020 17:24:18 +0200
changeset 7637
c878e8255972
parent 7628
f904d0eef264
child 7639
422fd05e9c91
permissions
-rw-r--r--

Removed some more Python2 related code.

5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 #!/usr/bin/env python3
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
3
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7257
diff changeset
4 # Copyright (c) 2016 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5 #
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 # This is the install script for the eric6 debug client. It may be used
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 # to just install the debug clients for remote debugging.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 #
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 Installation script for the eric6 debug clients.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from __future__ import unicode_literals, print_function
7228
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
15 try:
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
16 import cStringIO as io
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
17 try:
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
18 from PyQt5 import sip
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
19 except ImportError:
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
20 import sip
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
21 sip.setapi('QString', 2)
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
22 sip.setapi('QVariant', 2)
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
23 sip.setapi('QTextStream', 2)
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
24 except (ImportError):
6037ddba57aa install-debugclients.py: reverted the Python2 related changes because the debug client still supports Python2.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7192
diff changeset
25 import io # __IGNORE_WARNING__
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 import sys
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 import os
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 import re
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import compileall
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 import shutil
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 import fnmatch
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 # Define the globals.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 progName = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 currDir = os.getcwd()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 modDir = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 pyModDir = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 distDir = None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 installPackage = "eric6DebugClients"
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 doCleanup = True
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 doCompile = True
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 sourceDir = "eric"
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
44 eric6SourceDir = os.path.join(sourceDir, "eric6")
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 def exit(rcode=0):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 Exit the install script.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 @param rcode result code to report back (integer)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 global currDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 if sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 try:
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
57 input("Press enter to continue...") # secok
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 except (EOFError, SyntaxError):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 pass
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 os.chdir(currDir)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 sys.exit(rcode)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 def usage(rcode=2):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 Display a usage message and exit.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @param rcode the return code passed back to the calling process.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 global progName, modDir, distDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 print("Usage:")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if sys.platform == "darwin":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 print(" {0} [-chz] [-d dir] [-i dir]".format(progName))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 elif sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 print(" {0} [-chz] [-d dir]".format(progName))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 print(" {0} [-chz][-d dir] [-i dir]".format(progName))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 print("where:")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 print(" -h, --help display this help message")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 print(" -d dir where eric6 debug client files will be installed")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 print(" (default: {0})".format(modDir))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 if not sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 print(" -i dir temporary install prefix")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 print(" (default: {0})".format(distDir))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 print(" -c don't cleanup old installation first")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 print(" -z don't compile the installed python files")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 exit(rcode)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 def initGlobals():
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 Module function to set the values of globals that need more than a
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 simple assignment.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 global modDir, pyModDir
6304
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
101
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
102 try:
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
103 import distutils.sysconfig
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
104 except ImportError:
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
105 print("Please install the 'distutils' package first.")
68f9aa03bf75 install: show a message to the user if the distutile package cannot be imported.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
106 exit(5)
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 modDir = distutils.sysconfig.get_python_lib(True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 pyModDir = modDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
111
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
112 def copyTree(src, dst, filters, excludeDirs=None, excludePatterns=None):
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 Copy files of a directory tree.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 @param src name of the source directory
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 @param dst name of the destination directory
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 @param filters list of filter pattern determining the files to be copied
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 @param excludeDirs list of (sub)directories to exclude from copying
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 @keyparam excludePatterns list of filter pattern determining the files to
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 be skipped
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 """
5651
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
123 if excludeDirs is None:
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
124 excludeDirs = []
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
125 if excludePatterns is None:
982465f8389c Fixed a few code style issues related to the usage of mutable types for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5597
diff changeset
126 excludePatterns = []
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 names = os.listdir(src)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 except OSError:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 # ignore missing directories
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 return
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 for name in names:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 skipIt = False
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 for excludePattern in excludePatterns:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 if fnmatch.fnmatch(name, excludePattern):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 skipIt = True
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 break
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 if not skipIt:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 srcname = os.path.join(src, name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 dstname = os.path.join(dst, name)
5597
3d88d53f8c2b Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
142 for fileFilter in filters:
3d88d53f8c2b Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
143 if fnmatch.fnmatch(srcname, fileFilter):
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 if not os.path.isdir(dst):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 os.makedirs(dst)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 shutil.copy2(srcname, dstname)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 os.chmod(dstname, 0o644)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 break
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if os.path.isdir(srcname) and srcname not in excludeDirs:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 copyTree(srcname, dstname, filters,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 excludePatterns=excludePatterns)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 def cleanupSource(dirName):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 Cleanup the sources directory to get rid of leftover files
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 and directories.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @param dirName name of the directory to prune (string)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 # step 1: delete the __pycache__ directory and all *.pyc files
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 if os.path.exists(os.path.join(dirName, "__pycache__")):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 shutil.rmtree(os.path.join(dirName, "__pycache__"))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 for name in [f for f in os.listdir(dirName)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 if fnmatch.fnmatch(f, "*.pyc")]:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 os.remove(os.path.join(dirName, name))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 # step 2: descent into subdirectories and delete them if empty
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 for name in os.listdir(dirName):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 name = os.path.join(dirName, name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 if os.path.isdir(name):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 cleanupSource(name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 if len(os.listdir(name)) == 0:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 os.rmdir(name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 def cleanUp():
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 Uninstall the old eric debug client files.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 global pyModDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 # Cleanup the install directories
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 dirname = os.path.join(pyModDir, installPackage)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 if os.path.exists(dirname):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 shutil.rmtree(dirname, True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 except (IOError, OSError) as msg:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 sys.stderr.write(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 'Error: {0}\nTry install with admin rights.\n'.format(msg))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 exit(7)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 def shutilCopy(src, dst, perm=0o644):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 Wrapper function around shutil.copy() to ensure the permissions.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 @param src source file name (string)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 @param dst destination file name or directory name (string)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 @keyparam perm permissions to be set (integer)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 shutil.copy(src, dst)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 if os.path.isdir(dst):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 dst = os.path.join(dst, os.path.basename(src))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 os.chmod(dst, perm)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 def installEricDebugClients():
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 Actually perform the installation steps.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 @return result code (integer)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 global distDir, doCleanup, sourceDir, modDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 # set install prefix, if not None
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 if distDir:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 targetDir = os.path.normpath(os.path.join(distDir, installPackage))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 targetDir = os.path.join(modDir, installPackage)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 # Install the files
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 # copy the various parts of eric6 debug clients
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 copyTree(
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
227 os.path.join(eric6SourceDir, "DebugClients"), targetDir,
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 ['*.py', '*.pyc', '*.pyo', '*.pyw'],
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
229 [os.path.join(sourceDir, ".ropeproject")],
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 excludePatterns=["eric6config.py*"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232 # copy the license file
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
233 shutilCopy(os.path.join(sourceDir, "docs", "LICENSE.GPL3"), targetDir)
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 except (IOError, OSError) as msg:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 sys.stderr.write(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 'Error: {0}\nTry install with admin rights.\n'.format(msg))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 return(7)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 return 0
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 def main(argv):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 The main function of the script.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 @param argv the list of command line arguments.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 import getopt
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 # Parse the command line.
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 global progName, modDir, doCleanup, doCompile, distDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 global sourceDir
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254
7637
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
255 if sys.version_info < (3, 5, 0) or sys.version_info >= (4, 0, 0):
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
256 print('Sorry, the eric6 debugger requires Python 3.5 or better'
c878e8255972 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
257 ' for running.')
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 exit(5)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 progName = os.path.basename(argv[0])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 if os.path.dirname(argv[0]):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 os.chdir(os.path.dirname(argv[0]))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 initGlobals()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 if sys.platform.startswith("win"):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 optlist, args = getopt.getopt(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 argv[1:], "chzd:", ["help"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 elif sys.platform == "darwin":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 optlist, args = getopt.getopt(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 argv[1:], "chzd:i:", ["help"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 optlist, args = getopt.getopt(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 argv[1:], "chzd:i:", ["help"])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 except getopt.GetoptError as err:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 print(err)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 usage()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 for opt, arg in optlist:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 if opt in ["-h", "--help"]:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 usage(0)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 elif opt == "-d":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 modDir = arg
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 elif opt == "-i":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
287 distDir = os.path.normpath(arg)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288 elif opt == "-c":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 doCleanup = False
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 elif opt == "-z":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 doCompile = False
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 installFromSource = not os.path.isdir(sourceDir)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 if installFromSource:
6959
dfb8a57de154 install-debugclients: fixed an issue causing cleanup to fail.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6942
diff changeset
295 sourceDir = os.path.abspath("..")
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
296 eric6SourceDir = os.path.join(sourceDir, "eric6")
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 # cleanup source if installing from source
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 if installFromSource:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 print("Cleaning up source ...")
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
301 cleanupSource(os.path.join(eric6SourceDir, "DebugClients"))
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 # cleanup old installation
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 if doCleanup:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 print("Cleaning up old installation ...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 if distDir:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 shutil.rmtree(distDir, True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 cleanUp()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 except (IOError, OSError) as msg:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 sys.stderr.write('Error: {0}\nTry install as root.\n'.format(msg))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 exit(7)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 if doCompile:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 print("\nCompiling source files ...")
5179
5f56410e7624 Combined version of the Python debugger.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 5145
diff changeset
318 skipRe = re.compile(r"DebugClients[\\/]Python[\\/]")
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 sys.stdout = io.StringIO()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 if distDir:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 compileall.compile_dir(
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
322 os.path.join(eric6SourceDir, "DebugClients"),
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 ddir=os.path.join(distDir, modDir, installPackage),
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 rx=skipRe,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 quiet=True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 compileall.compile_dir(
6942
2602857055c5 Major restructuring of the source tree to get prepared for a setup.py based installation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
328 os.path.join(eric6SourceDir, "DebugClients"),
5053
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 ddir=os.path.join(modDir, installPackage),
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 rx=skipRe,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 quiet=True)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 sys.stdout = sys.__stdout__
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 print("\nInstalling eric6 debug clients ...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 res = installEricDebugClients()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 print("\nInstallation complete.")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 exit(res)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 if __name__ == "__main__":
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344 main(sys.argv)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 except SystemExit:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 raise
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 except Exception:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 print("""An internal error occured. Please report all the output"""
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 """ of the program,\nincluding the following traceback, to"""
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """ eric-bugs@eric-ide.python-projects.org.\n""")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 raise
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 #
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 # eflag: noqa = M801

eric ide

mercurial