当前位置: 首页>>代码示例>>Python>>正文


Python styles.doUpgrade函数代码示例

本文整理汇总了Python中twisted.persisted.styles.doUpgrade函数的典型用法代码示例。如果您正苦于以下问题:Python doUpgrade函数的具体用法?Python doUpgrade怎么用?Python doUpgrade使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了doUpgrade函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_sourcestamp_version3

 def test_sourcestamp_version3(self):
     pkl = textwrap.dedent("""\
         (ibuildbot.sourcestamp
         SourceStamp
         p1
         (dp2
         S'project'
         p3
         S''
         sS'ssid'
         p4
         I10
         sS'repository'
         p5
         S''
         sS'patch_info'
         p6
         NsS'buildbot.sourcestamp.SourceStamp.persistenceVersion'
         p7
         I2
         sS'patch'
         Nsb.""")
     ss = cPickle.loads(pkl)
     styles.doUpgrade()
     self.assertEqual(ss.sourcestampsetid,10)
     self.assertEqual(ss.codebase, '')
开发者ID:gkistanova,项目名称:buildbot,代码行数:26,代码来源:test_upgrade.py

示例2: decode

 def decode(filename, data):
     log.msg("Loading %s..." % (filename,))
     sys.modules['__main__'] = EverythingEphemeral()
     application = pickle.loads(data)
     sys.modules['__main__'] = mainMod
     styles.doUpgrade()
     return application
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:twistd.py

示例3: loadBuildFromFile

    def loadBuildFromFile(self, number):
        filename = self.makeBuildFilename(number)
        try:
            log.msg("Loading builder %s's build %d from on-disk pickle"
                    % (self.name, number))
            with open(filename, "rb") as f:
                build = pickle.load(f)
            build.setProcessObjects(self, self.master)

            # (bug #1068) if we need to upgrade, we probably need to rewrite
            # this pickle, too.  We determine this by looking at the list of
            # Versioned objects that have been unpickled, and (after doUpgrade)
            # checking to see if any of them set wasUpgraded.  The Versioneds'
            # upgradeToVersionNN methods all set this.
            versioneds = styles.versionedsToUpgrade
            styles.doUpgrade()
            if True in [hasattr(o, 'wasUpgraded') for o in versioneds.values()]:
                log.msg("re-writing upgraded build pickle")
                build.saveYourself()

            # check that logfiles exist
            build.checkLogfiles()
            return build
        except IOError:
            raise IndexError("no such build %d" % number)
        except EOFError:
            raise IndexError("corrupted build pickle %d" % number)
开发者ID:PeterDaveHello,项目名称:buildbot,代码行数:27,代码来源:builder.py

示例4: load

def load(filename, style, passphrase=None):
    """Load an object from a file.

    Deserialize an object from a file. The file can be encrypted.

    @param filename: string
    @param style: string (one of 'source', 'xml' or 'pickle')
    @param passphrase: string
    """
    mode = "r"
    if style == "source":
        from twisted.persisted.aot import unjellyFromSource as load
    elif style == "xml":
        from twisted.persisted.marmalade import unjellyFromXML as load
    else:
        load, mode = pickle.load, "rb"
    if passphrase:
        fp = StringIO.StringIO(_decrypt(passphrase, open(filename, "rb").read()))
    else:
        fp = open(filename, mode)
    mainMod = sys.modules["__main__"]
    ee = _EverythingEphemeral()
    sys.modules["__main__"] = ee
    ee.initRun = 1
    value = load(fp)
    sys.modules["__main__"] = mainMod
    styles.doUpgrade()
    ee.initRun = 0
    persistable = IPersistable(value, None)
    if persistable is not None:
        persistable.setStyle(style)
    return value
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:32,代码来源:sob.py

示例5: decode

 def decode(self):
     from twisted.persisted.marmalade import unjellyFromXML
     sys.modules['__main__'] = EverythingEphemeral()
     application = unjellyFromXML(StringIO.StringIO(self.data))
     sys.modules['__main__'] = mainMod
     styles.doUpgrade()
     return application
开发者ID:fxia22,项目名称:ASM_xf,代码行数:7,代码来源:tapconvert.py

示例6: load

def load(filename, style):
    """Load an object from a file.

    Deserialize an object from a file. The file can be encrypted.

    @param filename: string
    @param style: string (one of 'pickle' or 'source')
    """
    mode = 'r'
    if style=='source':
        from twisted.persisted.aot import unjellyFromSource as _load
    else:
        _load, mode = pickle.load, 'rb'

    fp = open(filename, mode)
    ee = _EverythingEphemeral(sys.modules['__main__'])
    sys.modules['__main__'] = ee
    ee.initRun = 1
    with fp:
        try:
            value = _load(fp)
        finally:
            # restore __main__ if an exception is raised.
            sys.modules['__main__'] = ee.mainMod

    styles.doUpgrade()
    ee.initRun = 0
    persistable = IPersistable(value, None)
    if persistable is not None:
        persistable.setStyle(style)
    return value
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:31,代码来源:sob.py

示例7: testVersionUpgrade

    def testVersionUpgrade(self):
        global MyVersioned
        class MyVersioned(styles.Versioned):
            persistenceVersion = 2
            v3 = 0
            v4 = 0

            def __init__(self):
                self.somedata = 'xxx'

            def upgradeToVersion3(self):
                self.v3 = self.v3 + 1

            def upgradeToVersion4(self):
                self.v4 = self.v4 + 1
        mv = MyVersioned()
        assert not (mv.v3 or mv.v4), "hasn't been upgraded yet"
        pickl = cPickle.dumps(mv)
        MyVersioned.persistenceVersion = 4
        obj = cPickle.loads(pickl)
        styles.doUpgrade()
        assert obj.v3, "didn't do version 3 upgrade"
        assert obj.v4, "didn't do version 4 upgrade"
        pickl = cPickle.dumps(obj)
        obj = cPickle.loads(pickl)
        styles.doUpgrade()
        assert obj.v3 == 1, "upgraded unnecessarily"
        assert obj.v4 == 1, "upgraded unnecessarily"
开发者ID:lhl,项目名称:songclub,代码行数:28,代码来源:test_persisted.py

示例8: test_versionUpgrade

    def test_versionUpgrade(self):
        global MyVersioned
        class MyVersioned(styles.Versioned):
            persistenceVersion = 2
            persistenceForgets = ['garbagedata']
            v3 = 0
            v4 = 0

            def __init__(self):
                self.somedata = 'xxx'
                self.garbagedata = lambda q: 'cant persist'

            def upgradeToVersion3(self):
                self.v3 += 1

            def upgradeToVersion4(self):
                self.v4 += 1
        mv = MyVersioned()
        assert not (mv.v3 or mv.v4), "hasn't been upgraded yet"
        pickl = pickle.dumps(mv)
        MyVersioned.persistenceVersion = 4
        obj = pickle.loads(pickl)
        styles.doUpgrade()
        assert obj.v3, "didn't do version 3 upgrade"
        assert obj.v4, "didn't do version 4 upgrade"
        pickl = pickle.dumps(obj)
        obj = pickle.loads(pickl)
        styles.doUpgrade()
        assert obj.v3 == 1, "upgraded unnecessarily"
        assert obj.v4 == 1, "upgraded unnecessarily"
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:30,代码来源:test_persisted.py

示例9: test_upgrade

 def test_upgrade(self):
     self.patch(
         BuildStepStatus, "upgradeToVersion1", lambda _: self.fail("BuildStepStatus.upgradeToVersion1 called")
     )
     self.patch(BuildStatus, "upgradeToVersion1", lambda _: self.fail("BuildStatus.upgradeToVersion1 called"))
     self.patch(BuilderStatus, "upgradeToVersion1", lambda _: self.fail("BuilderStatus.upgradeToVersion1 called"))
     pkl_result = pickle.loads(self.pickle_data)
     styles.doUpgrade()
     del pkl_result
开发者ID:BME-IK,项目名称:buildbot,代码行数:9,代码来源:test_unpickling.py

示例10: testNullVersionUpgrade

 def testNullVersionUpgrade(self):
     global NullVersioned
     class NullVersioned:
         ok = 0
     pkcl = pickle.dumps(NullVersioned())
     class NullVersioned(styles.Versioned):
         def upgradeToVersion1(self):
             self.ok = 1
     mnv = pickle.loads(pkcl)
     styles.doUpgrade()
     assert mnv.ok, "initial upgrade not run!"
开发者ID:fxia22,项目名称:ASM_xf,代码行数:11,代码来源:test_persisted.py

示例11: loadChanges

 def loadChanges(self):
     filename = os.path.join(self.basedir, "changes.pck")
     try:
         changes = load(open(filename, "rb"))
         styles.doUpgrade()
     except IOError:
         log.msg("changes.pck missing, using new one")
         changes = ChangeMaster()
     except EOFError:
         log.msg("corrupted changes.pck, using new one")
         changes = ChangeMaster()
     self.useChanges(changes)
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:12,代码来源:master.py

