コード例 #1
0
ファイル: file.py プロジェクト: weijia/ufs
 def listNamedChildren(self, start, cnt, isTree):
     '''
     Will return res = {"D:/file/full/path/filename": "filename",... }
     '''
     if cnt is None:
         cnt = MAX_ELEMENTS_IN_COLLECTION
     #Retrieve children from database
     folderObj = self.objDbSys.getFsObjFromFullPath(self.fullPath)
     #print folderObj
     if folderObj.has_key("folderCollectionId"):
         folderCol = self.objDbSys.getCollection(folderObj["folderCollectionId"])
         resList = []
         #print 'get collection from db----------------------------------'
         addedCnt = 0
         for i in folderCol.enumObjs():
             resList.append(i.getIdInCol())
             addedCnt += 1
             if addedCnt >= (start+cnt):
                 break
     else:
         #Retrieve children from local service
         import xmlrpclib
         proxy = xmlrpclib.ServerProxy("http://127.0.0.1:9906/xmlrpc")
         if cnt is None:
             cnt = MAX_ELEMENTS_IN_COLLECTION
         resList = proxy.create(self.fullPath, start + cnt, self.userSession.getUserName(), 
                                self.userSession.getPasswd())
         cl('get collection from service', resList)
     res = {}
     #print start, cnt
     for i in resList[start:(start+cnt)]:
         res[transform.transformDirToInternal(os.path.join(self.fullPath, i))] = unicode(os.path.basename(i))
     return res
コード例 #2
0
ファイル: objSysV2.py プロジェクト: weijia/ufs
 def getSameObjsForFullPath(self, fullPath):
     fullPath = transform.transformDirToInternal(fullPath)
     try:
         objFullPathList = self.objDbInst.getSameObjList(fullPath)
         res = []
         for objFullPath in objFullPathList:
             if os.path.exists(objFullPath):
                 res.append(objFullPath)
         return res
     except IOError:
         return []
コード例 #3
0
ファイル: tagObj.py プロジェクト: weijia/ufs
def tagObj(req):
    fields = libs.http.queryParam.queryInfo().getAllFieldStorageUnicode()
    h = libs.html.response.html()
    h.genTxtHead()
    #fullPath = urllib.unquote(fields[u"path"][0])
    fullPath = fields[u"path"][0]
    fullPath = transform.transformDirToInternal(fullPath)
    #print fullPath
    #tags = urllib.unquote(fields[u"tags"][0])
    tags = fields[u"tags"][0]
    tl = stringTools.splitWithChars(tags, configurationTools.getTagSeparator())
    t = tagSys.getTagSysObj(req.getDbSys())
    t.tag(fullPath, tl)
    #h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(tl))))
    
    h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(t.getTags(fullPath)))))
    h.end()
コード例 #4
0
ファイル: objSys.py プロジェクト: weijia/ufs
 def getSameObjsForFullPath(self, fullPath):
     fullPath = transform.transformDirToInternal(fullPath)
     #0. Return empty for dir
     #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     #To do to catch exception of file not exist
     if os.path.isdir(fullPath):
         return []
     #1. First find the items marked as the same
     
     #2. Check same content files
     #2.1 Check same size
     sizeDbInst = dbSizeMod.InfoDb(self.dbSysInst)
     size = sizeDbInst.getInfo(dbSizeMod.localPathElement(fullPath, self.dbSysInst))
     #print 'got info from db:',fullPath, size
     itemPathList = sizeDbInst.getItemWithInfo(size)
     #2.2 Check content of same size
     #print 'with the same size:',itemPathList
     if 0 != len(itemPathList):
         #print 'check data for the items'
         #2.2.1 Size same, compare content if possible, other wise check if the name is the same
         res = []
         headDb = dbSizeMod.InfoDb(self.dbSysInst, dbSizeMod.getHeadContentMd5, "headInfo")
         #Replace try after got the actual exception raised by path does not exist
         #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         try:#if True:
             origMd5 = headDb.getInfo(dbSizeMod.localPathElement(fullPath, self.dbSysInst))
         except IOError:#else:
             origMd5 = None
         for i in itemPathList:
             if i == fullPath:
                 continue
             if origMd5 is None:
                 targetMd5 = None
             else:
                 #Replace try after got the actual exception raised by path does not exist
                 #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                 try:#if True:
                     targetMd5 = headDb.getInfo(dbSizeMod.localPathElement(i, self.dbSysInst))
                 except IOError:#else:
                     targetMd5 = None
             if isIdentical(origMd5, fullPath, targetMd5, i):
                 res.append(i)
         return res
     return []
コード例 #5
0
ファイル: executeV2.py プロジェクト: weijia/ufs
def executeAppOrOpenFile(req):
    fields = libs.http.queryParam.queryInfo().getAllFieldStorageUnicode()
    h = libs.html.response.html()
    h.genTxtHead()
    #fullPath = urllib.unquote(fields[u"path"][0])
    fullPath = fields[u"path"][0]
    if objTools.isUfsFs(fullPath):
        fullPath = objTools.getFullPathFromUfsUrl(fullPath)
    fullPath = transform.transformDirToInternal(fullPath)
    #print fullPath
    #tags = urllib.unquote(fields[u"tags"][0])
    tags = "sys.executable"
    tl = stringTools.splitWithChars(tags, configurationTools.getTagSeparator())
    t = tagSys.getTagSysObj(req.getDbSys())
    #t.tag(fullPath, tl)
    #h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(tl))))
    res = startAppOrOpenFile(fullPath)
    if res == "app":
        t.tag(fullPath, tl)

    h.write(u'{"path":"%s","tags":"%s"}'%(fullPath, (u','.join(t.getTags(fullPath)))))
    h.end()
コード例 #6
0
ファイル: removeItem.py プロジェクト: weijia/ufs
#import libs.utils.stringTools as stringTools
import shutil
import os
import uuid
import localLibSys
import localLibs.cache.localFileSystemCache as localFileSystemCache
import libs.ufsDb.dbSys as dbSys

import libs.utils.misc as misc
import libs.utils.transform as transform



if __name__=='__main__':
    fields = libs.http.queryParam.queryInfo().getAllFieldStorageUnicode()
    h = libs.html.response.html()
    h.genTxtHead()
    dbSysInst = dbSys.dbSysSmart()
    fullPath = urllib.unquote(fields[u"path"][0])
    fullPath = transform.transformDirToInternal(fullPath)
    
    rootPath = configurationTools.getRootDir()
    recyclePath = os.path.join(rootPath, 'recycle')
    misc.ensureDir(recyclePath)

    dst = os.path.join(recyclePath, str(uuid.uuid4())+os.path.basename(fullPath))
    localFileSystemCache.localFileSystemCache(dbSysInst).moveCached(fullPath, dst)
    #print fullPath
    h.write(u'{"path":"%s","removed":"true"}'%fullPath)
    h.end()
コード例 #7
0
ファイル: cachedCollection.py プロジェクト: weijia/ufs
import collectionInterface as collectionInterface
コード例 #8
0
ファイル: file.py プロジェクト: weijia/ufs
 def __init__(self, fullPath, objDbSys, userSession = None):
     #Remove the first / after file:// in file:///D:/
     self.fullPath = transform.transformDirToInternal(fullPath[1:])
     self.objDbSys = objDbSys
     self.userSession = userSession
コード例 #9
0
ファイル: objSysV2.py プロジェクト: weijia/ufs
 def addObjForFullPath(self, fullPath):
     fullPath = transform.transformDirToInternal(fullPath)
     try:
         return self.objDbInst.getFsObjFromFullPath(fullPath)
     except IOError:
         return None