本文整理匯總了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, '')