mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
No issue - Improve fallback handling and resolve PATH issues with python clobber command
This commit is contained in:
parent
6dc8a7d813
commit
b7d80962d0
1 changed files with 23 additions and 2 deletions
|
|
@ -710,15 +710,36 @@ class Clobber(MachCommandBase):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if 'python' in what:
|
if 'python' in what:
|
||||||
|
# TODO: Once we move to Python 3, we should probably use
|
||||||
|
# shutil.which to get the fully qualified path for these commands.
|
||||||
|
cmd = ''
|
||||||
if os.path.isdir(mozpath.join(self.topsrcdir, '.hg')):
|
if os.path.isdir(mozpath.join(self.topsrcdir, '.hg')):
|
||||||
cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[co]']
|
cmd = ['hg', 'purge', '--all', '-I', 'glob:**.py[co]']
|
||||||
elif os.path.isdir(mozpath.join(self.topsrcdir, '.git')):
|
elif os.path.isdir(mozpath.join(self.topsrcdir, '.git')):
|
||||||
cmd = ['git', 'clean', '-f', '-x', '*.py[co]']
|
cmd = ['git', 'clean', '-f', '-x', '*.py[co]']
|
||||||
|
|
||||||
|
if not cmd:
|
||||||
|
ret = self.clobber_python_fallback()
|
||||||
else:
|
else:
|
||||||
cmd = ['find', '.', '-type', 'f', '-name', '*.py[co]', '-delete']
|
# It is possible that git or hg is either not installed or
|
||||||
|
# excluded from PATH despite the existence of their data
|
||||||
|
# directories, so use a fallback instead of failing early.
|
||||||
|
try:
|
||||||
ret = subprocess.call(cmd, cwd=self.topsrcdir)
|
ret = subprocess.call(cmd, cwd=self.topsrcdir)
|
||||||
|
except OSError as e:
|
||||||
|
ret = self.clobber_python_fallback()
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def clobber_python_fallback(self):
|
||||||
|
cmd = ['find', '.', '-type', 'f', '-name', '*.py[co]', '-delete']
|
||||||
|
# Execute the command through the shell if we're on Windows to ensure
|
||||||
|
# that our copy of `find` is run rather than the OS default.
|
||||||
|
# This is because on Windows, Popen (and by extension, subprocess.call)
|
||||||
|
# ignores PATH and looks only at the current working directory.
|
||||||
|
use_shell = sys.platform.startswith('win')
|
||||||
|
return subprocess.call(cmd, cwd=self.topsrcdir, shell=use_shell)
|
||||||
|
|
||||||
@CommandProvider
|
@CommandProvider
|
||||||
class Logs(MachCommandBase):
|
class Logs(MachCommandBase):
|
||||||
"""Provide commands to read mach logs."""
|
"""Provide commands to read mach logs."""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue