install-debugclients.py

Sun, 24 Jul 2016 16:50:04 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 24 Jul 2016 16:50:04 +0200
changeset 5053
dac4920b55ad
child 5145
95947ce71171
permissions
-rw-r--r--

Added scripts to just install the eric6 debug clients in an eric6DebugClients package

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
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 # Copyright (c) 2016 Detlev Offenbach <detlev@die-offenbachs.de>
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
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 import cStringIO as io
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 import sip
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 sip.setapi('QString', 2)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 sip.setapi('QVariant', 2)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 sip.setapi('QTextStream', 2)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 except (ImportError):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import io # __IGNORE_WARNING__
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 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
25 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
26 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
27 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
28 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
29 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
30 import distutils.sysconfig
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 # 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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41 sourceDir = "eric"
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 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
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 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
47
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @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
49 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 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
51
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 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
53 # different meaning of input between Py2 and Py3
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 input("Press enter to continue...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 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
57 pass
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 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
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 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
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
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 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
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 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
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 @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
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 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
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 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 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
74 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
75 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
76 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
77 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
78 else:
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] [-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
80 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
81 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
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 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
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
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 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
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 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
96 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
97 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 global modDir, pyModDir
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 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
101 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
102
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 def copyTree(src, dst, filters, excludeDirs=[], excludePatterns=[]):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 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
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 @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
109 @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
110 @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
111 @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
112 @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
113 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
114 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
116 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
117 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
118 # 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
119 return
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 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
122 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
123 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
124 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
125 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
126 break
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 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
128 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
129 dstname = os.path.join(dst, name)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 for filter in filters:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 if fnmatch.fnmatch(srcname, filter):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 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
133 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
134 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
135 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
136 break
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 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
139 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
140 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
141
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 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
144 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 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
146 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
147
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 @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
149 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 # 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
151 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
152 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
153 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
154 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
155 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
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 # 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
158 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
159 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
160 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
161 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
162 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
163 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
164
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 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
167 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 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
169 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 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
171
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 # 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
174 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
175 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
176 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
177 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
178 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
179 '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
180 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
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
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 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
184 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 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
186
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 @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
188 @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
189 @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
190 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 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
192 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
193 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
194 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
195
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 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
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 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
200
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 @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
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 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
204
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 # 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
206 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
207 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
208 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 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
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 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 # 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
213 # 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
214 copyTree(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 os.path.join(sourceDir, "DebugClients"), targetDir,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 ['*.py', '*.pyc', '*.pyo', '*.pyw'],
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 ['{1}{0}.ropeproject'.format(os.sep, sourceDir)],
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 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
219 copyTree(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 os.path.join(sourceDir, "DebugClients"), targetDir,
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 ['*.rb'],
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 ['{1}{0}Examples'.format(os.sep, sourceDir)])
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 # copy the license file
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 shutilCopy(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 '{1}{0}LICENSE.GPL3'.format(os.sep, sourceDir), targetDir)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 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
229 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
230 '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
231 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
232
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 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
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
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 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
237 """
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 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
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 @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
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 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
243
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 # 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
245 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
246 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
247
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 if sys.version_info < (2, 7, 0) or sys.version_info > (3, 9, 9):
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 print('Sorry, eric6 requires at least Python 2.7 or '
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 'Python 3 for running.')
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 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
252
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 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
254
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 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
256 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
257
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258 initGlobals()
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 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 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
262 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
263 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
264 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
265 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
266 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
267 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 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
269 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
270 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
271 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
272 usage()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 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
275 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
276 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
277 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
278 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
279 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
280 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
281 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
282 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
283 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
284 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
285
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 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
287 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
288 sourceDir = os.path.dirname(__file__) or "."
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 # 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
291 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
292 print("Cleaning up source ...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 cleanupSource(os.path.join(sourceDir, "DebugClients"))
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 # 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
297 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 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
299 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
300 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
301 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
302 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 cleanUp()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 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
305 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
306 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
307
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 doCompile:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 print("\nCompiling source files ...")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 if sys.version_info[0] == 3:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 skipRe = re.compile(r"DebugClients[\\/]Python[\\/]")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 skipRe = re.compile(r"DebugClients[\\/]Python3[\\/]")
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 # Hide compile errors (mainly because of Py2/Py3 differences)
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 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
316 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
317 compileall.compile_dir(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 os.path.join(sourceDir, "DebugClients"),
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 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
320 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
321 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
322 else:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 compileall.compile_dir(
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 os.path.join(sourceDir, "DebugClients"),
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 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
326 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
327 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
328 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
329 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
330 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
331
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 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
333 print()
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 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
336
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 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
339 try:
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 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
341 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
342 raise
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 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
344 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
345 """ 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
346 """ 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
347 raise
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 #
dac4920b55ad Added scripts to just install the eric6 debug clients in an eric6DebugClients package
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 # eflag: noqa = M801

eric ide

mercurial