当前位置: 首页>>代码示例>>Python>>正文


Python RemoteTarget.exists方法代码示例

本文整理汇总了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())
开发者ID:strategist922,项目名称:luigi,代码行数:9,代码来源:_test_ssh.py

示例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())
开发者ID:ChrisBg,项目名称:luigi,代码行数:10,代码来源:_test_ssh.py

示例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())
开发者ID:ChrisBg,项目名称:luigi,代码行数:11,代码来源:_test_ssh.py

示例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")
开发者ID:edhodapp,项目名称:luigi,代码行数:51,代码来源:test_ssh.py

示例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())
开发者ID:ChrisBg,项目名称:luigi,代码行数:7,代码来源:_test_ssh.py


注:本文中的luigi.contrib.ssh.RemoteTarget.exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。