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


Python FlagFramework.normpath方法代码示例

本文整理汇总了Python中pyflag.FlagFramework.normpath方法的典型用法代码示例。如果您正苦于以下问题:Python FlagFramework.normpath方法的具体用法?Python FlagFramework.normpath怎么用?Python FlagFramework.normpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyflag.FlagFramework的用法示例。


在下文中一共展示了FlagFramework.normpath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_inodes

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
            def add_inodes(path, root_item):
                for item in pst_file.listitems(root_item):
                    properties = item.properties()

                    item_inode = "%s|P%s" % (self.fd.inode, item.get_id())
                    new_path = FlagFramework.normpath(
                        "%s/%s" % (path, item.__str__().replace('/','_'))
                        )

                    ## This is a little optimization - we save the
                    ## cache copy of the property list so the File
                    ## driver does not need to do anything:
                    property_data = format_properties(properties)

                    ## These are the inode properties:
                    args = dict(size = len(property_data))

                    try:
                        args['_ctime'] = properties.get('create_date',
                                                       properties['arrival_date'])
                    except: pass

                    try:
                        args['_mtime'] = properties.get('modify_date',
                                                       properties['sent_date'])
                    except: pass
                    
                    self.ddfs.VFSCreate(None, item_inode, new_path, **args)

                    ## Make sure we can scan it:
                    fd = self.ddfs.open(inode = item_inode)
                    Scanner.scanfile(self.ddfs, fd, self.factories)

                    ## If its an email we create VFS nodes for its
                    ## attachments:
                    try:
                        for i in range(len(properties['_attachments'])):
                            att = properties['_attachments'][i]
                            
                            attachment_path = FlagFramework.normpath(
                                "%s/%s" % (new_path, att['filename1'].replace('/','_')))

                            args['size'] = len(att['body'])
                                        
                            attach_inode = "%s:%s" % (item_inode,i)
                            self.ddfs.VFSCreate(None, attach_inode,
                                                attachment_path, **args)
                            
                            ## Make sure we scan it:
                            fd = self.ddfs.open(inode = attach_inode)
                            Scanner.scanfile(self.ddfs, fd, self.factories)
                    except KeyError:
                        pass

                    ## Recursively add the next inode:
                    add_inodes(new_path, item)
开发者ID:anarchivist,项目名称:pyflag,代码行数:58,代码来源:PstFile_deprecated.py

示例2: longls

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
    def longls(self,path='/', dirs = None):
        dbh=DB.DBO(self.case)
        if self.isdir(path):
            ## If we are listing a directory, we list the files inside the directory            
            if not path.endswith('/'):
                path=path+'/'

            where = DB.expand(" path=%r " ,path)
        else:
            ## We are listing the exact file specified:
            where = DB.expand(" path=%r and name=%r", (
                FlagFramework.normpath(posixpath.dirname(path)+'/'),
                posixpath.basename(path)))
                   
        mode =''
        if(dirs == 1):
            mode=" and file.mode like 'd%'"
        elif(dirs == 0):
            mode=" and file.mode like 'r%'"

        dbh.execute("select * from file where %s %s", (where, mode))
        result = [dent for dent in dbh]

        for dent in result:
            if dent['inode']:
                dbh.execute("select * from inode where inode = %r", dent['inode'])
                data = dbh.fetch()
                if data:
                    dent.update(data)

        return result
开发者ID:arkem,项目名称:pyflag,代码行数:33,代码来源:FileSystem.py

示例3: right

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
 def right(query,result):
     result.decoration = "raw"
     result.content_type = "text/html"
     
     try:
         path=FlagFramework.normpath(query['open_tree'])
     except KeyError:
         path='/'
         
     pane_cb(path,result)
开发者ID:anarchivist,项目名称:pyflag,代码行数:12,代码来源:AJAXUI.py

示例4: isdir

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
 def isdir(self,directory):
     directory=posixpath.normpath(directory)
     if directory=='/': return 1
     
     dbh=DB.DBO(self.case)
     dirname=FlagFramework.normpath(posixpath.dirname(directory))
     dbh.execute("select type from vfs where path=%r and name=%r and "
                 "type='directory' limit 1",(dirname,
                                             posixpath.basename(directory)))
     return dbh.fetch()
开发者ID:py4n6,项目名称:pyflag,代码行数:12,代码来源:FileSystem.py

示例5: treecb

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
            def treecb(path):
                """ This call back will render the branch within
                the registry file."""
                dbh = DB.DBO(query['case'])

                path = FlagFramework.normpath(path+"/")

                ##Show the directory entries:
                dbh.execute("select basename from regi where dirname=%r",(path))
                for row in dbh:
                    yield(([row['basename'],row['basename'],'branch']))
开发者ID:backupManager,项目名称:pyflag,代码行数:13,代码来源:RegScan.py

示例6: isdir

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
 def isdir(self,directory):
     directory=posixpath.normpath(directory)
     if directory=='/': return 1
     
     dbh=DB.DBO(self.case)
     dirname=FlagFramework.normpath(posixpath.dirname(directory)+'/')
     dbh.check_index('file','path', 200)
     dbh.check_index('file','name', 200)
     dbh.execute("select mode from file where path=%r and name=%r and mode like 'd%%' limit 1",(dirname,posixpath.basename(directory)))
     row=dbh.fetch()
     if row:
         return 1
     else:
         return 0
开发者ID:arkem,项目名称:pyflag,代码行数:16,代码来源:FileSystem.py

示例7: glob_files

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
    def glob_files(self, args):
        ## Glob the path if possible:
        files = {}
        for arg in args:
            ## Add the implied CWD:
            if not arg.startswith("/"): arg=FlagFramework.normpath(self.environment.CWD+"/"+arg)
            for path in FileSystem.glob(arg, case=self.environment._CASE):
                files[path]=True

        ## This is used to collate files which may appear in multiple globs
        files = files.keys()
        files.sort()

        return files
开发者ID:anarchivist,项目名称:pyflag,代码行数:16,代码来源:pyflagsh.py

示例8: execute

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
    def execute(self):
        args=self.args
        try:
            path=args[0]
        except IndexError:
            path="/"

        new_path=posixpath.abspath(posixpath.join(self.environment.CWD,path))
        if not new_path.endswith('/'):
            new_path+='/'

        path=FlagFramework.normpath(new_path)
        if new_path!='/':
        ## Now check if the new path actually exists (There is an edge case here with / does have an inode):
            if not self.environment._FS.isdir(new_path):
                raise RuntimeError("No such directory: %s" % new_path)
        
        self.environment.CWD=new_path
        yield 'current working directory %s' % self.environment.CWD
开发者ID:anarchivist,项目名称:pyflag,代码行数:21,代码来源:BasicCommands.py

示例9: longls

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
    def longls(self,path='/', dirs = None):
        dbh=DB.DBO(self.case)
        if self.isdir(path):
            ## If we are listing a directory, we list the files inside the directory            
            where = DB.expand(" path=%r " ,path)
        else:
            ## We are listing the exact file specified:
            where = DB.expand(" path=%r and name=%r", (
                FlagFramework.normpath(posixpath.dirname(path)),
                posixpath.basename(path)))

        ## Only list directories
        if dirs:
            where += " and isnull(inode_id) "
        else:
            where += " and not isnull(inode_id) "
                   
        dbh.execute("select * from vfs where %s group by inode_id,path,name", (where))
        result = [dent for dent in dbh]

        return result
开发者ID:py4n6,项目名称:pyflag,代码行数:23,代码来源:FileSystem.py

示例10: mark_link

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
    def mark_link(self, reference):
        """ Create markup to indicate the link.

        We just add an overlay to represent the link.
        """
        if not reference: return ''
        postfix = ''
        ## Absolute reference
        if reference.startswith('http'):
            pass
        elif reference.startswith("/"):
            path = normpath("%s" % (reference))
            reference="%s://%s%s" % (self.method, self.host, path)
        elif self.method:
            ## FIXME: This leads to references without methods:
            reference="%s/%s" % (self.base_url, reference)
            if reference.startswith("http://"):
                reference='http:/'+FlagFramework.normpath(reference[6:])

        reference = url_unquote(decode_entity(unquote(reference)))
        dbh = DB.DBO(self.case)
        dbh.execute("select mtime from inode where inode_id=%r", self.inode_id)
        row = dbh.fetch()

        dbh.execute("select inode.inode_id, inode.mtime, datediff(inode.mtime, %r) as diff, url "\
                    "from http join inode on "\
                    "inode.inode_id=http.inode_id where url=%r and not "\
#                    "isnull(http.inode_id) and size > 0 and inode.mtime >= %r "\
                    "isnull(http.inode_id) "\
                    "order by inode.mtime asc limit 1", (row['mtime'],
                                                         reference, ))
        row = dbh.fetch()
        if row:
            print "Fetched %s %s ago" % (row['url'], row['diff'])
            postfix = "<div class='overlay'>Linked <a href=%s>%s</a><br>After %s</div>" % (
                self.make_reference_to_inode(row['inode_id'],None),
                row['url'][:50],
                row['diff'])

        return postfix
开发者ID:anarchivist,项目名称:pyflag,代码行数:42,代码来源:HTML.py

示例11: tree

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
        def tree(query,result):
            result.decoration = "raw"
            result.content_type = "text/html"

            ## I think this is secure enough??? This should really be
            ## json.parse but do we need to pull in a whole module
            ## just for this???
            data = eval(query['data'],{'__builtins__':None, 'true':True, 'false':False})
            path=FlagFramework.normpath(data['node']['objectId'])

            r=[]
            for x in tree_cb(path):
                if not x[0] or len(x[0])==0: continue
                
                tmp = dict(title = x[0], objectId="/%s/%s" % (path,x[1]))
                if x[2]=='branch':
                    tmp['isFolder']='true'
                else:
                    tmp['isFolder']='false'
                r.append(tmp)

            result.result=r
