本文整理汇总了Python中perfrunner.helpers.remote.RemoteHelper.detect_os_release方法的典型用法代码示例。如果您正苦于以下问题:Python RemoteHelper.detect_os_release方法的具体用法?Python RemoteHelper.detect_os_release怎么用?Python RemoteHelper.detect_os_release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类perfrunner.helpers.remote.RemoteHelper
的用法示例。
在下文中一共展示了RemoteHelper.detect_os_release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CouchbaseInstaller
# 需要导入模块: from perfrunner.helpers.remote import RemoteHelper [as 别名]
# 或者: from perfrunner.helpers.remote.RemoteHelper import detect_os_release [as 别名]
class CouchbaseInstaller(object):
def __init__(self, cluster_spec, options):
self.options = options
self.remote = RemoteHelper(cluster_spec, None, options.verbose)
self.cluster_spec = cluster_spec
arch = self.remote.detect_arch()
pkg = self.remote.detect_pkg()
release = None
build = None
if options.version:
release, build = options.version.split('-')
self.build = Build(arch, pkg, options.cluster_edition, options.version,
release, build, options.url)
logger.info('Target build info: {}'.format(self.build))
def get_expected_filenames(self):
if self.build.pkg == 'rpm':
os_release = self.remote.detect_os_release()
patterns = (
'couchbase-server-{{edition}}-{{version}}-centos{}.{{arch}}.{{pkg}}'.format(os_release),
'couchbase-server-{edition}_centos6_{arch}_{version}-rel.{pkg}',
)
elif self.build.pkg == 'deb':
patterns = (
'couchbase-server-{edition}_{arch}_{version}-rel.{pkg}',
'couchbase-server-{edition}_{version}-ubuntu12.04_{arch}.{pkg}',
)
elif self.build.pkg == 'exe':
patterns = (
'couchbase-server-{edition}_{arch}_{version}-rel.setup.{pkg}',
'couchbase-server-{edition}_{version}-windows_{arch}.{pkg}',
'couchbase_server-{edition}-windows-{arch}-{version}.{pkg}',
)
else:
patterns = () # Sentinel
for pattern in patterns:
yield pattern.format(**self.build.__dict__)
@staticmethod
def is_exist(url):
try:
status_code = requests.head(url).status_code
except ConnectionError:
return False
if status_code == 200:
return True
return False
def find_package(self):
for filename in self.get_expected_filenames():
for location in LOCATIONS:
url = '{}{}'.format(location.format(**self.build.__dict__),
filename)
if self.is_exist(url):
return filename, url
logger.interrupt('Target build not found')
def kill_processes(self):
self.remote.kill_processes()
def uninstall_package(self):
self.remote.uninstall_couchbase(self.build.pkg)
def clean_data(self):
self.remote.clean_data()
def install_package(self):
if self.options.version:
filename, url = self.find_package()
else:
url = self.options.url
filename = urlparse(url).path.split('/')[-1]
logger.info('Using this URL: {}'.format(url))
self.remote.install_couchbase(self.build.pkg, url, filename,
self.build.release)
def install(self):
self.kill_processes()
self.uninstall_package()
self.clean_data()
self.install_package()