Esempio n. 1
0
    def _getTraversalResult(self, arg, params):
        id = WebFunc.checkId(arg, self.traversalMap)
        start = int(params.get('offset', 0))
        limit = int(params.get('limit', -1))

        try:
            ret = []
            end = 0
            traversalInfo = self.traversalMap[id]['info']
            traversalInfo['lastTime'] = int(time.time())
            if limit > 0: end = start + limit
            result = ProfileFunc.getTraversalTBWithId(id, start, end)
            resultLen = len(result)
            if resultLen < limit:
                limit = resultLen
                end = start + limit
            ProfileFunc.delTraversalTBWithId(id, end)
            traversalInfo['start'] = end
            Log.info(
                'Get TraversalFolder Result:start[%d], limit[%d], count[%d]' %
                (start, limit, len(result)))
            return WebFunc.jsonResult({'files':result, 'finish':traversalInfo['finished'], \
                        'fileCount':traversalInfo['fileCount'], 'folderCount':traversalInfo['folderCount']})
        except Exception, e:
            Log.error("Get Traversal Folder Result Failed! Reason[%s]" % e)
            return cherrypy.HTTPError(462, 'Operation Failed')
Esempio n. 2
0
 def DELETE(self, *arg, **params):
     id = WebFunc.checkId(arg, self.operateMap)
     try:
         b_obj = self.operateMap.pop(id)
         b_obj['finished'] = 1
         Log.info('Batch[%s] Canceled!!!!' % id)
         cherrypy.response.status = 205
         return
     except Exception, e:
         Log.error("Batch[%s] Failed! Reason[%s]" % (id, e))
         raise cherrypy.HTTPError(462, 'Operation Failed')
Esempio n. 3
0
    def _cancelTraversalFolder(self, arg):
        sid = WebFunc.checkId(arg, self.traversalMap)
        try:
            traversalMapEntry = self.traversalMap[sid]
            traversalInfo = traversalMapEntry['info']
            traversalInfo['finished'] = 1

            del self.traversalMap[sid]
            ProfileFunc.delTraversalCacheDB(sid)
            Log.info('Cancel Traversal Folder!!!!')
        except Exception, e:
            Log.exception("Cancel Traversal Folder Failed! Reason[%s]" % e)
            raise cherrypy.HTTPError(462, 'Operation Failed')
Esempio n. 4
0
    def DELETE(self, *arg, **params):
        sid = WebFunc.checkId(arg, self.searchMap)
        try:
            searchInfo = self.searchMap[sid]['info']
            searchInfo['finished'] = 1

            del self.searchMap[sid]
            ProfileFunc.delSearchCacheDB(sid)
            Log.debug('Cancel Search!!!!')

        except Exception, e:
            Log.error("Cancel Search Failed! Reason[%s]" % e)
            raise cherrypy.HTTPError(462, 'Operation Failed')
Esempio n. 5
0
 def GET(self, *arg, **params):
     sid = WebFunc.checkId(arg, self.searchMap)
     start = int(params.get('offset', 0))
     limit = int(params.get('limit', -1))
     try:
         end = 0
         searchInfo = self.searchMap[sid]['info']
         searchInfo['lastTime'] = int(time.time())
         if limit > 0: end = start + limit
         result = ProfileFunc.getSearchTBWithId(sid, start, end)
         resultLen = len(result)
         if resultLen < limit:
             limit = resultLen
             end = start + limit
         ProfileFunc.delSearchTBWithId(sid, end)
         searchInfo['start'] = end
         Log.info('Get Search Result: start[%d], limit[%d], count[%d]' %
                  (start, limit, len(result)))
         return WebFunc.jsonResult({'files':result, 'finished':searchInfo['finished'], \
                     'folderCount':searchInfo['folderCount'], 'fileCount':searchInfo['fileCount']})
     except Exception, e:
         Log.error("Get Search Result Failed! Reason[%s]" % e)
         raise cherrypy.HTTPError(462, 'Operation Failed')
Esempio n. 6
0
 def GET(self, *arg, **params):
     id = WebFunc.checkId(arg, self.operateMap)
     ret = self.operateMap[id]
     ret['progress'] = int(ret['finishedFiles']) * 100 / int(
         ret['totalFiles'])
     return WebFunc.jsonResult({'files': ret})