コード例 #1
0
ファイル: server.py プロジェクト: billy3321/ivod-download
    def index(self, *args):
        from mako.template import Template
        tmpl = Template(filename='template.mako', output_encoding='utf-8')
        data = {}
        cd = collections.defaultdict


        data['status'] = cd(lambda: cd(lambda: cd(lambda: cd(int))))

        db = DB()
        rows = db.get_status()
        db.close()
        for year, clip, bw, state, count in rows:
            print year, clip, bw, state, count
            state = {
                    'no': u'未下載',
                    '404': u'404 not found (to try)',
                    '404skip': u'404 not found',
                    'downloading': u'下載中',
                    'downloaded': u'已下載(a)',
                    'stored': u'已下載(b)',
                    }.get(state, u'其他')
            data['status'][year][clip][bw][state] = count

        print data

        result = tmpl.render(**data)
        return result
コード例 #2
0
ファイル: server.py プロジェクト: billy3321/ivod-download
 def status(self):
     db = DB()
     rows = db.get_status()
     db.close()
     return json.dumps(rows)