コード例 #1
0
ファイル: makeBranch.py プロジェクト: nobodybut/TTEngine
def getPackageRevision(id, rootPath, limit='all'):
    """

    :param id:
    """
    package = InstallPackage.objects().get(pk=id)
    revision = 0
    # get svnVersion
    for fileInfoDetail in package.files:
        svnVersion = fileInfoDetail['svnVersion']
        svnVersion = svnVersion.strip('[]')
        if svnVersion == '':
            continue
        tmpList = svnVersion.split(":")
        newRev = tmpList[len(tmpList) - 1]
        if revision == 0:
            revision = int(newRev)
            break
    # get url 2 path map
    url2path = dict()
    for fileInfoDetail in package.files:
        svnVersions = fileInfoDetail['svnVersion']
        svnVersions = svnVersion.strip("[]")
        myPath = rootPath
        if len(svnVersions) != 0:
            svnList = svnVersion.split(",")
            for svnVersion in svnList:
                urlpath = genUrlPath(svnVersion.strip('" '), myPath)
                if limit == 'all' or urlpath[0].find(limit) != -1:  # use limit to filter update
                    url2path[urlpath[0]] = urlpath[1]  # save the url 2 path relation, avoid repetition

    # create the folder to get its externals
    for url, path in url2path.iteritems():
        command_list = ['svn', 'checkout', '-r', str(revision), url, path]
        # print '[getPackageRevision] command_list: ', command_list
        subp = subprocess.Popen(command_list)
        subp.wait()


    # iterate externals and get its biggest revision
    for url, path in url2path.iteritems():
        client = pysvn.Client()
        externals = client.propget('svn:externals', path, recurse=True)
        print "[getPackageRevision] external list: "
        for extPath, data in externals.iteritems():
            print extPath, ": ", data
            extRev = getUrlRevision(data)
            if revision < extRev:
                revision = extRev
    return revision
コード例 #2
0
ファイル: makeBranch.py プロジェクト: NolanZhao/TTEngine
def getPackageRevision(id, rootPath, limit="all"):
    """

    :param id:
    """
    package = InstallPackage.objects().get(pk=id)
    revision = 0
    # get svnVersion
    for fileInfoDetail in package.files:
        svnVersion = fileInfoDetail["svnVersion"]
        svnVersion = svnVersion.strip("[]")
        if svnVersion == "":
            continue
        tmpList = svnVersion.split(":")
        newRev = tmpList[len(tmpList) - 1]
        if revision == 0:
            revision = int(newRev)
            break
    # get url 2 path map
    url2path = dict()
    for fileInfoDetail in package.files:
        svnVersions = fileInfoDetail["svnVersion"]
        svnVersions = svnVersion.strip("[]")
        myPath = rootPath
        if len(svnVersions) != 0:
            svnList = svnVersion.split(",")
            for svnVersion in svnList:
                urlpath = genUrlPath(svnVersion.strip('" '), myPath)
                if limit == "all" or urlpath[0].find(limit) != -1:  # use limit to filter update
                    url2path[urlpath[0]] = urlpath[1]  # save the url 2 path relation, avoid repetition

    # create the folder to get its externals
    for url, path in url2path.iteritems():
        command_list = ["svn", "checkout", "-r", str(revision), url, path]
        # print '[getPackageRevision] command_list: ', command_list
        subp = subprocess.Popen(command_list)
        subp.wait()

    # iterate externals and get its biggest revision
    for url, path in url2path.iteritems():
        client = pysvn.Client()
        externals = client.propget("svn:externals", path, recurse=True)
        print "[getPackageRevision] external list: "
        for extPath, data in externals.iteritems():
            print extPath, ": ", data
            extRev = getUrlRevision(data)
            if revision < extRev:
                revision = extRev
    return revision
コード例 #3
0
ファイル: views.py プロジェクト: nobodybut/TTEngine
def modifyPlatformLua(request):
    """
    machines =  Machine.objects()
    for machine in machines:
        str = genPlatform(machine.modules)
        path = "server/config/platform.lua"

        sha1 = hashlib.sha1(str).hexdigest()
        size = len(str)
        details = FileInfoDetail.objects(filePath=path, sha1=sha1, size=size)
        detail = None
        if len(details) > 0:
            detail = details[0]
            detail.filePath = path
            detail.sha1 = hashlib.sha1(str).hexdigest()
            detail.size = len(str)
            detail.svnVersion = ""
            stingIo = StringIO(str)
            detail.file.put(stingIo)
            detail.createTime = datetime.datetime.now()
            detail.updateTime = datetime.datetime.now()
    """
    path = "server/config/platform.lua"
    packages = InstallPackage.objects(
        version="国联安实盘_192.168.2.204_20140702   ")
    for package in packages:
        for file in package.files:
            if file.filePath == path:
                str = genPlatform(package.machine.modules)
                sha1 = hashlib.sha1(str).hexdigest()
                size = len(str)
                # if file.sha1 != sha1 or file.size != size:
                print package.version, "must modify"
                stingIo = StringIO(str)
                file.sha1 = sha1
                file.size = size
                file.file.replace(stingIo)
                file.save()
                break

    return HttpResponse("成功")
コード例 #4
0
ファイル: views.py プロジェクト: NolanZhao/TTEngine
def modifyPlatformLua(request):
    """
    machines =  Machine.objects()
    for machine in machines:
        str = genPlatform(machine.modules)
        path = "server/config/platform.lua"

        sha1 = hashlib.sha1(str).hexdigest()
        size = len(str)
        details = FileInfoDetail.objects(filePath=path, sha1=sha1, size=size)
        detail = None
        if len(details) > 0:
            detail = details[0]
            detail.filePath = path
            detail.sha1 = hashlib.sha1(str).hexdigest()
            detail.size = len(str)
            detail.svnVersion = ""
            stingIo = StringIO(str)
            detail.file.put(stingIo)
            detail.createTime = datetime.datetime.now()
            detail.updateTime = datetime.datetime.now()
    """
    path = "server/config/platform.lua"
    packages = InstallPackage.objects(version="国联安实盘_192.168.2.204_20140702   ")
    for package in packages:
        for file in package.files:
            if file.filePath == path:
                str = genPlatform(package.machine.modules)
                sha1 = hashlib.sha1(str).hexdigest()
                size = len(str)
                # if file.sha1 != sha1 or file.size != size:
                print package.version, "must modify"
                stingIo = StringIO(str)
                file.sha1 = sha1
                file.size = size
                file.file.replace(stingIo)
                file.save()
                break

    return HttpResponse("成功")