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


Python machine.Machine类代码示例

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


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

示例1: test_issue

    def test_issue(self):
        machine = Machine()
        instr = Instruction(0x20010003)
        self.assertTrue(machine.issue(instr))
        self.assertTrue(machine.hasInstruction())

        rstations = machine.unitContainers['IntUnit'].dumpRStations()
开发者ID:kaledj,项目名称:TomasuloSim,代码行数:7,代码来源:test_machine.py

示例2: StarTest

class StarTest(object):
    def __init__(self, tmpdir):
        self.tmpdir = str(tmpdir)
        self.root = Compound(None, 'root')
        self.events = {}
        for meth_name in dir(self):
            meth = getattr(self, meth_name)
            ticks = getattr(meth, 'ticks', None)
            if ticks is not None:
                for tick in ticks:
                    events = self.events.get(tick, [])
                    events.append(meth)
                    self.events[tick] = events

    def each_tick(self, tick):
        pass

    def each_clock(self, clock):
        pass

    def get_total_ticks(self):
        return max(self.events.keys() or [0]) + 1

    def run_machine(self, ticks=None):
        self.machine = Machine(self.root, on_tick=self.each_tick,
                               on_clock=self.each_clock)
        self.machine.run(ticks or self.get_total_ticks(), self.events)

    def view(self, prefix, tick=None):
        tick = tick if tick is not None else self.machine.tick
        builder = GraphBuilder()
        graph = builder.visit(self.root)
        graph.render(os.path.join(self.tmpdir, '%s_%i' % (prefix, tick)))
开发者ID:MeadBarrel,项目名称:starschematic,代码行数:33,代码来源:_startest.py

示例3: main

def main(argv):
	
	if len(argv) < 5:
		print "Usage: mipssim.py -i [input_file_name] -o [output_file_name]"
		quit(-1)
	try:
		inputFilenameIndex = argv.index('-i') + 1
		outputFilenameIndex = argv.index('-o') + 1
	except ValueError:
		print "Usage: mipssim.py -i [input_file_name] -o [output_file_name]"
		quit(-1)
	
	infileName = argv[inputFilenameIndex]
	if '.bin' not in infileName:
		infileName+='.bin'
	outFileName = argv[outputFilenameIndex]
	
	(word, address) = filemanager.loadInstructionsAndAddresses(infileName)
	instruction = []
	for i in range(len(word)):
		instruction.append(Instruction(word[i], address[i]))
	
	disassembler.target_file = open(outFileName+'_dis.txt', 'w')
	disassembler.disassembleSet(instruction)
	mips = Machine(outFileName+'_sim.txt')
	mips.loadInstructions(instruction)
	mips.executeInstructions()
开发者ID:dane-johnson,项目名称:CS-312,代码行数:27,代码来源:mipssim.py

示例4: main

def main():
    if len(sys.argv) != 3:
        print "usage: %s [input_directory] [output_directory]" % (sys.argv[0])
        sys.exit()

    input_dir = os.path.abspath(sys.argv[1])
    output_dir = os.path.abspath(sys.argv[2])
    os.path.exists(output_dir) or os.mkdir(output_dir)

    framework_dir = os.path.dirname(os.path.abspath(os.path.join(os.getcwd(), __file__)))
    os.chdir(framework_dir)

    m = Machine(input_dir=input_dir, output_dir=output_dir, framework_dir=framework_dir, program=[])
    m.setup(
        "defaults",
        "exception",
        "parse",
        "modules",
        "php_backend",
        "php_view",
        "macro",
        "global_command",
        "guard",
        "handler",
        "view",
        "generate",
    )
    m.boot()
开发者ID:reusee,项目名称:defphp,代码行数:28,代码来源:defwork.py

示例5: __init__

 def __init__(self, vm_limit, azure_config, skip_setup, local):
     self.vm_limit = vm_limit # user input
     self.budget = 0
     self.timestamp = datetime.now()
     self.cost_pred = 0
     self.wf_end = None
     
     self.jobs_terminated = False
     self.last_resched = None
     
     self.workflow = Workflow()
     self.logwatcher = LogWatcher()
     
     self.schedule = Schedule()
     
     manager = Machine()
     manager.status = MachineStatus.manager
     manager.condor_slot = 'manager'
     self.machines = [manager]
     
     boot_entry = ScheduleEntry(Job('boot', None), manager, self.timestamp, self.timestamp)
     boot_entry.real_start = self.timestamp
     boot_entry.real_end = self.timestamp
     boot_entry.status = EntryStatus.completed
     self.schedule.add_entry_host(boot_entry, manager)
     
     self.local = local
     if azure_config and not local:
         hostname = socket.gethostname()
         self.exp = AzureExperiment(azure_config, skip_setup=skip_setup, name=hostname)
         self.master_addr = socket.gethostbyname(hostname)
         self.user = azure_config.admin_username
     else:
         self.exp = self.master_addr = self.user = None
开发者ID:rika,项目名称:dynamic-provisioning,代码行数:34,代码来源:provisioner.py

