本文整理匯總了Python中charmhelpers.fetch.install_remote方法的典型用法代碼示例。如果您正苦於以下問題:Python fetch.install_remote方法的具體用法?Python fetch.install_remote怎麽用?Python fetch.install_remote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類charmhelpers.fetch
的用法示例。
在下文中一共展示了fetch.install_remote方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _git_clone_and_install_single
# 需要導入模塊: from charmhelpers import fetch [as 別名]
# 或者: from charmhelpers.fetch import install_remote [as 別名]
def _git_clone_and_install_single(repo, branch, depth, parent_dir, http_proxy,
update_requirements):
"""
Clone and install a single git repository.
"""
if not os.path.exists(parent_dir):
juju_log('Directory already exists at {}. '
'No need to create directory.'.format(parent_dir))
os.mkdir(parent_dir)
juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
repo_dir = install_remote(
repo, dest=parent_dir, branch=branch, depth=depth)
venv = os.path.join(parent_dir, 'venv')
if update_requirements:
if not requirements_dir:
error_out('requirements repo must be cloned before '
'updating from global requirements.')
_git_update_requirements(venv, repo_dir, requirements_dir)
juju_log('Installing git repo from dir: {}'.format(repo_dir))
if http_proxy:
pip_install(repo_dir, proxy=http_proxy, venv=venv)
else:
pip_install(repo_dir, venv=venv)
return repo_dir
示例2: test_installs_remote
# 需要導入模塊: from charmhelpers import fetch [as 別名]
# 或者: from charmhelpers.fetch import install_remote [as 別名]
def test_installs_remote(self, _plugins, _log):
h1 = MagicMock(name="h1")
h1.can_handle.return_value = "Nope"
h2 = MagicMock(name="h2")
h2.can_handle.return_value = True
h2.install.side_effect = fetch.UnhandledSource()
h3 = MagicMock(name="h3")
h3.can_handle.return_value = True
h3.install.return_value = "foo"
_plugins.return_value = [h1, h2, h3]
for url in self.valid_urls:
result = fetch.install_remote(url)
h1.can_handle.assert_called_with(url)
h2.can_handle.assert_called_with(url)
h3.can_handle.assert_called_with(url)
h1.install.assert_not_called()
h2.install.assert_called_with(url)
h3.install.assert_called_with(url)
self.assertEqual(result, "foo")
fetch.install_remote('url', extra_arg=True)
h2.install.assert_called_with('url', extra_arg=True)