コード例 #1
0
def processor(reqQ, resQ):
    gDbDict = {}
    while True:
        r = reqQ.get()
        reqType, key, dbName, value = r
        print 'get req for %s'%dbName.encode('gb2312', 'replace')
        try:
            db = gDbDict[dbName]
        except KeyError:
            db = dbSys.dbSysSmart().getDb(dbName)
            gDbDict[dbName] = db

        if '0' == reqType:
            #End req
            return
        if '1' == reqType:
            #Query
            try:
                value = db[key]
                if type(value) == list:
                    v = u','.join(value)
                else:
                    v = value
                resQ.put((db[key], r))
                print 'find %s = %s'%(key.encode('gb2312', 'replace'), v.encode('gb2312', 'replace'))
            except KeyError:
                print '%s not exist'%key.encode('gb2312', 'replace')
                resQ.put(([], r))
        if '2' == reqType:
            if type(value) == list:
                v = u','.join(value)
            else:
                v = value
            print 'set:%s = %s'%(key.encode('gb2312', 'replace'),v.encode('gb2312', 'replace'))
            db[key] = value
コード例 #2
0
ファイル: tag.py プロジェクト: weijia/ufs
def main():
    import libs.ufsDb.dbSys as dbSys
    dbSysInst = dbSys.dbSysSmart()
    a = ",\xc4\xe3\xba\xc3"#This is gbk encode of nihao. just input chinese nihao in python console, you will get this
    b = a.decode("gbk")
    print b
    c = getCollection(b, dbSysInst)
    for i in c.getRange(0, 50):
        print i
コード例 #3
0
ファイル: collectionUpdater.py プロジェクト: weijia/ufs
def handleImportCollectionFromJsonRequest(req):
    #Get request param: collectionId, start, cnt
    param = webUtils.paramWithDefault({u"jsonCollection":-1}, req.getQueryInfo())
    h = req.resp
    h.genHead('Upload Collections')
    if param[u"jsonCollection"] == -1:
        h.genForm('/apps/collection/collectionImporter.py',[['f','jsonCollection']])
    else:
        dbInst = dbSys.dbSysSmart()
        updateCollectionFromJson(param[u"jsonCollection"], h, dbInst)
        h.write('-------------------------------------------')
        h.write(param[u"jsonCollection"])
    h.genEnd()
コード例 #4
0
ファイル: collectionImporter.py プロジェクト: weijia/ufs
def importCollectionFromJson(jsonCollectionStr, htmlGen):
    r = json.loads(jsonCollectionStr)
    dbInst = dbSys.dbSysSmart()
    for i in r:
        c = collectionBase.collectionBase(i, dbInst.getCollectionDb())
        try:
            htmlGen.write(r[i]+u"<br>")
        except:
            pass
        if type(r[i]) == list:
            for j in r[i]:
                c.append(j)
        else:
            c.append(r[i])
コード例 #5
0
ファイル: ufsFs.py プロジェクト: weijia/ufs
 def listNamedChildren(self, start = 0, cnt = None, getParent = True):
     #Return {fullPath:name}
     db = dbSys.dbSysSmart()
     co = collectionManager.getCollection(u"ufsFs://"+self.id, db).getRange(0, None)
     #res = {getUfsUuidItemUrl(self.id):getUfsUuidItemUrl(self.id)}
     res = {}
     #res["test"] = co
     ns = nameService.nameService(db.getNameServiceDb())
     for i in co:
         n = ns.getName(i)
         if n is None:
             n = i
         res[i] = objTools.getUfsBasename(n)
     return res
コード例 #6
0
ファイル: ufsV2.py プロジェクト: weijia/ufs
 def listNamedChildren(self, start = 0, cnt = None, getParent = True):
     #Return {fullPath:name}
     db = dbSys.dbSysSmart()
     #print "retriving co:", getUfsUuidItemUrl(self.id)
     co = collectionManager.getCollection(getUfsUuidItemUrl(self.id), db).getRange(0, None)
     #res = {getUfsUuidItemUrl(self.id):getUfsUuidItemUrl(self.id)}
     #res = {}
     #print "got co:", co
     res = odict.OrderedDict()
     #res["test"] = co
     #Hard code the freq items
     res[u"freq://root"] = u"Freqently Used"
     #Hard code the tag system
     res[u"tag://,"] = u"Tag System"
     #Hard code the task system
     res[u"tasklist://,"] = u"Task List"
     #Hard code the task system
     res[u"zippedColllectionWithInfo://,"] = u"Zipped Collections"
     #Storage List
     res[u"storage://"] = u"Storages"
     #Add other item in root item
     ns = nameService.nameService(db.getNameServiceDb())
     for i in co:
         n = ns.getName(i)
         if n is None:
             try:
                 #Get url
                 n = objTools.getUrlContent(i)
             except ValueError:
                 n = None
         if n is None:
             #Seems to be a directory path
             try:
                 n = objTools.getUfsBasename(i)
             except:
                 n = None
         if n is None:
             n = i
         res[i] = n
     if localDriverExist():
         res[u"winUfs"+configurationTools.getFsProtocolSeparator()+winUfs.winUfsRootItemUuid] = u"Filesystem"
     return res
コード例 #7
0
ファイル: tagDbCleaner.py プロジェクト: weijia/ufs
def main():
    dbSysInst = dbSys.dbSysSmart()
    newDbSysInst = newDbSys.dbSysSmart()
    dbNew = tagSys.tagSystemShoveDb(newDbSysInst)
    dbOld = tagSys.tagSystemShoveDb(dbSysInst, dbSupportsCnt=True)
    res = {}
    
    for i,j in dbOld.getAllTags():
        print 'find tag:',i,j
        for url in dbOld.enumObjsWithTag(i):
            print url.encode('gbk','replace'),i.encode('gbk','replace'),j
            if res.has_key(url):
                res[url].append(i)
            else:
                res[url] = [i]
            
    for i in res:
        if os.path.exists(i):
            dbNew.tag(i, list(set(res[i])))
            pass
        else:
            print i.encode('gbk','replace'), str(list(set(res[i]))).encode('gbk','replace')
コード例 #8
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()
コード例 #9
0
ファイル: collectionManager.py プロジェクト: weijia/ufs
def main():
    import libs.ufsDb.dbSys as dbSys
    co = getCollection('C:/', dbSys.dbSysSmart(), False).getRange(0, None)
    print co
    for i in co:
        print i,",is empty?",getCollection(i, dbSys.dbSysSmart(), False).isEmpty()