Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if sys.platform.startswith("win"):
# Fake being in MINGW32 terminal, so paths are properly converted.
cmds.insert(1, "set MSYSTEM=MINGW32")
tmShUtil.RunInContext(cfg.envScriptName, cmds)
if sys.platform.startswith("win") or sys.platform == "darwin":
# Need to include the Komodo bits separately.
output_dir = join(cfg.mozDist, "crashreporter-symbols")
if not _isdir(output_dir):
_mkdir(output_dir)
moz_crashreporter_src_dir = join(cfg.mozSrc, "mozilla", "toolkit",
"crashreporter")
py_symbol_script = join(moz_crashreporter_src_dir, "tools", "symbolstore.py")
options = "-c"
if sys.platform.startswith("win"):
if not cfg.compiler.startswith("vc"):
raise black.BlackError("unexpected compiler %r" % (cfg.compiler, ))
msc_ver = (int(cfg.compiler[2:], 10) + 6) * 100
dump_symbols_exe = join(moz_crashreporter_src_dir, "tools", "win32",
"dump_syms_vc%d.exe" % (msc_ver, ))
else:
options += " -a " + cfg.architecture # the wanted architecture
dump_symbols_exe = join(cfg.mozDist, "host", "bin", "dump_syms")
cmd = ["python",
py_symbol_script, # python script to generate symbol info
options,
"-s", cfg.komodoDevDir, # the base source reference directory
dump_symbols_exe, # executable that dumps the symbol info
output_dir, # where crashreporter symbol files end up
cfg.buildAbsDir, # where to look for ".pdb" files
]
# Ensure the Mozilla Python libraries are on the pythonpath:
def do_upload(self, argv):
"""upload built packages to staging area
bk upload
This is a total HACK just for Komodo -- the only user of Black,
so that is okay.
"""
# die if there is no project configuration
if not blackFile:
raise black.BlackError("attempted 'upload' with no project "\
"configuration: no Blackfile.py was found")
try:
projectConfig = black.configure.ImportProjectConfig(
blackFileName, blackFile)
except ImportError:
out.startErrorItem()
out.write("error: Attempted 'upload' command without having "\
"configured. You must first configure your project.\n")
out.endErrorItem()
return 1
# There can be no default "upload" command. A project must override
# this.
if HasOverride(blackFile, "upload"):
return RunOverride(blackFile, projectConfig, "upload", argv)
else:
if not blackFile:
raise black.BlackError("attempted 'cleanprefs' with no project "\
"configuration: no Blackfile.py was found")
try:
projectConfig = black.configure.ImportProjectConfig(
blackFileName, blackFile)
except ImportError:
out.startErrorItem()
out.write("error: Attempted '%s' command without having "
"configured. You must first configure your project.\n"
% (cmd,))
out.endErrorItem()
return 1
if HasOverride(blackFile, cmd):
return RunOverride(blackFile, projectConfig, cmd, argv)
raise black.BlackError("attempted to run command '%s', but the "
"handler disappeared.\n" % (cmd,))
setattr(self, func_name, handle)
def do_package(self, argv):
"""package up bits
bk package []
"""
# die if there is no project configuration
if not blackFile:
raise black.BlackError("attempted 'package' with no project "\
"configuration: no Blackfile.py was found")
try:
projectConfig = black.configure.ImportProjectConfig(
blackFileName, blackFile)
except ImportError:
out.startErrorItem()
out.write("error: Attempted 'package' command without having "\
"configured. You must first configure your project.\n")
out.endErrorItem()
return 1
# There can be no default "package" command. A project must override
# this.
if HasOverride(blackFile, "package"):
return RunOverride(blackFile, projectConfig, "package", argv)
else:
def CleanPreferences(cfg, argv):
"""remove Komodo and Mozilla preference files
These must be kept in sync with the directory naming in koDirs,
or maybe I could acutally query koDirs.
"""
if len(argv) != 2:
raise black.BlackError("Wrong number of arguments to 'clean'. You "\
"have to specify one argument, namely what preferences to "\
"clean: 'komodo' or 'mozilla'.")
else:
what = argv[1]
toDelete = []
if sys.platform.startswith("win"):
from win32com.shell import shellcon, shell
## XXX win32com.shellcon is missing CSIDL_COMMON_APPDATA
shellcon.CSIDL_COMMON_APPDATA = 0x23
if what.startswith("ko"):
#---- komodo preference files
if sys.platform.startswith("win"):
base = str(shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA,
0, 0))
toDelete.append(os.path.join(base, "ActiveState", "Komodo"))
def do_image(self, argv):
"""create the install image
bk image []
This is a total HACK just for Komodo -- the only user of Black,
so that is okay.
"""
# die if there is no project configuration
if not blackFile:
raise black.BlackError("attempted 'image' with no project "\
"configuration: no Blackfile.py was found")
try:
projectConfig = black.configure.ImportProjectConfig(
blackFileName, blackFile)
except ImportError:
out.startErrorItem()
out.write("error: Attempted 'image' command without having "\
"configured. You must first configure your project.\n")
out.endErrorItem()
return 1
# There can be no default "image" command. A project must override
# this.
if HasOverride(blackFile, "image"):
return RunOverride(blackFile, projectConfig, "image", argv)
else:
def do_start(self, argv):
"""run a command in the configured environment"""
global blackFile
# die if there is no project configuration
if not blackFile:
raise black.BlackError("attempted 'start' with no project "\
"configuration: no Blackfile.py was found")
# import the project configure module
try:
projectConfig = black.configure.ImportProjectConfig(
blackFileName, blackFile)
except ImportError:
out.startErrorItem()
out.write("error: Attempted 'start' command without having "\
"configured. You must first configure your project.\n")
out.endErrorItem()
return 1
quotedArgs = []
args = argv[1:]
if args[0] == "-v":
def do_configure(self, argv):
global blackFile, blackFileName
# die if there is no project configuration
if not blackFile:
raise black.BlackError("attempted 'configure' with no project "\
"configuration: no Blackfile.py was found")
# configure away
from black.configure import Configure
return Configure(argv[1:], blackFileName, blackFile)
def do_perf(self, argv):
"""run self-perf
bk perf [options]
"""
global blackFile, blackFileName
# die if there is no project configuration
if not blackFile:
raise black.BlackError("attempted 'perf' with no project "\
"configuration: no Blackfile.py was found")
try:
projectConfig = black.configure.ImportProjectConfig(
blackFileName, blackFile)
except ImportError:
out.startErrorItem()
out.write("error: Attempted 'perf' command without having "\
"configured. You must first configure your project.\n")
out.endErrorItem()
return 1
# Currently Black has no knowledge of how to clean a project. However,
# it can invoke a custom clean procedure as expressed in
# the commandOverrides['clean'] variable in the project Blackfile.py.
if HasOverride(blackFile, "perf"):
return RunOverride(blackFile, projectConfig, "perf", argv)