示例6: test_math_is_right_on_restock

    def test_math_is_right_on_restock(self):
        bev1 = Beverage('Coke', 150, 1.00)
        bev = ['Coke', 150, 1.00]

        my_machine = Machine()
        my_machine.beverages.append((bev1))

        self.assertEqual('9 Cokes have been added to the machine', my_machine.restock(bev, 9))
开发者ID:carjug,项目名称:python-class-practice,代码行数:8,代码来源:test_machine.py

示例7: test_brUnit1

 def test_brUnit1(self):
     sys.stdout = output = io.StringIO()
     machine = Machine()
     machine.loadProgram('Tomasulo/brUnit1.hex')
     machine.run()
     with open('Tomasulo/brUnit1.out', 'r') as answerFile:
         answer = answerFile.read()
     self.assertEquals(output.getvalue(), answer)
开发者ID:kaledj,项目名称:TomasuloSim,代码行数:8,代码来源:test_tomasulo.py

示例8: run

def run():
    print 'machine echo side a'
    ma = Machine('proxy_runner')
    ma.add_peer(peer)
    n = ProxyNode('node.example.TestNode')
    ma.add(n)

    return ma
开发者ID:Strangemother,项目名称:python-state-machine,代码行数:8,代码来源:proxynode.py

示例9: run

def run():
	m = Machine('Chain')
	a = A()
	nodes = [a, B(), C(), D(), E(), F(), G(), H(), I(), J(), K(), L(), M()]
	m.nodes.add(*nodes)
	a=m.get_nodes('A')[0]
	import pdb; pdb.set_trace()
	a.set('on', True)
	return m
开发者ID:Strangemother,项目名称:python-state-machine,代码行数:9,代码来源:chain.py

示例10: test_allInts

 def test_allInts(self):
     for i in range(1, 9):
         sys.stdout = output = io.StringIO()
         machine = Machine()
         machine.loadProgram('Tomasulo/intUnit{0}.hex'.format(i))
         machine.run()
         with open('Tomasulo/intUnit{0}.out'.format(i), 'r') as answerFile:
             answer = answerFile.read()
         self.assertEquals(output.getvalue(), answer)
开发者ID:kaledj,项目名称:TomasuloSim,代码行数:9,代码来源:test_tomasulo.py

示例11: run

def run():
    print 'running simple machine'
    m = Machine()
    m.add_peer('PYRO:[email protected]:55090')
    a = A()
    m.add(a)

    print 'perform a.one += 4'
    a.one += 4
    return m
开发者ID:Strangemother,项目名称:python-state-machine,代码行数:10,代码来源:foo.py

示例12: test_all

 def test_all(self):
     sys.stdout = output = io.StringIO()
     for inputFile in os.listdir('Tomasulo'):
         if inputFile.endswith('.dlx'): continue
         if inputFile.endswith('.out'): continue
         machine = Machine()
         machine.loadProgram('Tomasulo/' + inputFile)
         machine.run()
         with open('Tomasulo/' + inputFile.strip('.hex') + '.out', 'r') as answerFile:
             answer = answerFile.read()
         self.assertEquals(output.getvalue(), answer)
开发者ID:kaledj,项目名称:TomasuloSim,代码行数:11,代码来源:test_tomasulo.py

示例13: process_start_trans_tape

def process_start_trans_tape(start_status, transition, tape):
    print("Transition:")
    print(transition)
    print("Tape:")
    print(tape)
    if not start_status:
        machine = Machine(transition,tape)
    else:
        machine = Machine(transition,tape,start_status)
    print("Execution:")
    machine.execute()
开发者ID:gcali,项目名称:pturing,代码行数:11,代码来源:main.py

示例14: test_count_bevs_of_one_name

    def test_count_bevs_of_one_name(self):
        my_machine = Machine()
        bevs = []
        new_bev = Beverage('Coke', 150, 1.00)
        new_bev2 = Beverage('Coke', 150, 1.00)
        new_bev3 = Beverage('Pepsi', 150, 1.50)
        bevs.append(new_bev)
        bevs.append(new_bev2)
        bevs.append(new_bev3)
        my_machine.beverages = bevs

        self.assertEqual(2, my_machine.get_number_of_bev('Coke'))
开发者ID:carjug,项目名称:python-class-practice,代码行数:12,代码来源:test_machine.py

示例15: sync_machines

 def sync_machines(self):
     slots = condor_slots()
     for s in slots:
         if s not in [m.condor_slot for m in self.machines]:
             machine = Machine()
             machine.status = MachineStatus.running
             machine.condor_slot = s
             boot_job = Job('boot', None)
             boot_entry = ScheduleEntry(boot_job, machine, None, None)
             boot_entry.log[LogKey.real_start] = self.creation_timestamp
             boot_entry.log[LogKey.real_end] = self.timestamp
             boot_entry.status = EntryStatus.completed
             self.entries.append(boot_entry)
             self.machines.append(machine)
             print "++Machine", s
开发者ID:rika,项目名称:dynamic-provisioning,代码行数:15,代码来源:monitor.py


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