Пример #1
0
 def get(self, collectionname):
     name = tornado.escape.url_unescape(collectionname)
     hidemissing = 'true' == self.get_argument('hidemissing',
                                               default='false')
     cdb = self.settings['session'].query(orm.Collection)\
         .filter(orm.Collection.name == name)\
         .first()
     if not cdb:
         _log().warning('collection {} not found'
                        .format(name))
         self.send_error(404)
         return
     games = []
     for dbg in cdb.games:
         if hidemissing and dbg.status == 'missing':
             continue
         g = dbg.as_dict()
         g['nfo'] = 'missing'
         for v in dbg.variants:
             nfofile = filenames.nfo(self.settings['home'],
                                     v)
             if os.path.exists(nfofile):
                 g['nfo'] = 'present'
                 break
         games.append(g)
     _log().debug('returning {} with {} games'
                  .format(name, len(games)))
     # _log().debug(json.dumps(games, indent=4))
     self.write(json.dumps({
         'collection': cdb.as_dict(),
         'games': games,
     }))
Пример #2
0
 def scrap_missing(self):
     l = []
     for v in self.session.query(orm.Variant):
         nfofile = filenames.nfo(self.home,
                                 v)
         if os.path.exists(nfofile):
             _log().debug('scrapper skipping {}, found {}'
                          .format(v.name, nfofile))
             continue
         romfile = filenames.variant(self.home, v)
         if not os.path.exists(romfile):
             _log().debug('scrapper skipping {}, rom not found {}'
                          .format(v.name, romfile))
             continue
         l.append(self.scrap(v, nfofile))
         if len(l) > 5:
             yield l
             l = []
     if len(l) > 0:
         yield l