Beispiel #1
0
    def ChangeSet(self,arch,source_version,target_version):
        out = ''
        arches = self.request.get('arches')
        if arches:
            oarch,narch = (int(_) for _ in arches.split('|')[:2])
        else:
            oarch = version_arch(source_version)
            narch = version_arch(target_version)

        if oarch is None: oarch = arch
        if narch is None: narch = arch

        omanifest = fetcher.fetch(oarch,source_version,'manifest.xml')
        nmanifest = fetcher.fetch(narch,target_version,'manifest.xml')


        if omanifest is not None:
            #Version(value=source_version,key_name=source_version).put()
            version_ok(oarch,source_version)
        if nmanifest is not None:
            #Version(value=target_version,key_name=target_version).put()
            version_ok(narch,target_version)            
        if omanifest is None:
            out += ('Sorry, could not fetch manifest for %s' % source_version)
        elif nmanifest is None:
            out += ('Sorry, could not fetch manifest for %s' % target_version)
        else:
            omanifest = Manifest(omanifest)
            nmanifest = Manifest(nmanifest)

            changeset = Changeset(omanifest,nmanifest)

            changes = ( {'path' : f, 'old_version' : omanifest.files[f]['version'], \
                    'new_version' : nmanifest.files[f]['version'] } for f in changeset.changes )
            adds = ( {'path' : f,  \
                    'new_version' : nmanifest.files[f]['version'] } for f in changeset.adds )
            dels = ( {'path' : f, 'old_version' : omanifest.files[f]['version']\
                     } for f in changeset.dels )

            template_values = {
                    'source_version': source_version,
                    'target_version': target_version,
                    'changes': changes,
                    'adds' : adds,
                    'dels' : dels,
                    'base_url' : fetcher.get_base_url(arch),
                    'base_url2' : fetcher.get_base_url(arch, 1),
                    'arches' : '|'.join([str(_) for _ in [oarch,narch]]),
                    }
            template = templates.get_template('changeset.html')
            return template.render(template_values)
        self.response.out.write(out)
        return None
Beispiel #2
0
    def get_page(self,arch,version,path,fpath):
        manifest = fetcher.fetch(arch,version,'manifest.xml')
        if manifest is not None:
            #Version(value=version,key_name=version).put()
            version_ok(arch,version)
        else:
            self.response.out.write("Sorry, could not fetch manifest for {0} version".format(version))
            return
        manifest = Manifest(manifest)
        path = path[1:]
        if fpath != '':
            print 'file requested!'
        else:
            if path == '':
                nodes = manifest.files.keys()
            else:
                l = len(path)
                nodes = [f[l:] for f in manifest.files.keys() if f.startswith(path)]
            dirs = []
            files = []
            for x in nodes:
                n = x.split('/')
                if len(n) == 1:
                    x = path + x
                    f = { 'path' : n[0] , 'version' : fetcher.normalize_ver(manifest.files[x]['version']), 'size' : manifest.files[x]['size'] }
                    f['lang'] = get_lang(n[0])
                    f['fullpath'] = x
                    files.append(f)
                else:
                    dirs.append(n[0])
            dirs = frozenset(dirs)

            if path != '':
                up_url = '..'
            else:
                up_url = ''

            template_values = {
                    'version': version,
                    'path': path,
                    'dirs': sorted(list(dirs)),
                    'files' : files,
                    'up_url' : up_url,
                    'base_url' : fetcher.get_base_url(arch),
                    'base_url2' : fetcher.get_base_url(arch, 1),
                    }
            template = templates.get_template('folder.html')
            return template.render(template_values)
