Exemplo n.º 1
0
 def compile(self,path,liteFile,out):
     paths = [path];
     sources = [self.readFile(self.liteBase+path)];
     decoratorPath = '/WEB-INF/decorators.xml';
     decoratorXml = self.readFile(self.liteBase+decoratorPath);
     if decoratorXml:
         sources.append(decoratorXml);
         paths.append(decoratorPath);
     #最多尝试6次
     test = 6;
     while test>0 :
         test = test-1;
         code = self.httpLoad(paths,sources,out);
         if not code:
             continue;
         result = json_decode(code);
         if not result:
             continue;
         if not isinstance(result,list):
             missed = result["missed"];
             retry = False;
             for path in missed:
                 if path not in paths:
                     content = self.readFile(self.liteBase+path);
                     sources.append(content);
                     paths.append(path);
                     retry = True;
             if not retry:
                 return [paths,[code]];
         else:
             self.writeCache(liteFile,paths,code)
             return [paths,result];
Exemplo n.º 2
0
 def load(self,path,out):
     liteFile = self.liteCached+path.replace('/','.')
     if exists(liteFile):
         lite = json_decode(self.readFile(liteFile))
         paths = lite[0]
         liteTime = getmtime(liteFile)
         fileTime = liteTime
         for item in paths:
             fileTime = max(fileTime,getmtime(self.liteBase+item))
         if fileTime<=liteTime:
             return lite[1]
     lite = self.compile(path,liteFile,out)
     return lite[1]