示例#1
0
def main() -> None:
    usage = '''

Usage (from `PyBoardTypeshedGenerator`'s directory) one of:
  1. `python3 main.py <destination directory>`.
  2. `./main.py <destination directory>` (if `main.py` is executable).
'''
    assert len(argv) > 1, 'No destination directory given.' + usage
    assert len(argv) == 2, 'Extra argument(s) given.' + usage
    shed = RST2PyI(output_dir=argv[1])
    uasyncio(shed)
    math(shed)
    gc(shed)
    cmath(shed)
    uctypes(shed)
    ucryptolib(shed)
    ubluetooth(shed)
    network(shed)
    micropython(shed)
    framebuf(shed)
    btree(shed)
    machine(shed)
    lcd160cr(shed)
    uarray(shed)
    pyb(shed)
示例#2
0
def main() -> None:
    usage = '''

Usage (from `ByBoardTypeshedGenerator`'s directory) one of:
  1. `python3 main.py <destination directory>`.
  2. `./main.py <destination directory>` (if `main.py` is executable).
'''
    assert len(argv) > 1, 'No destination directory given.' + usage
    assert len(argv) == 2, 'Extra argument(s) given.' + usage
    shed = RST2PyI(output_dir=argv[1])
    btree(shed)
    machine(shed)
    lcd160cr(shed)
    uarray(shed)
    pyb(shed)
示例#3
0
文件: script.py 项目: jcatw/bitrans
 def opcount(self):
     if self.nops is None:
         stack_machine = machine.machine()
         machine.lock()   #don't actually do anything
         self.interpret(stack_machine)
         machine.unlock()
     return self.nops
示例#4
0
文件: script.py 项目: marchon/bitrans
 def opcount(self):
     if self.nops is None:
         stack_machine = machine.machine()
         machine.lock()  #don't actually do anything
         self.interpret(stack_machine)
         machine.unlock()
     return self.nops
示例#5
0
 def interpret(self, stack_machine = None, transaction = None, index = None, animate = False):
     if stack_machine is None:
         stack_machine = machine.machine()  # create a clean machine if none provided
     if animate:
         stack_machine.draw()
     while not self.bstream.isempty():
         code = self.bstream.read(1).unsigned(endian="big")
         op = ops.code[code]
         print op
         
         #special cases
         if op.word == "OP_IF" or op.word == "OP_NOTIF":
             top_value = stack_machine.pop()
             if op.word == "OP_IF":
                 consequence = top_value.signed() != 0
             elif op.word == "OP_NOTIF":
                 consequence = top_value.signed() == 0
             if consequence:
                 stack_machine.pushifstate("eval-consequent")
                 continue
             else:
                 stack_machine.pushifstate("ignore-consequent")
                 stack_machine.lock()
                 continue
         elif op.word == "OP_ELSE":
             if not stack_machine.inif():
                 print "OP_ELSE called outside of if statement"
                 return False
             if stack_machine.inifstate("eval-consequent"):
                 stack_machine.changeifstate("ignore-alternative")
                 stack_machine.lock()
             elif stack_machine.inifstate("ignore-consequent"):
                 stack_machine.changeifstate("eval-alternative")
                 stack_machine.unlock()
         elif op.word == "OP_ENDIF":
             if not stack_machine.inif():
                 print "OP_ENDIF called outside of if statement"
                 return False
             if stack_machine.inifstate("ignore-alternative"):
                 stack_machine.unlock()
             stack_machine.popifstate()
         elif op.word == 'OP_CHECKSIG':  #checksig is a special case
             if transaction is None or index is None:
                 print "OP_CHECKSIG called but transaction or index missing; script invalid"
                 return False
             op(self.bstream, stack_machine, transaction, index, self)
         # usual case
         else:
             op(self.bstream, stack_machine)
             
         if animate:
             stack_machine.draw(op)
     
     # reset the stream
     self.bstream = self.stream()
     if stack_machine.peek().unsigned() == 0:
         return False
     return True
