コード例 #1
0
 def test_rwremotefile3(self):
     """write and seek"""
     f = RWRemoteFile('/source/project/package/fname2')
     f.write('ple\nfile\n')
     f.seek(0, os.SEEK_SET)
     f.write('yet another\nsim')
     f.close(foo='bar')
コード例 #2
0
 def test_rwremotefile7(self):
     """write and seek (tmpfile)"""
     f = RWRemoteFile('/source/project/package/fname2', use_tmp=True)
     f.write('ple\nfile\n')
     self.assertTrue(os.path.exists(f._fobj.name))
     f.seek(0, os.SEEK_SET)
     f.write('yet another\nsim')
     f.close(foo='bar')
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #3
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile3(self):
     """write and seek"""
     f = RWRemoteFile('/source/project/package/fname2')
     f.write('ple\nfile\n')
     f.seek(0, os.SEEK_SET)
     f.write('yet another\nsim')
     f.close(foo='bar')
コード例 #4
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile7(self):
     """write and seek (tmpfile)"""
     f = RWRemoteFile('/source/project/package/fname2', use_tmp=True)
     f.write('ple\nfile\n')
     self.assertTrue(os.path.exists(f._fobj.name))
     f.seek(0, os.SEEK_SET)
     f.write('yet another\nsim')
     f.close(foo='bar')
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #5
0
 def test_rwremotefile4(self):
     """append to existing file"""
     f = RWRemoteFile('/source/project/package/fname2', append=True)
     # read first line
     self.assertEqual(f.readline(), 'yet another\n')
     # append/overwrite text
     f.write('more complex\n')
     f.write('testcase\n')
     # check that it is a StringIO
     self.assertTrue(isinstance(f._fobj, OutputType))
     f.close()
コード例 #6
0
 def test_rwremotefile6(self):
     """write to file (tmpfile)"""
     f = RWRemoteFile('/source/project/package/fname2', use_tmp=True)
     f.write('yet another\nsim')
     self.assertTrue(os.path.exists(f._fobj.name))
     f.write('ple\nfile\n')
     f.close()
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #7
0
 def test_rwremotefile8(self):
     """append to existing file"""
     f = RWRemoteFile('/source/project/package/fname2',
                      tmp_size=15,
                      append=True)
     # read first line
     self.assertEqual(f.readline(), 'yet another\n')
     self.assertTrue(os.path.exists(f._fobj.name))
     # append/overwrite text
     f.write('more complex\n')
     f.write('testcase\n')
     f.close()
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #8
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile4(self):
     """append to existing file"""
     f = RWRemoteFile('/source/project/package/fname2', append=True)
     # read first line
     self.assertEqual(f.readline(), 'yet another\n')
     # append/overwrite text
     f.write('more complex\n')
     f.write('testcase\n')
     # check that it is a StringIO
     self.assertTrue(isinstance(f._fobj, OutputType))
     f.close()
コード例 #9
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile6(self):
     """write to file (tmpfile)"""
     f = RWRemoteFile('/source/project/package/fname2', use_tmp=True)
     f.write('yet another\nsim')
     self.assertTrue(os.path.exists(f._fobj.name))
     f.write('ple\nfile\n')
     f.close()
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #10
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile8(self):
     """append to existing file"""
     f = RWRemoteFile('/source/project/package/fname2',
                      tmp_size=15, append=True)
     # read first line
     self.assertEqual(f.readline(), 'yet another\n')
     self.assertTrue(os.path.exists(f._fobj.name))
     # append/overwrite text
     f.write('more complex\n')
     f.write('testcase\n')
     f.close()
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #11
0
 def test_rwremotefile10(self):
     """read some bytes, write some bytes and call write_to"""
     f = RWRemoteFile('/source/project/package/fname2', append=True)
     self.assertEqual(f.read(3), 'yet')
     self.assertTrue(isinstance(f._fobj, OutputType))
     f.write('01234567')
     sio = StringIO()
     f.write_to(sio, 7)
     self.assertEqual(sio.getvalue(), '\nsimple')
コード例 #12
0
 def test_rwremotefile9(self):
     """iterate over the file (but read only 8 bytes)"""
     f = RORemoteFile('/source/project/package/fname')
     i = iter(f)
     self.assertEqualFile(i.next(), 'remotefile1')
     f = RORemoteFile('/source/project/package/fname2', stream_bufsize=6)
     i = f.__iter__(size=8)
     self.assertEqual(i.next(), 'yet an')
     self.assertEqual(i.next(), 'ot')
     f = RWRemoteFile('/source/project/package/fname2', stream_bufsize=6)
     i = f.__iter__(size=8)
     self.assertEqual(i.next(), 'yet an')
     self.assertEqual(i.next(), 'ot')
コード例 #13
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile10(self):
     """read some bytes, write some bytes and call write_to"""
     f = RWRemoteFile('/source/project/package/fname2', append=True)
     self.assertEqual(f.read(3), 'yet')
     self.assertTrue(isinstance(f._fobj, OutputType))
     f.write('01234567')
     sio = StringIO()
     f.write_to(sio, 7)
     self.assertEqual(sio.getvalue(), '\nsimple')
