def open(self, filepath, mode):
        """Opens an hpss file"""
        #want to close any open files first
        try:
            if self._file:
                self.close()
        except ArchiveInterfaceError as ex:
            err_str = "Can't close previous hpss file before "\
                      "opening new one with error: " + str(ex)
            raise ArchiveInterfaceError(err_str)

        #try to open file
        try:
            fpath = un_abs_path(filepath)
            filename = os.path.join(self._prefix, path_info_munge(fpath))
            self._filepath = filename
            hpss = HpssExtended(self._filepath, self._latency)
            hpss.ping_core()
            hpss_fopen = self._hpsslib.hpss_Fopen
            hpss_fopen.restype = c_void_p
            self._file = hpss_fopen(filename, mode)
            if self._file < 0:
                err_str = "Failed opening Hpss File, code: " + str(self._file)
                raise ArchiveInterfaceError(err_str)
            return self
        except Exception as ex:
            err_str = "Can't open hpss file with error: " + str(ex)
            raise ArchiveInterfaceError(err_str)
    def open(self, filepath, mode):
        """Opens an hpss file"""
        #want to close any open files first
        try:
            if self._file:
                self.close()
        except ArchiveInterfaceError as ex:
            err_str = "Can't close previous hpss file before "\
                      "opening new one with error: " + str(ex)
            raise ArchiveInterfaceError(err_str)

        #try to open file
        try:
            fpath = un_abs_path(filepath)
            filename = os.path.join(self._prefix, path_info_munge(fpath))
            self._filepath = filename
            hpss = HpssExtended(self._filepath, self._latency)
            hpss.ping_core()
            hpss_fopen = self._hpsslib.hpss_Fopen
            hpss_fopen.restype = c_void_p
            self._file = hpss_fopen(filename, mode)
            if self._file < 0:
                err_str = "Failed opening Hpss File, code: " + str(self._file)
                raise ArchiveInterfaceError(err_str)
            return self
        except Exception as ex:
            err_str = "Can't open hpss file with error: " + str(ex)
            raise ArchiveInterfaceError(err_str)
 def open(self, filepath, mode):
     """Open a posix file"""
     #want to close any open files first
     try:
         if self._file:
             self.close()
     except ArchiveInterfaceError as ex:
         err_str = "Can't close previous posix file before opening new "\
                   "one with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)
     try:
         fpath = un_abs_path(filepath)
         filename = os.path.join(self._prefix, fpath)
         self._file = ExtendedFile(filename, mode)
         return self
     except Exception as ex:
         err_str = "Can't open posix file with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)
Esempio n. 4
0
 def open(self, filepath, mode):
     """Open a posix file"""
     #want to close any open files first
     try:
         if self._file:
             self.close()
     except ArchiveInterfaceError as ex:
         err_str = "Can't close previous posix file before opening new "\
                   "one with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)
     try:
         fpath = un_abs_path(filepath)
         filename = os.path.join(self._prefix, fpath)
         self._file = ExtendedFile(filename, mode)
         return self
     except Exception as ex:
         err_str = "Can't open posix file with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)
 def test_utils_absolute_path(self):
     """test the return of un_abs_path"""
     return_one = un_abs_path("tmp/foo.text")
     return_two = un_abs_path("/tmp/foo.text")
     return_three = un_abs_path("/tmp/foo.text")
     return_four = un_abs_path("foo.text")
     self.assertEqual(return_one, "tmp/foo.text")
     self.assertEqual(return_two, "tmp/foo.text")
     self.assertNotEqual(return_three, "/tmp/foo.text")
     self.assertEqual(return_four, "foo.text")
     hit_exception = False
     try:
         un_abs_path(47)
     except ArchiveInterfaceError, ex:
         hit_exception = True
 def test_utils_absolute_path(self):
     """test the return of un_abs_path"""
     return_one = un_abs_path("tmp/foo.text")
     return_two = un_abs_path("/tmp/foo.text")
     return_three = un_abs_path("/tmp/foo.text")
     return_four = un_abs_path("foo.text")
     self.assertEqual(return_one, "tmp/foo.text")
     self.assertEqual(return_two, "tmp/foo.text")
     self.assertNotEqual(return_three, "/tmp/foo.text")
     self.assertEqual(return_four, "foo.text")
     hit_exception = False
     try:
         un_abs_path(47)
     except ArchiveInterfaceError, ex:
         hit_exception = True
 def open(self, filepath, mode):
     """Open a hms sideband file"""
     #want to close any open files first
     try:
         if self._file:
             self.close()
     except ArchiveInterfaceError as ex:
         err_str = "Can't close previous HMS Sideband file before opening new "\
                   "one with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)
     try:
         self._fpath = un_abs_path(filepath)
         filename = os.path.join(self._prefix, path_info_munge(self._fpath))
         #path database refers to, rather then just the file system mount path
         sam_qfs_path = os.path.join(self._sam_qfs_prefix,
                                     path_info_munge(self._fpath))
         self._file = ExtendedHmsSideband(filename, mode, sam_qfs_path)
         return self
     except Exception as ex:
         err_str = "Can't open HMS Sideband file with error: " + str(ex)
         raise ArchiveInterfaceError(err_str)
def path_info_munge(filepath):
    """
    Munge the path for this filetype
    """
    return_path = un_abs_path(id2filename(int(filepath)))
    return return_path
def path_info_munge(filepath):
    """
    Munge the path for this filetype
    """
    return_path = un_abs_path(id2filename(int(filepath)))
    return return_path