Esempio n. 1
0
    def getSymlinkPath(self):
        """
        Returns a Path object that has the path that the symlink
        refers to.
        """
        if not self.isSymlink():
            raise ufsi.NotASymlinkError('%r is not a symlink' % self._path)

        try:
            return ufsi.Path(os.readlink(self._path))
        except Exception, e:
            NativeUtils.handleException(e, self._path)
Esempio n. 2
0
 def getStat(self):
     """
     Returns a dict of information about this directory.
     """
     try:
         if self.__pathStr=='':
             selfStr='.'
         else:
             selfStr=self.__pathStr
         return NativeUtils.convertStatObjectToDict(os.stat(selfStr))
     except Exception,e:
         NativeUtils.handleException(e,self.__pathStr)
    def getSymlinkPath(self):
        """
        Returns a Path object that has the path that the symlink
        refers to.
        """
        if not self.isSymlink():
            raise ufsi.NotASymlinkError('%r is not a symlink'%self._path)

        try:
            return ufsi.Path(os.readlink(self._path))
        except Exception,e:
            NativeUtils.handleException(e,self._path)
Esempio n. 4
0
 def getStat(self):
     """
     Returns a dict of information about this directory.
     """
     try:
         if self.__pathStr == '':
             selfStr = '.'
         else:
             selfStr = self.__pathStr
         return NativeUtils.convertStatObjectToDict(os.stat(selfStr))
     except Exception, e:
         NativeUtils.handleException(e, self.__pathStr)
Esempio n. 5
0
    def open(self,mode=None):
        """
        Opens the file for io using the read... and
        write... methods. Before opening the file it closes a
        previously opened file.
        """
        # TODO: change the default mode from None to 'r'
        self.close()

        try:
            if mode is None:
                self.__fileHandle=file(self.__pathStr)
            else:
                self.__fileHandle=file(self.__pathStr,mode)
        except Exception,e:
            NativeUtils.handleException(e,self.__pathStr)
Esempio n. 6
0
    def open(self, mode=None):
        """
        Opens the file for io using the read... and
        write... methods. Before opening the file it closes a
        previously opened file.
        """
        # TODO: change the default mode from None to 'r'
        self.close()

        try:
            if mode is None:
                self.__fileHandle = file(self.__pathStr)
            else:
                self.__fileHandle = file(self.__pathStr, mode)
        except Exception, e:
            NativeUtils.handleException(e, self.__pathStr)
Esempio n. 7
0
    def getStat(self):
        """
        Returns a dict of information about the file. The keys are:

        * size
        * accessTime
        * modificationTime
        * creationTime
        * permissions - a string of the octal unix permissions.
        
        """
        # TODO: update docstring
        try:
            return NativeUtils.convertStatObjectToDict(os.stat(self.__pathStr))
        except Exception, e:
            NativeUtils.handleException(e, self.__pathStr)
Esempio n. 8
0
    def getStat(self):
        """
        Returns a dict of information about the file. The keys are:

        * size
        * accessTime
        * modificationTime
        * creationTime
        * permissions - a string of the octal unix permissions.
        
        """
        # TODO: update docstring
        try:
            return NativeUtils.convertStatObjectToDict(
                    os.stat(self.__pathStr))
        except Exception,e:
            NativeUtils.handleException(e,self.__pathStr)
Esempio n. 9
0
    def getDirList(self,filter=None,sort=None):
        """
        Returns a list of Path's that exist in this directory. 
        """
        try:
            if self.__pathStr=='':
                ds=os.listdir('.')
            else:
                ds=os.listdir(self.__pathStr)

            ds=map(lambda d:self.__path.join(d),ds)
            # TODO: implement re filtering

            if sort!=None:
                ds.sort(lambda x,y: cmp(x.split()[sort],y.split()[sort]))
            return ds

        except Exception,e:
            NativeUtils.handleException(e,self.__pathStr)
Esempio n. 10
0
    def getDirList(self, filter=None, sort=None):
        """
        Returns a list of Path's that exist in this directory. 
        """
        try:
            if self.__pathStr == '':
                ds = os.listdir('.')
            else:
                ds = os.listdir(self.__pathStr)

            ds = map(lambda d: self.__path.join(d), ds)
            # TODO: implement re filtering

            if sort != None:
                ds.sort(lambda x, y: cmp(x.split()[sort], y.split()[sort]))
            return ds

        except Exception, e:
            NativeUtils.handleException(e, self.__pathStr)