本文整理汇总了Python中sprinter.lib.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __run_command
def __run_command(self, command_type, manifest_type):
config = getattr(self, manifest_type)
if config.has(command_type):
command = config.get(command_type)
self.logger.debug("Running %s..." % command)
shell = config.has('shell') and config.is_affirmative('shell')
lib.call(command, shell=shell)
示例2: test_call_error
def test_call_error(self):
""" Test an exception is thrown for a non-existent command """
try:
lib.call("eahxanea0e0")
except CommandMissingException:
return
raise("Bogus command without proper shell doesn't return proper exception!")
示例3: _configure_npmrc
def _configure_npmrc(self):
arguments = ""
if self.target.has('global_npm_root'):
global_npm_root = os.path.abspath(os.path.expanduser(self.target.get('global_npm_root')))
arguments += " --prefix={0}".format(global_npm_root)
self.logger.debug("configuring npm with {0}_".format(arguments))
lib.call("lib/node_modules/npm/configure {0}".format(arguments),
cwd=self.directory.install_directory(self.feature_name))
示例4: __call_command
def __call_command(self, command, ssh_path):
ssh_path += ".pub" # make this the public key
ssh_contents = open(ssh_path, 'r').read().rstrip('\n')
command = command.replace('{{ssh}}', ssh_contents)
lib.call(command,
shell=True,
output_log_level=logging.DEBUG,
sensitive_info=True)
示例5: __checkout_branch
def __checkout_branch(self, target_directory, branch):
self.logger.debug("Checking out branch %s..." % branch)
os.chdir(target_directory)
error, output = lib.call("git fetch origin %s" % branch,
output_log_level=logging.DEBUG)
if not error:
error, output = lib.call("git checkout %s" % branch,
output_log_level=logging.DEBUG)
if error:
raise GitException("An error occurred when checking out a branch!")
示例6: __install_package
def __install_package(self, config):
if self.package_manager and config.has(self.package_manager):
package = config.get(self.package_manager)
self.logger.info("Installing %s..." % package)
call_command = "%s%s install %s" % (self.package_manager, self.args, package)
if self.sudo_required:
call_command = "sudo " + call_command
self.logger.debug("Calling command: %s" % call_command)
# it's not possible to retain remember sudo privileges across shells unless they pipe
# to STDOUT. Nothing we can do about that for now.
lib.call(call_command, output_log_level=logging.DEBUG, stdout=None)
示例7: __install_eggs
def __install_eggs(self, config):
""" Install eggs for a particular configuration """
eggs = []
if config.has('egg'):
eggs += [config.get('egg')]
if config.has('eggs'):
eggs += [egg.strip() for egg in re.split(',|\n', config.get('eggs'))]
self.logger.debug("Installing eggs %s..." % eggs)
with open(os.path.join(self.directory.install_directory(self.feature_name), 'requirements.txt'),
'w+') as fh:
fh.write('\n'.join(eggs))
lib.call("bin/pip install -r requirements.txt --upgrade",
cwd=self.directory.install_directory(self.feature_name))
示例8: install_brew
def install_brew(target_path):
""" Install brew to the target path """
if not os.path.exists(target_path):
try:
os.makedirs(target_path)
except OSError:
LOGGER.warn("Unable to create directory %s for brew." % target_path +
" Trying sudo...")
lib.call("sudo mkdir -p %s" % target_path, stdout=None,
output_log_level=logging.DEBUG)
lib.call("sudo chown %s %s" % (getpass.getuser(), target_path),
output_log_level=logging.DEBUG, stdout=None)
extract_targz(HOMEBREW_URL, target_path, remove_common_prefix=True)
示例9: __generate_key
def __generate_key(self, config):
"""
Generate the ssh key, and return the ssh config location
"""
cwd = config.get('ssh_path', self.directory.install_directory(self.feature_name))
if not config.has('create') or config.is_affirmative('create'):
if not os.path.exists(cwd):
os.makedirs(cwd)
if not os.path.exists(os.path.join(cwd, config.get('keyname'))):
command = "ssh-keygen -t %(type)s -f %(keyname)s -N " % config.to_dict()
lib.call(command, cwd=cwd, output_log_level=logging.DEBUG)
if not config.has('ssh_path'):
config.set('ssh_path', cwd)
config.set('ssh_key_path', os.path.join(config.get('ssh_path'), config.get('keyname')))
示例10: update
def update(self):
if not lib.which('git'):
self.logger.warn("git is not installed! Please install git to install this feature.")
return
target_directory = self.directory.install_directory(self.feature_name)
source_branch = self.source.get('branch', 'master')
target_branch = self.target.get('branch', 'master')
if self.target.get('url') != self.source.get('url') or \
not os.path.exists(target_directory):
if os.path.exists(target_directory):
self.logger.debug("Old git repository Found. Deleting...")
self.directory.remove_feature(self.feature_name)
self.__clone_repo(self.target.get('url'),
target_directory,
branch=self.target.get('branch', 'master'))
elif source_branch != target_branch:
self.__checkout_branch(target_directory, target_branch)
else:
if not os.path.exists(target_directory):
self.logger.debug("No repository cloned. Re-cloning...")
self.__clone_repo(self.target.get('url'),
target_directory,
branch=target_branch)
os.chdir(target_directory)
error, output = lib.call("git pull origin %s" % target_branch,
output_log_level=logging.DEBUG)
if error:
self.logger.info(output)
raise GitException("An error occurred when pulling!")
FormulaBase.update(self)
示例11: install_sandboxes
def install_sandboxes(self):
if self.target:
if system.is_osx():
if not self.target.is_affirmative('config', 'use_global_packagemanagers'):
self._install_sandbox('brew', brew.install_brew)
elif lib.which('brew') is None:
install_brew = lib.prompt(
"Looks like you don't have brew, " +
"which is sprinter's package manager of choice for OSX.\n"
"Would you like sprinter to install brew for you?",
default="yes", boolean=True)
if install_brew:
lib.call("sudo mkdir -p /usr/local/", stdout=None,
output_log_level=logging.DEBUG)
lib.call("sudo chown -R %s /usr/local/" % getpass.getuser(),
output_log_level=logging.DEBUG, stdout=None)
brew.install_brew('/usr/local')
示例12: __clone_repo
def __clone_repo(self, repo_url, target_directory, branch):
self.logger.debug("Cloning repository %s into %s..." % (repo_url, target_directory))
error, output = lib.call("git clone %s %s" % (repo_url, target_directory),
output_log_level=logging.DEBUG)
if error:
self.logger.info(output)
raise GitException("An error occurred when cloning!")
self.__checkout_branch(target_directory, branch)
示例13: install
def install(self):
"""
Install is called when a feature does not previously exist.
In the case of a feature changing formulas, the old feature/formula is
removed, then the new feature/formula is installed.
Installs are only guaranteed to have the 'target' config set.
errors should either be reported via self._log_error(), or raise an exception
"""
install_directory = self.directory.install_directory(self.feature_name)
cwd = install_directory if os.path.exists(install_directory) else None
if self.target.has('rc'):
self.directory.add_to_rc(self.target.get('rc'))
if self.target.has('command'):
lib.call(self.target.get('command'), shell=True, cwd=cwd)
示例14: __run_command
def __run_command(self, command_type, manifest_type):
config = getattr(self, manifest_type)
if config.has(command_type):
command = config.get(command_type)
self.logger.debug("Running %s..." % command)
shell = config.has('shell') and config.is_affirmative('shell')
return_code, output = lib.call(command, shell=shell)
if config.is_affirmative('fail_on_error', True) and return_code != 0:
raise CommandFormulaException("Command returned a return code of {0}!".format(return_code))
示例15: __run_command
def __run_command(self, command_type, manifest_type):
config = getattr(self, manifest_type)
if config.has(command_type):
command = config.get(command_type)
self.logger.debug("Running %s..." % command)
shell = config.has('shell') and config.is_affirmative('shell')
stdout = subprocess.PIPE if config.is_affirmative('redirect_stdout_to_log', 'true') else None
return_code, output = lib.call(command, shell=shell, stdout=stdout)
if config.is_affirmative('fail_on_error', True) and return_code != 0:
raise CommandFormulaException("Command returned a return code of {0}!".format(return_code))