示例#6
0
    def __init__(self):
        Thread.__init__(self)

        #self.htmlnam = "webioc.html"
        self.htmlnam = "/ceph/WWW/SlowControls2018/webioc.html"

        #open the configuration
        csv = pd.read_csv("config.csv")

        #all slow controls machines
        self.machines = {}
        self.machine_names = []

        #load the machines from the configuration
        for i in csv.iterrows():
            host = i[1]["host"].strip()

            if host not in self.machines:
                self.machines[host] = machine(i[1])
                self.machine_names.append(host)

            self.machines[host].add_ioc(i[1])

        #alphabetical order for machine and ioc names
        self.machine_names.sort()
        for i in self.machines.itervalues():
            i.sort_iocs()

        #html header
        self.hhead = ['<HTML><HEAD><link rel="stylesheet" type="text/css" href="stylesx.css">',
                      '<META HTTP-EQUIV="Refresh" Content="5" url="./"> </HEAD>',
                      '<title>Slow Controls IOC Monitor</title> ', '<BODY BGCOLOR=cornsilk>',
                      '  <br><table style="padding-top: 20px;">',
                      #'<caption style="font-size:160%;">Slow Controls IOC Monitor, development and testing (Jarda)</caption>'
                      '<caption style="font-size:160%;">Slow Controls IOC Monitor</caption>'
                      ]

        #html footer
        self.hfoot = ['  </table><br>',
                      'OK = IOC is present on the host. Alarm states (red): NOT_RUNNING, MULTIPLE_INSTANCES, DISCONNECTED, UNDEFINED',
                      '<br></BODY></HTML> '
        ]

        #table header
        self.tab_head = [
            '    <th class="h0">IOC</th>',
            '    <th class="h0">Status</th>',
            '    <th class="h1">Description</th>'
            ]
示例#7
0
 def verify(self, animate=False):
     valid = True
     for tin in self.tx_in:
         # clean machine for each input
         stack_machine = machine.machine()
         # always eval tin
         valid = valid and tin.script.interpret(stack_machine=stack_machine)
         # coinbase transactions do not refer to a previous output, but other transactions do
         if not tin.is_coinbase:
             prev_tran = transaction(tin.prev_hash, self.server)
             tout = prev_tran.tx_out[tin.index]
             valid = valid and tout.script.interpret(stack_machine=stack_machine,  #operate on dirty machine
                                                     transaction=self,
                                                     index=tin.index,
                                                     animate=animate)  
     return valid
示例#8
0
 def verify(self, animate=False):
     valid = True
     for tin in self.tx_in:
         # clean machine for each input
         stack_machine = machine.machine()
         # always eval tin
         valid = valid and tin.script.interpret(stack_machine=stack_machine)
         # coinbase transactions do not refer to a previous output, but other transactions do
         if not tin.is_coinbase:
             prev_tran = transaction(tin.prev_hash, self.server)
             tout = prev_tran.tx_out[tin.index]
             valid = valid and tout.script.interpret(
                 stack_machine=stack_machine,  #operate on dirty machine
                 transaction=self,
                 index=tin.index,
                 animate=animate)
     return valid
示例#9
0
    def __init__(self):

        #prefix for the PVs
        builder.SetDeviceName("iocmon")

        #open the configuration
        csv = pd.read_csv("config.csv")

        #all slow controls machines
        self.machines = {}

        #load machines and iocs from the configuration
        for i in csv.iterrows():
            host = i[1]["host"].strip()

            if host not in self.machines:
                sleep(0.3)
                self.machines[host] = machine(i[1])

            self.machines[host].add_ioc(i[1])
示例#10
0
    def __init__(self, generalIndividual):
        """
        self.machineList  由self.machineNum个machine对象构成的list
        self.allMachineWaitingList  待加工的工序构成的list,每个元素格式为[lot号,sublot号,sublotSize,工序号,可以开始加工的时间]
        self.idleMomentList  每台机器的idletime,从self.machineList同步而来,用来方便选择下一台需要安排工件的机器
        self.sublotOperationAssignment  每个sublot的每个工序都由哪个机器加工,起止时间是多少,每个元素格式为[机器号,起始时间,结束时间]
        """
        # 从generalIndividual同步而来的信息
        self.lotSplitingCode = [
            item.sublotSizes
            for item in generalIndividual.segment1.lotSplitingCode
        ]
        self.preferenceCode = generalIndividual.segment2.preferenceCode
        self.lotNum = generalIndividual.lotNum
        self.machineNum = generalIndividual.machineNum

        # 下面是主要变量
        self.machineList = [machine() for i in range(self.machineNum)]
        self.idleMomentList = [item.idleMoment for item in self.machineList]
        self.allMachineWaitingList = []
        self.sublotOperationAssignment = [[[] for sublot in lot]
                                          for lot in self.lotSplitingCode]
