class Elem (Thing):

	def __init__ (self):
		self.Attributes = Thing ()

	def add_attribute (self, attr):
		self.Attributes.set(attr.name, attr)

	def say (self, **args):
		template = '''\
<xacml-context:%(tag)s>
%(attributes)s
</xacml-context:%(tag)s>'''
		attr = ''
		for x in self.Attributes:
			attr += self.Attributes.get(x).say(quiet=True)
		
		t = Thing ()
		t.tag = args['tag']
		t.attributes = attr
		
		if not ('quiet' in args and args['quiet']):
			print(template%t)
			
		return template%t
	def say (self, **args):
		template = '''\
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
	xmlns:urn="urn:oasis:names:tc:xacml:2.0:context:schema:os">
	<soapenv:Header />
	<soapenv:Body>
		<xacml-context:Request
			xmlns:xacml-context="urn:oasis:names:tc:xacml:2.0:context:schema:os"
			xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
			xsi:schemaLocation="urn:oasis:names:tc:xacml:2.0:context:schema:os http://docs.oasis-open.org/xacml/access_control-xacml-2.0-context-schema-os.xsd">
			%(subject)s
			%(resource)s
			%(action)s
			%(environment)s
		</xacml-context:Request>
	</soapenv:Body>
</soapenv:Envelope>
'''
		t = Thing ()
		t.subject = self.subject.say(quiet=True)
		t.resource = self.resource.say(quiet=True)
		t.action = self.action.say(quiet=True)
		t.environment = self.environment.say(quiet=True)
		
		if not ('quiet' in args and args['quiet']):
			print(template%t)
			
		return template%t
	def say (self, **args):
		template = '''\
<xacml-context:%(tag)s>
%(attributes)s
</xacml-context:%(tag)s>'''
		attr = ''
		for x in self.Attributes:
			attr += self.Attributes.get(x).say(quiet=True)
		
		t = Thing ()
		t.tag = args['tag']
		t.attributes = attr
		
		if not ('quiet' in args and args['quiet']):
			print(template%t)
			
		return template%t
示例#4
0
def test(store):
    from Thing import Thing
    from Person import Person
    from MiscUtils.DataTable import DataTable

    dataSource = '''
b:int,i:int,l:long,f:float,s:string,d:int
0,0,0,0,0,0
0,0,0,0.0,0.0,0
1,1,1,1,a,0
0,-1,8589934592,-3.14,'x',0
'''

    data = DataTable()
    data.readString(dataSource)

    for values in data:
        print values

        t = Thing()
        for attr in list('bilfsd'):
            t.setValueForKey(attr, values[attr])

        store.addObject(t)
        store.saveChanges()

        # Try an immediate fetch
        results = store.fetchObjectsOfClass(Thing)
        assert len(results) == 1, 'len=%s, results=%s' % (len(results), results)
        # This tests the uniquing feature of MiddleKit:
        assert id(results[0]) == id(t)

        # Clear the store's in memory objects and try a fetch again
        store.clear()
        results = store.fetchObjectsOfClass(Thing)
        assert len(results) == 1
        assert results[0].allAttrs() == t.allAttrs()

        # Make sure what we got from the store is what we put in
        for attr in list('bils'):
            assert results[0].valueForKey(attr) == values[attr]

        different = 0.000001    # @@ 2000-11-25 ce: more work needed on floats
        assert abs(results[0].valueForKey('f')-values['f']) < different

        # Insert the fetched attributes
        t2 = Thing()
        for attr in list('bilfsd'):
            t2.setValueForKey(attr, results[0].valueForKey(attr))
        store.addObject(t2)
        store.saveChanges()
        results = store.fetchObjectsOfClass(Thing)
        assert len(results) == 2, 'len=%r' % len(results)
        assert results[0].allAttrs() == results[1].allAttrs()

        # Reset
        store.clear()
        store.executeSQLTransaction('delete from Thing;')
示例#5
0
 def createObjects(self):
     from Thing import Thing
     for i in range(self._numObjects):
         t = Thing()
         t.setB(1)
         t.setI(2)
         t.setL(3)
         t.setF(4.0)
         t.setS('five')
         self._store.addObject(t)
     self._store.saveChanges()
     things = self._store.fetchObjectsOfClass('Thing')
     assert len(things) == self._numObjects, \
         '%i, %i' % (len(things), self._numObjects)
# nekem megoldotta az import problémát az,
# hogy a .vscode/settings.json -ön belül
# "python.languageServer": "Jedi" -re változtattam a
# "python.languageServer": "Microsoft" helyett

from Fleet import Fleet
from Thing import Thing

fleet = Fleet()

get_milk = Thing("Get milk")
remove_obstacles = Thing("Remove the obstacles")
stand_up = Thing("Stand up")
stand_up.complete()
eat_lunch = Thing("Eat lunch")
eat_lunch.complete()

fleet.add(get_milk)
fleet.add(remove_obstacles)
fleet.add(stand_up)
fleet.add(eat_lunch)

# Töltsd fel a fleet példányt olyan módon, hogy a következő legyen a kimenet:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

print(fleet)
示例#7
0
 def createObjects(self):
     from Thing import Thing
     for i in range(self._numObjects):
         t = Thing()
         t.setB(1)
         t.setI(2)
         t.setL(3)
         t.setF(4.0)
         t.setS('five')
         self._store.addObject(t)
     self._store.saveChanges()
     things = self._store.fetchObjectsOfClass('Thing')
     assert len(things) == self._numObjects, \
         '%i, %i' % (len(things), self._numObjects)
示例#8
0
def init():
    global thing_objects_list
    thing_objects_list = Thing.create_things()
示例#9
0
文件: recog.py 项目: to-future/-
            cx = int(M['m10'] / M['m00'])
            cy = int(M['m01'] / M['m00'])
            x, y, w, h = cv2.boundingRect(cnt)

            new = True
            for i in things:
                # 从没有结束的对象里面找
                if i.getIsEnd() == False and abs(x - i.getX()) <= w and abs(
                        y - i.getY()) <= h:
                    # 如果新探测到的接近前一帧探测到的
                    new = False
                    i.updateCoords(cx, cy)  #更新那个接近的坐标顺便记录此元素这一次被改变了
                    break
            if new == True:
                # 如果确定有新的
                p = Thing(pid, cx, cy)
                things.append(p)
                pid += 1
            cv2.circle(frame, (cx, cy), 5, (0, 0, 225), -1)  #小红点
            img = cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 225, 0), 2)
            cv2.drawContours(frame, cnt, -1, (0, 255, 0), 3)

    # 检查之后的物品
    for i in things:
        if i.getIsEnd() == False:
            # 如果在尚存物品中发现本轮未改变的或者发现超出范围的物品 立即将其结束
            if i.getIsChanged() == False or i.getY() >= 850:
                i.setEnd()

    i = 0
    while i <= (len(things) - 1):
示例#10
0
from Thing import Thing, on_message
import time
import threading
thing = Thing('"12345"', '"12345"',
              "http://165.22.121.233:8888/api/authorization/",
              "165.22.121.233")
thing.on_message = on_message
thing.Start()
thr = threading.Thread(target=thing.OnConnected)
thr.start()
thing.Send("start ssss")
time.sleep(5)
thing.End()
示例#11
0
    'spa': 'No se pudo conectar con el servidor',
    'eng': 'Cannot connect to server'
}

"""This is where it begins"""

if not is_server_up():
    print(no_server_error_message[lang])
    quit()

auth = Authentication()

if not auth.is_auth:
    quit()

thing = Thing()

print('ip: ' + str(thing.ip))
print('macs: ' + str(thing.macs))

groups = auth.getAdminGroups()

pprint(groups)
allThings = []
for group in groups:
    res = requests.get(base_url+'/group', params={'id': group['id']})
    group = res.json()
    #pprint(group)
    for t in group['things']:
        allThings.append(t)
示例#12
0
from Fleet import Fleet
from Thing import Thing

fleet = Fleet()
# Create a fleet of things to have this output:
# 1. [ ] Get milk
# 2. [ ] Remove the obstacles
# 3. [x] Stand up
# 4. [x] Eat lunch

fleet.add(Thing("Get milk"))
fleet.add(Thing("Remove the obstacles"))

thing1 = Thing("Stand up")
thing1.complete()
thing2 = Thing("Eat lunch")
thing2.complete()

fleet.add(thing1)
fleet.add(thing2)

print(fleet)
示例#13
0
wildPokemon = Pokemon("Oddish", "leaf", "water")

for i in range(len(pokemon)):
    if (pokemon[i].isEffectiveAgainst(wildPokemon)):
        print(f"Ash should Choose {pokemon[i].get()}")

###### Fleet of Things

from Fleet import Fleet

from Thing import Thing

# Create a fleet of things to have this output:

# 1. [ ] Get milk
c = Thing("Get milk")
milk = c.__str__()
fleet = Fleet()
fleet.add(milk)

# 2. [ ] Remove the obstacles
c = Thing("Remove the obstacles")
remove = c.__str__()
fleet.add(remove)

# 3. [x] Stand up
c = Thing("Stand up")
true_complete = c.complete()
stand = c.__str__()
fleet.add(stand)
	def __init__ (self):
		self.Attributes = Thing ()
示例#15
0
 def __init__(self, image, symbol, pos=[0,0], blockSize = [50,50]):
     Thing.__init__(self, image, pos, blockSize)
     self.symbol = symbol