scripts/install-debugclients.py

branch
eric7-maintenance
changeset 10460
3b34efa2857c
parent 10439
21c28b0f9e41
child 10781
0e3d6e22efaf
equal deleted inserted replaced
10366:411df92e881f 10460:3b34efa2857c
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 # Copyright (c) 2016 - 2023 Detlev Offenbach <detlev@die-offenbachs.de> 4 # Copyright (c) 2016 - 2024 Detlev Offenbach <detlev@die-offenbachs.de>
5 # 5 #
6 # This is the install script for the eric debug client. It may be used 6 # This is the install script for the eric debug client. It may be used
7 # to just install the debug clients for remote debugging. 7 # to just install the debug clients for remote debugging.
8 # 8 #
9 9
39 39
40 def exit(rcode=0): 40 def exit(rcode=0):
41 """ 41 """
42 Exit the install script. 42 Exit the install script.
43 43
44 @param rcode result code to report back (integer) 44 @param rcode result code to report back
45 @type int
45 """ 46 """
46 global currDir 47 global currDir
47 48
48 if sys.platform.startswith("win"): 49 if sys.platform.startswith("win"):
49 with contextlib.suppress(EOFError): 50 with contextlib.suppress(EOFError):
77 def copyTree(src, dst, filters, excludeDirs=None, excludePatterns=None): 78 def copyTree(src, dst, filters, excludeDirs=None, excludePatterns=None):
78 """ 79 """
79 Copy files of a directory tree. 80 Copy files of a directory tree.
80 81
81 @param src name of the source directory 82 @param src name of the source directory
83 @type str
82 @param dst name of the destination directory 84 @param dst name of the destination directory
85 @type str
83 @param filters list of filter pattern determining the files to be copied 86 @param filters list of filter pattern determining the files to be copied
87 @type list of str
84 @param excludeDirs list of (sub)directories to exclude from copying 88 @param excludeDirs list of (sub)directories to exclude from copying
89 @type list of str
85 @param excludePatterns list of filter pattern determining the files to 90 @param excludePatterns list of filter pattern determining the files to
86 be skipped 91 be skipped
92 @type str
87 """ 93 """
88 if excludeDirs is None: 94 if excludeDirs is None:
89 excludeDirs = [] 95 excludeDirs = []
90 if excludePatterns is None: 96 if excludePatterns is None:
91 excludePatterns = [] 97 excludePatterns = []
119 def cleanupSource(dirName): 125 def cleanupSource(dirName):
120 """ 126 """
121 Cleanup the sources directory to get rid of leftover files 127 Cleanup the sources directory to get rid of leftover files
122 and directories. 128 and directories.
123 129
124 @param dirName name of the directory to prune (string) 130 @param dirName name of the directory to prune
131 @type str
125 """ 132 """
126 # step 1: delete the __pycache__ directory and all *.pyc files 133 # step 1: delete the __pycache__ directory and all *.pyc files
127 if os.path.exists(os.path.join(dirName, "__pycache__")): 134 if os.path.exists(os.path.join(dirName, "__pycache__")):
128 shutil.rmtree(os.path.join(dirName, "__pycache__")) 135 shutil.rmtree(os.path.join(dirName, "__pycache__"))
129 for name in [f for f in os.listdir(dirName) if fnmatch.fnmatch(f, "*.pyc")]: 136 for name in [f for f in os.listdir(dirName) if fnmatch.fnmatch(f, "*.pyc")]:
146 153
147 try: 154 try:
148 # Cleanup the install directories 155 # Cleanup the install directories
149 dirname = os.path.join(pyModDir, installPackage) 156 dirname = os.path.join(pyModDir, installPackage)
150 if os.path.exists(dirname): 157 if os.path.exists(dirname):
151 shutil.rmtree(dirname, True) 158 shutil.rmtree(dirname, ignore_errors=True)
152 except OSError as msg: 159 except OSError as msg:
153 sys.stderr.write("Error: {0}\nTry install with admin rights.\n".format(msg)) 160 sys.stderr.write("Error: {0}\nTry install with admin rights.\n".format(msg))
154 exit(7) 161 exit(7)
155 162
156 163
157 def shutilCopy(src, dst, perm=0o644): 164 def shutilCopy(src, dst, perm=0o644):
158 """ 165 """
159 Wrapper function around shutil.copy() to ensure the permissions. 166 Wrapper function around shutil.copy() to ensure the permissions.
160 167
161 @param src source file name (string) 168 @param src source file name
162 @param dst destination file name or directory name (string) 169 @type str
163 @param perm permissions to be set (integer) 170 @param dst destination file name or directory name
171 @type str
172 @param perm permissions to be set
173 @type int
164 """ 174 """
165 shutil.copy(src, dst) 175 shutil.copy(src, dst)
166 if os.path.isdir(dst): 176 if os.path.isdir(dst):
167 dst = os.path.join(dst, os.path.basename(src)) 177 dst = os.path.join(dst, os.path.basename(src))
168 os.chmod(dst, perm) 178 os.chmod(dst, perm)
170 180
171 def installEricDebugClients(): 181 def installEricDebugClients():
172 """ 182 """
173 Actually perform the installation steps. 183 Actually perform the installation steps.
174 184
175 @return result code (integer) 185 @return result code
186 @rtype int
176 """ 187 """
177 global distDir, doCleanup, sourceDir, modDir 188 global distDir, doCleanup, sourceDir, modDir
178 189
179 # set install prefix, if not None 190 # set install prefix, if not None
180 targetDir = ( 191 targetDir = (
401 412
402 def main(argv): 413 def main(argv):
403 """ 414 """
404 The main function of the script. 415 The main function of the script.
405 416
406 @param argv the list of command line arguments. 417 @param argv the list of command line arguments
418 @type list of str
407 """ 419 """
408 global modDir, doCleanup, doCompile, distDir 420 global modDir, doCleanup, doCompile, distDir
409 global sourceDir, eric7SourceDir 421 global sourceDir, eric7SourceDir
410 422
411 if sys.version_info < (3, 8, 0) or sys.version_info >= (4, 0, 0): 423 if sys.version_info < (3, 8, 0) or sys.version_info >= (4, 0, 0):
448 # cleanup old installation 460 # cleanup old installation
449 try: 461 try:
450 if doCleanup: 462 if doCleanup:
451 print("Cleaning up old installation ...", end="", flush=True) 463 print("Cleaning up old installation ...", end="", flush=True)
452 if distDir: 464 if distDir:
453 shutil.rmtree(distDir, True) 465 shutil.rmtree(distDir, ignore_errors=True)
454 else: 466 else:
455 cleanUp() 467 cleanUp()
456 print(" Done") 468 print(" Done")
457 except OSError as msg: 469 except OSError as msg:
458 sys.stderr.write("Error: {0}\nTry install as root.\n".format(msg)) 470 sys.stderr.write("Error: {0}\nTry install as root.\n".format(msg))

eric ide

mercurial