コード例 #14
0
ファイル: build.py プロジェクト: vikas-lamba/osc2
    def log(self, **kwargs):
        """Get the buildlog.

        If repository, arch or package weren't specified during the __init__
        call a ValueError is raised.

        Keyword arguments:
        **kwargs -- optional parameters for the http request

        """
        if not (self.repository and self.arch and self.package):
            raise ValueError("repository, arch, package are mandatory for log")
        path = "/build/%s/%s/%s/%s/_log" % (self.project, self.repository,
                                            self.arch, self.package)
        return RWRemoteFile(path, **kwargs)
コード例 #15
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile11(self):
     """write, seek and multiple write backs"""
     f = RWRemoteFile('/source/project/package/fname2',
                      wb_path='/other/path')
     f.write('ple\nfile\n')
     f.seek(0, os.SEEK_SET)
     f.write('yet another\nsim')
     f.write_back(foo='bar')
     # no request is issued because file isn't modified
     f.write_back()
     # force write back
     f.write_back(force=True)
     # no write back is issued
     f.close(foo='bar')
コード例 #16
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile2(self):
     """write to file"""
     f = RWRemoteFile('/source/project/package/fname2')
     f.write('yet another\nsim')
     f.write('ple\nfile\n')
     f.close()
コード例 #17
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile5(self):
     """read and seek through a file (tmpfile)"""
     f = RWRemoteFile('/source/project/package/fname',
                      tmp_size=20, rev='123')
     f.seek(1, os.SEEK_SET)
     self.assertTrue(os.path.exists(f._fobj.name))
     self.assertEqual(f.read(7), 'his is ')
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.read(7), 'This is')
     f.seek(0, os.SEEK_SET)
     self.assertTrue(len(f.readlines()) == 5)
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.readline(), 'This is a simple file\n')
     self.assertEqual(f.readline(), 'with some newlines\n')
     self.assertEqual(f.read(), '\nand\ntext.\n')
     f.close()
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #18
0
ファイル: test_remote.py プロジェクト: scarabeusiv/osc2
 def test_rwremotefile1(self):
     """read and seek through a file"""
     f = RWRemoteFile('/source/project/package/fname', rev='123')
     f.seek(1, os.SEEK_SET)
     self.assertEqual(f.read(7), 'his is ')
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.read(7), 'This is')
     f.seek(0, os.SEEK_SET)
     self.assertTrue(len(f.readlines()) == 5)
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.readline(), 'This is a simple file\n')
     self.assertEqual(f.readline(), 'with some newlines\n')
     self.assertEqual(f.read(), '\nand\ntext.\n')
     f.close()
コード例 #19
0
 def test_rwremotefile5(self):
     """read and seek through a file (tmpfile)"""
     f = RWRemoteFile('/source/project/package/fname',
                      tmp_size=20,
                      rev='123')
     f.seek(1, os.SEEK_SET)
     self.assertTrue(os.path.exists(f._fobj.name))
     self.assertEqual(f.read(7), 'his is ')
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.read(7), 'This is')
     f.seek(0, os.SEEK_SET)
     self.assertTrue(len(f.readlines()) == 5)
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.readline(), 'This is a simple file\n')
     self.assertEqual(f.readline(), 'with some newlines\n')
     self.assertEqual(f.read(), '\nand\ntext.\n')
     f.close()
     self.assertFalse(os.path.exists(f._fobj.name))
コード例 #20
0
 def test_rwremotefile2(self):
     """write to file"""
     f = RWRemoteFile('/source/project/package/fname2')
     f.write('yet another\nsim')
     f.write('ple\nfile\n')
     f.close()
コード例 #21
0
 def test_rwremotefile11(self):
     """write, seek and multiple write backs"""
     f = RWRemoteFile('/source/project/package/fname2',
                      wb_path='/other/path')
     f.write('ple\nfile\n')
     f.seek(0, os.SEEK_SET)
     f.write('yet another\nsim')
     f.write_back(foo='bar')
     # no request is issued because file isn't modified
     f.write_back()
     # force write back
     f.write_back(force=True)
     # no write back is issued
     f.close(foo='bar')
コード例 #22
0
 def test_rwremotefile1(self):
     """read and seek through a file"""
     f = RWRemoteFile('/source/project/package/fname', rev='123')
     f.seek(1, os.SEEK_SET)
     self.assertEqual(f.read(7), 'his is ')
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.read(7), 'This is')
     f.seek(0, os.SEEK_SET)
     self.assertTrue(len(f.readlines()) == 5)
     f.seek(0, os.SEEK_SET)
     self.assertEqual(f.readline(), 'This is a simple file\n')
     self.assertEqual(f.readline(), 'with some newlines\n')
     self.assertEqual(f.read(), '\nand\ntext.\n')
     f.close()