开发者ID:anarchivist,项目名称:pyflag,代码行数:24,代码来源:AJAXUI.py

示例12: analyse

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
    def analyse(self, query):
        """ load the filesystem image data into the database """
        dbh = DB.DBO(query["case"])
        self.progress_str = None

        # call on FileSystem to load data
        fsobj = Registry.FILESYSTEMS.dispatch(query["fstype"])(query["case"], query)
        mount_point = FlagFramework.normpath("/" + query["mount_point"])
        fsobj.load(mount_point, query["iosource"])
        dbh.set_meta("mount_point_%s" % query["iosource"], mount_point)

        self.progress_str = "Creating file and inode indexes"
        # Add indexes:
        index = (
            ("file", "inode", None),
            ("file", "path", 100),
            ("file", "name", 100),
            ("inode", "inode", None),
            ("block", "inode", None),
        )
        for x, y, z in index:
            dbh.check_index(x, y, z)
开发者ID:backupManager,项目名称:pyflag,代码行数:24,代码来源:LoadData.py

示例13: store_key

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
            def store_key(nk_key, path):
                if not nk_key: return
                key_name = nk_key['key_name'].__unicode__()
                
                regi_handle.mass_insert(dirname=path,
                                        basename=key_name)

                new_path=DB.expand("%s/%s/",(path,nk_key['key_name']))
                new_path=FlagFramework.normpath(new_path)
                
                ## Store all the values:
                for v in nk_key.values():
                    reg_handle.mass_insert(inode_id = inode_id,
                                           path=new_path,
                                           offset=v['data']['offs_data'],
                                           _modified="from_unixtime(%d)" % nk_key['WriteTS'].get_value(),
                                           type=v['data']['val_type'],
                                           reg_key=v['keyname'],
                                           value=v['data']
                                           )
                    
                for k in nk_key.keys():
                    store_key(k,new_path)
开发者ID:backupManager,项目名称:pyflag,代码行数:25,代码来源:RegScan.py

示例14: insert_into_table

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
        def insert_into_table(mode, root, name):
            rel_root = FlagFramework.normpath(DB.expand("%s/%s/", (mount_point, root[len(path) :])))
            try:
                s = os.lstat(os.path.join(root, name))
            except OSError:
                pyflaglog.log(
                    pyflaglog.WARNING, DB.expand("Unable to stat %s - mount the directory with the uid option", root)
                )
                return

            inode = DB.expand("I%s|M%s", (iosource_name, s.st_ino))
            dbh_inode.insert(
                "inode",
                inode=inode,
                uid=s.st_uid,
                gid=s.st_gid,
                _mtime="from_unixtime(%s)" % s.st_mtime,
                _atime="from_unixtime(%s)" % s.st_atime,
                _ctime="from_unixtime(%s)" % s.st_ctime,
                status="alloc",
                mode=str(oct(s.st_mode)),
                size=s.st_size,
                _fast=True,
            )
            inode_id = dbh_inode.autoincrement()

            dbh_file.mass_insert(inode_id=inode_id, inode=inode, mode=mode, status="alloc", path=rel_root, name=name)

            ## If needed schedule inode for scanning:
            if scanners and mode == "r/r":
                pdbh.mass_insert(command="Scan", arg1=self.case, arg2=inode, arg3=scanner_string, cookie=cookie)

            ## Fixme - handle symlinks
            try:
                link = os.readlink(DB.expand("%s/%s", (root, name)).encode("utf8"))
            except OSError:
                link = ""
开发者ID:backupManager,项目名称:pyflag,代码行数:39,代码来源:Mounted.py

示例15: resolve_reference

# 需要导入模块: from pyflag import FlagFramework [as 别名]
# 或者: from pyflag.FlagFramework import normpath [as 别名]
    def resolve_reference(self, reference, hint='', build_reference=True):
        original_reference = reference

        ## Make reference into relative reference
        host, url = self.parse_url(url_unquote(decode(reference)))

        ## Maybe its in the filesystem
        if not host:
            dbh = DB.DBO(self.case)
            dbh.execute("select * from vfs where inode_id = %r", self.inode_id)
            row = dbh.fetch()
            if row:
                ## Try to find the reference relative to the VFS:
                new_path = FlagFramework.normpath("/".join((row['path'], row['name'], url)))
                
                dbh.execute("select * from vfs where path = %r and name = %r",
                            os.path.split(new_path))
                row = dbh.fetch()
                if row:
                    return self.make_reference_to_inode(row['inode_id'])

        ## Now we try to find the reference. Is the reference in the
        ## http table:
        dbh = DB.DBO(self.case)
        dbh.execute("select * from http where host = %r and url = %r",
                    (host, url))
        row = dbh.fetch()
        if row:
            return self.make_reference_to_inode(row['inode_id'])

        result = "images/spacer.png"
        if build_reference:
            result += " reference=\"%s\" " % reference

        print "Not found '%s' (%s)" % (reference,(host, url))
        return result
开发者ID:backupManager,项目名称:pyflag,代码行数:38,代码来源:HTML.py


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