Mon, 28 Feb 2022 19:44:36 +0100
Changed calls to subprocess.call() and subprocess.check_output() to use subprocess.run().
--- a/eric7/DocumentationTools/QtHelpGenerator.py Mon Feb 28 17:10:59 2022 +0100 +++ b/eric7/DocumentationTools/QtHelpGenerator.py Mon Feb 28 19:44:36 2022 +0100 @@ -276,7 +276,7 @@ shutil.copy( os.path.join(self.outputDir, HelpProjectFile), self.htmlDir) os.chdir(self.htmlDir) - subprocess.call([ # secok + subprocess.run([ # secok qhelpgeneratorExe, HelpProjectFile, "-o", os.path.join(self.outputDir, HelpHelpFile)]) os.remove(HelpProjectFile) @@ -286,7 +286,7 @@ sys.stdout.flush() sys.stderr.flush() os.chdir(self.outputDir) - subprocess.call([ # secok + subprocess.run([ # secok qhelpgeneratorExe, HelpCollectionProjectFile, "-o", HelpCollectionFile])
--- a/eric7/Utilities/__init__.py Mon Feb 28 17:10:59 2022 +0100 +++ b/eric7/Utilities/__init__.py Mon Feb 28 19:44:36 2022 +0100 @@ -1277,11 +1277,11 @@ # we are on a Linux or macOS platform for mountCommand in ["mount", "/sbin/mount", "/usr/sbin/mount"]: with contextlib.suppress(FileNotFoundError): - mountOutput = ( - subprocess.check_output(mountCommand).splitlines() # secok - ) + mountOutput = subprocess.run( # secok + mountCommand, check=True, capture_output=True, text=True + ).stdout.splitlines() mountedVolumes = [ - x.decode("utf-8").split(" type")[0].split(maxsplit=2)[2] + x.split(" type")[0].split(maxsplit=2)[2] for x in mountOutput ] if findAll:
--- a/scripts/install.py Mon Feb 28 17:10:59 2022 +0100 +++ b/scripts/install.py Mon Feb 28 19:44:36 2022 +0100 @@ -1055,7 +1055,7 @@ os.path.join(os.path.dirname(__file__), "create_windows_links.py"), ] - subprocess.call(args) # secok + subprocess.run(args) # secok else: print( "\nThe Python package 'pywin32' is not installed. Desktop and" @@ -1389,10 +1389,10 @@ .format(message, packageName), end=" ") answer = input() # secok if answer in ("", "Y", "y"): - exitCode = subprocess.call( # secok + exitCode = subprocess.run( # secok [sys.executable, "-m", "pip", "install", "--prefer-binary", "--upgrade", packageName] - ) + ).returncode ok = (exitCode == 0) return ok @@ -1406,11 +1406,11 @@ @rtype bool """ try: - pipOut = subprocess.check_output([ # secok - sys.executable, "-m", "pip", "list", "--outdated", - "--format=json" - ]) - pipOut = pipOut.decode() + pipOut = subprocess.run( # secok + [sys.executable, "-m", "pip", "list", "--outdated", + "--format=json"], + check=True, capture_output=True, text=True + ).stdout except (OSError, subprocess.CalledProcessError): pipOut = "[]" # default empty list try: @@ -1439,7 +1439,7 @@ print("Shall 'pip' be updated (recommended)? (Y/n)", end=" ") answer = input() # secok if answer in ("", "Y", "y"): - subprocess.call( # secok + subprocess.run( # secok [sys.executable, "-m", "pip", "install", "--upgrade", "pip"]) @@ -1797,8 +1797,10 @@ ) for hg in (localHg, "hg"): with contextlib.suppress(OSError, subprocess.CalledProcessError): - hgOut = subprocess.check_output([hg, "identify", "-i"]) # secok - hgOut = hgOut.decode() + hgOut = subprocess.run( # secok + [hg, "identify", "-i"], check=True, + capture_output=True, text=True + ).stdout if hgOut: break else:
--- a/setup.py Mon Feb 28 17:10:59 2022 +0100 +++ b/setup.py Mon Feb 28 19:44:36 2022 +0100 @@ -141,8 +141,10 @@ with contextlib.suppress(OSError): os.rename(fileName, fileName + ".orig") try: - hgOut = subprocess.check_output(["hg", "identify", "-i"]) # secok - hgOut = hgOut.decode() + hgOut = subprocess.run( # secok + ["hg", "identify", "-i"], check=True, + capture_output=True, text=True + ).stdout except (OSError, subprocess.CalledProcessError): hgOut = "" if hgOut: