예제 #1
0
manager = ThreadedManager(name="GlobalManager",threads=getTrainThreads())
manager.start()

class TrainUpdate(Update):
    def wait_alterability(self):
        return True
    def apply(self):
        for train in self.manager.threads:
            train.direction = "right"
        addMethodToClass(main.Train,"__int__",newTrainInit)
        addMethodToClass(main.Train,"switch_direction",switch_direction)
    def cleanup(self):
        print("Trains sucessfully updated")

manager.add_update(TrainUpdate(name="Trains"))

class SafeMethodUpdate(Update):
    def __init__(self,cls,method,nmethod,name=None):
        self.cls = cls
        self.method = method
        self.nmethod = nmethod
        super(SafeMethodUpdate,self).__init__(name=name)
    def wait_alterability(self):
        return waitQuiescenceOfFunction(self.method)
    def apply(self):
        addMethodToClass(self.cls,self.method.__name__,self.nmethod)
    def cleanup(self):
        print("Method "+self.method.__name__+" of class "+self.cls.__name__+" updated")
        return True
예제 #2
0
#parsed

from pymoult.highlevel.updates import SafeRedefineUpdate
from pymoult.highlevel.managers import ThreadedManager
import sys

main = sys.modules["__main__"]


def hello_v2():
    print("Hello Dave")


manager = ThreadedManager()
manager.start()
update = SafeRedefineUpdate(main, main.hello, hello_v2)

manager.add_update(update)
예제 #3
0
account_manager.start()
site_manager = ThreadedManager(threads=[main.main_thread])
site_manager.start()
functions_manager = ThreadedManager(threads=[main.main_thread])
functions_manager.start()


def transformer_site(site):
    site.owner = None

def transformer_account(account):
    account.friends=[]

site_update = LazyConversionUpdate(main.Site,SiteV2,transformer_site,None)
account_update = LazyConversionUpdate(main.Account,AccountV2,transformer_account,None)
account_manager.add_update(account_update)
site_manager.add_update(site_update)

class ClassUpdate(Update):
    def wait_alterability(self):
        return True
    def apply(self):
        redefineClass(main,main.Site,SiteV2)
        redefineClass(main,main.Account,AccountV2)

clsupdate = ClassUpdate()
functions_manager.add_update(clsupdate)
    
do_command_update = SafeRedefineUpdate(main,main.do_command,do_commandV2)
functions_manager.add_update(do_command_update)
do_create_update = SafeRedefineUpdate(main,main.do_create,do_createV2)