Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def system(cmd):
expand = isinstance(cmd, six.string_types)
if verbose:
sys.stderr.write("executing %s\n" % str(cmd))
retcode = subprocess.call(cmd, shell=expand)
if retcode:
raise CalledProcessError(retcode, cmd)
if not self.cloneDestination:
self.cloneDestination = self.defaultDestination(args)
print("Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination))
if not os.path.exists(self.cloneDestination):
os.makedirs(self.cloneDestination)
chdir(self.cloneDestination)
init_cmd = [ "git", "init" ]
if self.cloneBare:
init_cmd.append("--bare")
retcode = subprocess.call(init_cmd)
if retcode:
raise CalledProcessError(retcode, init_cmd)
if not P4Sync.run(self, depotPaths):
return False
# create a master branch and check out a work tree
if gitBranchExists(self.branch):
system([ "git", "branch", "master", self.branch ])
if not self.cloneBare:
system([ "git", "checkout", "-f" ])
else:
print('Not checking out any branch, use ' \
'"git checkout -q -b master "')
# auto-set this variable if invoked with --use-client-spec
if self.useClientSpec_from_options:
system("git config --bool git-p4.useclientspec true")
def p4_system(cmd):
"""Specifically invoke p4 as the system command. """
real_cmd = p4_build_cmd(cmd)
expand = isinstance(real_cmd, six.string_types)
retcode = subprocess.call(real_cmd, shell=expand)
if retcode:
raise CalledProcessError(retcode, real_cmd)