示例#11
0
            if re_machine_line.match(line):
                machine_details = line.split(None, 5)
                machine_dict = {}
                machine_dict["hostname"] = machine_details[0]
                machine_dict["distro"] = machine_details[1]
                machine_dict["distro_ver"] = machine_details[2]
                machine_dict["arch"] = machine_details[3]
                machine_dict["source"] = machine_details[4]
                machine_dict["components"] = map(str.lower, machine_details[5].strip("[]").split())
                ### ADD the machine to the array of machine
                cloud_machine = machine(
                    machine_dict["hostname"],
                    machine_dict["distro"],
                    machine_dict["distro_ver"],
                    machine_dict["arch"],
                    machine_dict["source"],
                    machine_dict["components"],
                    self.password,
                    self.keypath,
                    username,
                )
                machines.append(cloud_machine)

            ### LOOK for network mode in config file if not found then set it unknown
            try:
                if re.search("^network", line, re.IGNORECASE):
                    config_hash["network"] = line.split()[1].lower()
            except:
                self.debug("Could not find network type setting to unknown")
                config_hash["network"] = "unknown"
示例#12
0
文件: main.py 项目: aneeshdash/ALL
import re,assemble,link,loader,machine
files=[]
print 'Enter file names(in descending order of execution):'
while True:
	print 'File Name:',
	fname=raw_input()
	if fname is '':
		break;
	files.append(fname)
print 'Enter Offset:',
offset=int(raw_input())
main=files[-1].split('.')[0]+'.asm'
symbols=assemble.assemble(files)
link.linker(main, symbols)
loader.loader(main, offset)
machine.machine(main)
print 'Symbol Table:'
for key in symbols:
	print 'File: '+key
	print symbols[key]
示例#13
0
文件: main.py 项目: aneeshdash/ALL
import re, assemble, link, loader, machine
files = []
print 'Enter file names(in descending order of execution):'
while True:
    print 'File Name:',
    fname = raw_input()
    if fname is '':
        break
    files.append(fname)
print 'Enter Offset:',
offset = int(raw_input())
main = files[-1].split('.')[0] + '.asm'
symbols = assemble.assemble(files)
link.linker(main, symbols)
loader.loader(main, offset)
machine.machine(main)
print 'Symbol Table:'
for key in symbols:
    print 'File: ' + key
    print symbols[key]
示例#14
0
def tester():
    machine.machine()
    print("mpy execution works")
示例#15
0
文件: script.py 项目: marchon/bitrans
    def interpret(self,
                  stack_machine=None,
                  transaction=None,
                  index=None,
                  animate=False):
        if stack_machine is None:
            stack_machine = machine.machine(
            )  # create a clean machine if none provided
        if animate:
            stack_machine.draw()
        while not self.iterator.isempty():
            code = self.iterator.read(1).unsigned(endian="big")
            op = ops.code[code]
            print op

            #special cases
            if op.word == "OP_IF" or op.word == "OP_NOTIF":
                top_value = stack_machine.pop()
                if op.word == "OP_IF":
                    consequence = top_value.signed() != 0
                elif op.word == "OP_NOTIF":
                    consequence = top_value.signed() == 0
                if consequence:
                    stack_machine.pushifstate("eval-consequent")
                    continue
                else:
                    stack_machine.pushifstate("ignore-consequent")
                    stack_machine.lock()
                    continue
            elif op.word == "OP_ELSE":
                if not stack_machine.inif():
                    print "OP_ELSE called outside of if statement"
                    return False
                if stack_machine.inifstate("eval-consequent"):
                    stack_machine.changeifstate("ignore-alternative")
                    stack_machine.lock()
                elif stack_machine.inifstate("ignore-consequent"):
                    stack_machine.changeifstate("eval-alternative")
                    stack_machine.unlock()
            elif op.word == "OP_ENDIF":
                if not stack_machine.inif():
                    print "OP_ENDIF called outside of if statement"
                    return False
                if stack_machine.inifstate("ignore-alternative"):
                    stack_machine.unlock()
                stack_machine.popifstate()
            elif op.word == 'OP_CHECKSIG':  #checksig is a special case
                if transaction is None or index is None:
                    print "OP_CHECKSIG called but transaction or index missing; script invalid"
                    return False
                op(self.iterator, stack_machine, transaction, index, self)
            # usual case
            else:
                op(self.iterator, stack_machine)

            if self.nops is None:
                self.nops = 1
            else:
                self.nops += 1

            if animate:
                stack_machine.draw(op)

        # reset the iterator
        self.iterator.reset()
        if stack_machine.peek().unsigned() == 0:
            return False
        return True