本文整理匯總了Python中luigi.contrib.ssh.RemoteTarget.exists方法的典型用法代碼示例。如果您正苦於以下問題:Python RemoteTarget.exists方法的具體用法?Python RemoteTarget.exists怎麽用?Python RemoteTarget.exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類luigi.contrib.ssh.RemoteTarget
的用法示例。
在下文中一共展示了RemoteTarget.exists方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_exists
# 需要導入模塊: from luigi.contrib.ssh import RemoteTarget [as 別名]
# 或者: from luigi.contrib.ssh.RemoteTarget import exists [as 別名]
def test_exists(self):
self.assertTrue(self.target.exists())
no_file = RemoteTarget(
"/tmp/_file_that_doesnt_exist_",
working_ssh_host,
)
self.assertFalse(no_file.exists())
示例2: test_write_cleanup_with_error
# 需要導入模塊: from luigi.contrib.ssh import RemoteTarget [as 別名]
# 或者: from luigi.contrib.ssh.RemoteTarget import exists [as 別名]
def test_write_cleanup_with_error(self):
t = RemoteTarget(self.path, working_ssh_host)
try:
with t.open('w'):
raise Exception('something broke')
except:
pass
self.assertFalse(t.exists())
示例3: test_write_cleanup_no_close
# 需要導入模塊: from luigi.contrib.ssh import RemoteTarget [as 別名]
# 或者: from luigi.contrib.ssh.RemoteTarget import exists [as 別名]
def test_write_cleanup_no_close(self):
t = RemoteTarget(self.path, working_ssh_host)
def context():
f = t.open('w')
f.write('stuff')
context()
gc.collect() # force garbage collection of f variable
self.assertFalse(t.exists())
示例4: TestRemoteTarget
# 需要導入模塊: from luigi.contrib.ssh import RemoteTarget [as 別名]
# 或者: from luigi.contrib.ssh.RemoteTarget import exists [as 別名]
class TestRemoteTarget(unittest.TestCase):
""" These tests assume RemoteContext working
in order for setUp and tearDown to work
"""
def setUp(self):
self.ctx = RemoteContext(working_ssh_host)
self.filepath = "/tmp/luigi_remote_test.dat"
self.target = RemoteTarget(
self.filepath,
working_ssh_host,
)
self.ctx.check_output(["rm", "-rf", self.filepath])
self.ctx.check_output(["echo -n 'hello' >", self.filepath])
def tearDown(self):
self.ctx.check_output(["rm", "-rf", self.filepath])
def test_exists(self):
self.assertTrue(self.target.exists())
no_file = RemoteTarget(
"/tmp/_file_that_doesnt_exist_",
working_ssh_host,
)
self.assertFalse(no_file.exists())
def test_remove(self):
self.target.remove()
self.assertRaises(
subprocess.CalledProcessError,
self.ctx.check_output,
["cat", self.filepath]
)
def test_open(self):
f = self.target.open('r')
file_content = f.read()
f.close()
self.assertEqual(file_content, "hello")
self.assertTrue(self.target.fs.exists(self.filepath))
self.assertFalse(self.target.fs.isdir(self.filepath))
def test_context_manager(self):
with self.target.open('r') as f:
file_content = f.read()
self.assertEqual(file_content, "hello")
示例5: test_write_with_success
# 需要導入模塊: from luigi.contrib.ssh import RemoteTarget [as 別名]
# 或者: from luigi.contrib.ssh.RemoteTarget import exists [as 別名]
def test_write_with_success(self):
t = RemoteTarget(self.path, working_ssh_host)
with t.open('w') as p:
p.write("hello")
self.assertTrue(t.exists())