Beispiel #3
0
def import_manifest(arch,version):
    v = Version.get_by_key_name(version)
    if v is None or not v.imported:
        m = fetcher.fetch(arch,version,'manifest.xml')
        if m is not None:
            m = Manifest(m)
            #xg_on = db.create_transaction_options(xg=True)
            v = version_ok(arch,version)
            prev = db.GqlQuery('select * from Version where imported = True and arch = {0}'.format(arch)).fetch(1)
            if prev is not None and len(prev) > 0:
                prev = prev[0]
                from htmldiff import Changeset
                pmanifest = Manifest(fetcher.fetch(arch,prev.value,'manifest.xml'))
                changes = Changeset(pmanifest,m)
                to_delete = [ pmanifest.files[x] for x in changes.dels | changes.changes 
                        if pmanifest.files[x]['path'].endswith('entity') and pmanifest.files[x]['path'].startswith('game/resources0.s2z')]
                to_import = [ m.files[x] for x in changes.adds | changes.changes if 
                        m.files[x]['path'].endswith('entity') and m.files[x]['path'].startswith('game/resources0.s2z')]
                total = len(to_delete)
                current = 1
                del(changes)
                del(m)
                del(pmanifest)
                for file in to_delete:
                    e = Node.get_by_key_name('|'.join([file['version'],file['path']]))
                    if e is not None:
                        logging.info('[{1}/{2}] Deleting {0} entity group'.format('|'.join([file['version'],file['path']]),current,total))
                        db.run_in_transaction(delete_group,e)
                    current += 1
                del(to_delete)
            else:
                prev = None
                to_import = [x for x in m.files.values() if x['path'].endswith('entity') and x['path'].startswith('game/resources0.s2z')]
            
            total = len(to_import)
            current = 1
            for file in to_import:
                if file['path'].endswith('.entity'):
                    e = Node.get_by_key_name('|'.join([file['version'],file['path']]))
                    if e is None:
                        data = fetcher.fetch(arch,file['version'],file['path'])
                        #if data is None:
                            #continue
                        logging.info('[%d/%d] importing %s %s into db' % (current,total,file['version'],file['path']))
                        db.run_in_transaction(parse_entity,data,file['version'],file['path'],[version])
                        #db.run_in_transaction_options(xg_on,parse_entity,file['version'],file['path'],[version])
                    #elif version not in e.versions:
                        #db.run_in_transaction(set_version,e,version)
                current += 1
            v.imported = True
            v.put()
            if prev is not None:
                prev.imported = False
                prev.put()
Beispiel #4
0
 def get_page(self,arch,version):
     manifest = fetcher.fetch(arch,version,'manifest.xml')
     if manifest is not None:
         version_ok(arch,version)
     else:
         self.response.out.write("Sorry, could not fetch manifest for {0} version".format(version))
         return
     manifest = Manifest(manifest)
     data = fetcher.fetch(arch,fetcher.normalize_ver(manifest.files['change_log_color.txt']['version']),'change_log_color.txt')
     if data is None: return
     data = data.read()
     try:
         data = data.decode('utf8')
     except:
         data = data.decode('cp1251')
     data = data.replace('\r\n','\n')
     data = hon2html(data)
     data = re.sub(ver_sub,r'\1[color=Yellow][SIZE=6][b]\2[/b][/size][/color]',data)
     data = re.sub(head_sub,r'\1[B]==[SIZE=4]\2[/size]==[/b]',data)
     data = re.sub(hr_sub,r'[hr][/hr]',data)
     smilies = fetch_honsmilies()
     data = re.sub(smilies[0],lambda m: '%s%s  [b]%s[/b]' % (m.group(1), smilies[1][m.group(2).lower()], m.group(2)),data)
     return ''.join(['<pre>',data,'</pre>'])
Beispiel #5
0
 def get(self):
     retail = OsArchTuple.get_by_key_name("0")
     rct = OsArchTuple.get_by_key_name("1")
     sbt = OsArchTuple.get_by_key_name("2")
     try:
         version_ok(
             ARCHS.LINUX_RETAIL, getVerInfo(retail.os, retail.arch, "masterserver.hon.s2games.com")[0]["version"]
         )
     except:
         pass
     try:
         version_ok(ARCHS.LINUX_RCT, getVerInfo(rct.os, rct.arch, "masterserver.hon.s2games.com")[0]["version"])
     except:
         pass
     try:
         version_ok(ARCHS.LINUX_SBT, getVerInfo(sbt.os, sbt.arch, "masterserver.hon.s2games.com")[0]["version"])
     except:
         pass