示例12: builderAdded

    def builderAdded(self, name, basedir, category=None, description=None):
        """
        @rtype: L{BuilderStatus}
        """
        filename = os.path.join(self.basedir, basedir, "builder")
        log.msg("trying to load status pickle from %s" % filename)
        builder_status = None
        try:
            with open(filename, "rb") as f:
                builder_status = load(f)
            builder_status.master = self.master

            # (bug #1068) if we need to upgrade, we probably need to rewrite
            # this pickle, too.  We determine this by looking at the list of
            # Versioned objects that have been unpickled, and (after doUpgrade)
            # checking to see if any of them set wasUpgraded.  The Versioneds'
            # upgradeToVersionNN methods all set this.
            versioneds = styles.versionedsToUpgrade
            styles.doUpgrade()
            if True in [hasattr(o, 'wasUpgraded') for o in versioneds.values()]:
                log.msg("re-writing upgraded builder pickle")
                builder_status.saveYourself()

        except IOError:
            log.msg("no saved status pickle, creating a new one")
        except:
            log.msg("error while loading status pickle, creating a new one")
            log.msg("error follows:")
            log.err()
        if not builder_status:
            builder_status = builder.BuilderStatus(name, category, self.master,
                                                   description)
            builder_status.addPointEvent(["builder", "created"])
        log.msg("added builder %s in category %s" % (name, category))
        # an unpickled object might not have category set from before,
        # so set it here to make sure
        builder_status.category = category
        builder_status.description = description
        builder_status.master = self.master
        builder_status.basedir = os.path.join(self.basedir, basedir)
        builder_status.name = name  # it might have been updated
        builder_status.status = self

        if not os.path.isdir(builder_status.basedir):
            os.makedirs(builder_status.basedir)
        builder_status.determineNextBuildNumber()

        builder_status.setBigState("offline")

        for t in self.watchers:
            self.announceNewBuilder(t, name, builder_status)

        return builder_status
开发者ID:AsylumCorp,项目名称:buildbot,代码行数:53,代码来源:master.py

示例13: test_nullVersionUpgrade

 def test_nullVersionUpgrade(self):
     global NullVersioned
     class NullVersioned(object):
         def __init__(self):
             self.ok = 0
     pkcl = pickle.dumps(NullVersioned())
     class NullVersioned(styles.Versioned, object):
         persistenceVersion = 1
         def upgradeToVersion1(self):
             self.ok = 1
     mnv = pickle.loads(pkcl)
     styles.doUpgrade()
     assert mnv.ok, "initial upgrade not run!"
开发者ID:marcelpetersen,项目名称:localnews,代码行数:13,代码来源:test_persisted.py

示例14: loadOID

 def loadOID(self, oid):
     
     # maintenance note: when implementing future, truly async loadOID
     # methods, it may be useful to keep a dictionary around of
     # previously-loaded OIDs during recursive loads to make sure that we
     # don't send multiple requests to the DB for the same OID in the same
     # actual request.
     
     f = open(os.path.join(self.dirname, str(oid)))
     up = pickle.Unpickler(f)
     up.persistent_load = self.persistentLoad
     obj = up.load()
     # cheating...
     from twisted.persisted.styles import doUpgrade
     doUpgrade()
     return defer.succeed(obj)
开发者ID:fxia22,项目名称:ASM_xf,代码行数:16,代码来源:picklesicle.py

示例15: migrate_changes

    def migrate_changes(self):
        # if we still have a changes.pck, then we need to migrate it
        changes_pickle = os.path.join(self.basedir, "changes.pck")
        if os.path.exists(changes_pickle):
            if not self.quiet:
                print "migrating changes.pck to database"

            # 'source' will be an old b.c.changes.ChangeMaster instance, with a
            # .changes attribute
            source = cPickle.load(open(changes_pickle, "rb"))
            styles.doUpgrade()

            if not self.quiet:
                print " (%d Change objects)" % len(source.changes)

            # first, scan for changes without a number.  If we find any, then we'll
            # renumber the changes sequentially
            have_unnumbered = False
            for c in source.changes:
                if c.revision and c.number is None:
                    have_unnumbered = True
                    break
            if have_unnumbered:
                n = 1
                for c in source.changes:
                    if c.revision:
                        c.number = n
                        n = n + 1

            # insert the changes
            cursor = self.conn.cursor()
            for c in source.changes:
                if not c.revision:
                    continue
                self._addChangeToDatabase(c, cursor)

            # update next_changeid
            max_changeid = max([c.number for c in source.changes if c.revision] + [0])
            cursor.execute("""INSERT into changes_nextid VALUES (%d)""" % (max_changeid + 1))

            if not self.quiet:
                print "moving changes.pck to changes.pck.old; delete it or keep it as a backup"
            os.rename(changes_pickle, changes_pickle + ".old")
        else:
            c = self.conn.cursor()
            c.execute("""INSERT into changes_nextid VALUES (1)""")
开发者ID:cread,项目名称:buildbot,代码行数:46,代码来源:v1.py


注:本文中的twisted.persisted.styles.doUpgrade函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。