本文整理汇总了Python中glusto.core.Glusto.run_local方法的典型用法代码示例。如果您正苦于以下问题:Python Glusto.run_local方法的具体用法?Python Glusto.run_local怎么用?Python Glusto.run_local使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glusto.core.Glusto
的用法示例。
在下文中一共展示了Glusto.run_local方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_download
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import run_local [as 别名]
def test_download(self):
"""Testing SSH download() method"""
print "Running: %s - %s" % (self.id(), self.shortDescription())
remote_file = '/etc/hosts'
local_file = '/tmp/download_test_file'
# remove local test file (ignore error if not exist)
g.run_local('rm -f %s' % local_file)
# md5sum remote file
command = 'md5sum %s| awk \'{print $1}\'' % remote_file
rcode, rout, _ = g.run(self.primary_host, command)
if rcode == 0:
md5sum_up = rout.strip()
# download it
g.download(self.primary_host,
'/etc/hosts', '/tmp/download_test_file')
# md5sum local copy
command = 'md5sum %s | awk \'{print $1}\'' % local_file
rcode, rout, _ = g.run_local(command)
if rcode == 0:
md5sum_down = rout.strip()
# compare the md5sums
self.assertEqual(md5sum_down, md5sum_up, 'md5sums do not match')
示例2: test_run_local
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import run_local [as 别名]
def test_run_local(self):
"""Testing SSH run_local() method"""
print "Running: %s - %s" % (self.id(), self.shortDescription())
rcode, rout, rerr = g.run_local('echo -n %s' % self.test_string)
self.assertEqual(rcode, 0)
self.assertEqual(rout, self.test_string)
print rout
self.assertEqual(rerr, '')
示例3: test_upload
# 需要导入模块: from glusto.core import Glusto [as 别名]
# 或者: from glusto.core.Glusto import run_local [as 别名]
def test_upload(self):
"""Testing SSH upload() method"""
print "Running: %s - %s" % (self.id(), self.shortDescription())
g.run(self.primary_host, 'rm -f /tmp/upload_test_file')
rcode, rout, _ = g.run_local('md5sum /etc/hosts | awk \'{print $1}\'')
if rcode == 0:
md5sum = rout.strip()
g.upload(self.primary_host,
'/etc/hosts', '/tmp/upload_test_file')
command = 'md5sum /tmp/upload_test_file | awk \'{print $1}\''
rcode, rout, _ = g.run(self.primary_host, command)
if rcode == 0:
md5sum_up = rout.strip()
self.assertEqual(md5sum, md5sum_up, '')