def jqueryListOnCollection(): #Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"collectionId":u"D:/tmp",u"start":0,u"cnt":100}) #Get collection from system, collection system contains cached collections and filesystem collections. #h.write("<!--") #print "hello" if not objTools.isUuid(param["collectionId"]): #param["collectionId"] = collectionListItems.jsIdEncoding(param["collectionId"]) param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"]) #h.write(unicode(str(int(param["start"])))+unicode(str(int(param["cnt"])))) co = collectionManager.getCollection(param["collectionId"], dbSys.dbSysSmart()) containerCo = container.collectionContainer(co, dbSys.dbSysSmart()).getRange(int(param["start"]), int(param["cnt"])) #Output #h.write(str(co)) #res = "" #h.write("-->") if True:#try: res = collectionListItem(containerCo) else:#except: pass h = libs.html.response.html() #print "hello" #h.write("good") h.genPartialHtmlHead() h.write(res) #h.write(l.s) #print res h.end()
def jqueryListOnCollection(req): #Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"collectionId":u"C:/",u"start":0,u"cnt":40}, req.getQueryInfo()) #Get collection from system, collection system contains cached collections and filesystem collections. #h.write("<!--") #print "hello" print param if not objTools.isUuid(param["collectionId"]): #param["collectionId"] = collectionListItems.jsIdEncoding(param["collectionId"]) param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"]) #h.write(unicode(str(int(param["start"])))+unicode(str(int(param["cnt"])))) co = collectionManager.getCollection(param["collectionId"], req.getDbSys()).getRange(int(param["start"]), int(param["cnt"])) #Output #h.write(str(co)) #res = "" #h.write("-->") if True:#try: resList = collectionListItem(co, req) else:#except: pass #h = libs.html.response.html() #print "hello" #h.write("good") req.resp.genJsonHead() req.resp.write(json.dumps(resList, indent = 4)) #h.write(l.s) #print res req.resp.end()
def jqueryListOnCollection(req): #Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"collectionId":u"-1"}, req.getQueryInfo()) #Get collection from system, collection system contains cached collections and filesystem collections. if not objTools.isUuid(param["collectionId"]): #It is not uuid://xxxx-xxx-xxx-xxx-xxxx-xxxx param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"]) #Output req.resp.genJsonHead() if param["collectionId"] == "-1": p = ufs.ufsTreeUuidItem() #res = path else: #p = desktopApp.lib.localTreeItem.localTreeItem(path.decode('utf8')) if objTools.isUfsUrl(param["collectionId"]):#try: p = ufsTreeItem.getUfsTreeItem(param["collectionId"], req) #print "after getufstreeitem" #res += str(p.listNamedChildren()) else:#except ValueError: #No schema/protocol string. Normal dir p = jsTreeItemWithCollectionBackend.jsTreeItemWithCollectionBackend(param["collectionId"], None, req.getDbSys()) #Get the checked elements in the tree try: co = collectionManager.getCollection(u"uuid://3b84d155-cc5c-428e-8009-12d5fdc68b2a", req.getDbSys()).getRange(0, None) except KeyError: co = [] #print "before containerListJson" data = jsTreeNamedItemFunc.containerListJson(p, checkedItems=co) #print data if data == u"": raise "no item, raise exception to prevent loop query" req.resp.write(data) req.resp.end()
def handleImportCollectionFromJsonRequest(): #Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"jsonCollection":-1}) h = libs.html.response.html() h.genHead('Upload Collections') if param[u"jsonCollection"] == -1: h.genForm('/apps/collection/collectionImporter.py',[['f','jsonCollection']]) else: importCollectionFromJson(param[u"jsonCollection"], h) h.write('-------------------------------------------') h.write(param[u"jsonCollection"]) h.genEnd()
def jqueryListOnCollection(req): #Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"collectionId":u"-1", u"tree":u"n", u"start":0, u"cnt":40}, req.getQueryInfo()) #print param if param["collectionId"] == "-1": #################################### # It is the root element of the tree #################################### collectionItemList = ufs.ufsRootItem() elif not objTools.isUuid(param["collectionId"]): ############################################# #It is not uuid://xxxx-xxx-xxx-xxx-xxxx-xxxx ############################################# param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"]) if not objTools.isUfsUrl(param["collectionId"]): param["collectionId"] = u"file:///"+param["collectionId"] #Change URL to file:///D:/tmp etc. collectionItemList = ufsCollection.getUfsCollection(param["collectionId"], req) req.resp.genJsonHead() #print collectionItemList.listNamedChildren(0, 40, False) ############################################## # Get checked item for tree ############################################## try: checkedItemList = collectionManager.getCollection(gCheckedCollectionId, req.getDbSys()).getRange(0, None) except KeyError: checkedItemList = [] #print "before containerListJson" # Check if we are generating the tree. if param["tree"] == u"n": #print "false" isTree = False start = int(param["start"]) cnt = int(param["cnt"]) else: isTree = True start = 0 cnt = None #print start, cnt #print >>sys.stderr, "-------------", start, cnt #data = "1" #################################################### # Generate JSON string for collection #################################################### data = collection2Json.containerListJson(collectionItemList, start, cnt, isTree, req, checkedItemList) #print data if data == u"": raise "no item, raise exception to prevent loop query" req.resp.write(data) req.resp.end()
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()
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 = req.getObjDbSys() updateCollectionFromJson(param[u"jsonCollection"], h, dbInst) h.write("-------------------------------------------") h.write(param[u"jsonCollection"]) h.genEnd()
def jqueryListOnCollection(req): #Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"collectionId":u"-1"}, req.getQueryInfo()) #Get collection from system, collection system contains cached collections and filesystem collections. if not objTools.isUuid(param["collectionId"]): #It is not uuid://xxxx-xxx-xxx-xxx-xxxx-xxxx param["collectionId"] = stringTools.jsIdDecoding(param["collectionId"]) #Output if gDebugFlag: h = libs.html.response.html() h.genHead('Collections') res = u"" res += u'<!--' if param["collectionId"] == "-1": p = ufs.ufsTreeUuidItem() #res = path else: #p = desktopApp.lib.localTreeItem.localTreeItem(path.decode('utf8')) if objTools.isUfsUrl(param["collectionId"]):#try: #h.write(realUrl) h.setEncoding("utf8") p = ufsTreeItem.getUfsTreeItem(param["collectionId"], req) #res += str(p.listNamedChildren()) else:#except ValueError: #No schema/protocol string. Normal dir p = jsTreeItemWithCollectionBackend.jsTreeItemWithCollectionBackend(param["collectionId"], None, req.getDbSys()) #Get the checked elements in the tree try: co = collectionManager.getCollection(u"uuid://3b84d155-cc5c-428e-8009-12d5fdc68b2a", req.getDbSys()).getRange(0, None) except KeyError: co = [] data = jsTreeNamedItemFunc.containerList(p, checkedItems=co) res +=u'-->' #print res,d if data == u"": raise "no item, raise exception to prevent loop query" res += data if gDebugFlag: h.write(res) h.genEnd() else: print res.encode('gbk')
import libSys import libs.services.servicesV2 as service import libs.utils.webUtils as webUtils import localLibSys from localLibs.logSys.logSys import * if __name__=='__main__': r = service.req() r.resp.genTxtHead() param = webUtils.paramWithDefault({"username":None,"passwd":None}, r.getQueryInfo()) cl(str(param)) cl("before calling verifyLogin") r.verifyLogin() u = r.getPrimaryUser() cl("primary:"+u.username) s = r.getSecondaryUsername() sec = [] for i in s: sec.append(i) if u.username == param["username"]: state = "OK" else: state = "Wrong" r.resp.write(u'{"username":"******", "secondaryUsers":"%s", "state":"%s"}'%(u.username, u','.join(sec), state)) r.resp.end()
import libSys import libs.utils.webUtils as webUtils import os # import subprocess import localLibs.logWin.appStarterFromDbus as dbusStarter if __name__ == "__main__": # Get request param: collectionId, start, cnt param = webUtils.paramWithDefault({u"path": None}) path = param["path"] print path.encode("utf8", "replace") # os.system('"'+path+'"') # subprocess.Popen('"'+path+'"',shell=True) # os.spawnv(P_NOWAIT, '"'+path+'"') try: ext = os.path.splitext(path)[1] except: ext = "" if ext in [".bat", ".py"]: dbusStarter.startAppFromDbus([path]) raise "stop here" else: os.startfile('"' + path + '"') # raise "stop there"