Ejemplo n.º 1
0
Archivo: rules.py Proyecto: msarch/py
 def __init__(self, *args, **kwargs):
     self._items=set()
     if args:
         self._items.update(args)
     else:
         self._items.add(dummy)
     for i in kwargs:
         setattr(self,i,kwargs[i])
     if not hasattr (self,'ruletype'):
         self.ruletype='persistent'
     # default ruletype
     if self.ruletype == 'persistent':
         _persistent.add(weakref.ref(self))
     # periodic rules, of course rule must have a 'period' attribute
     elif self.ruletype == 'periodic':
         _periodic.add(weakref.ref(self))  # is this necessary ?
         schedule_interval(self,self.period) # or schedule a oneshot rule ?
     # will run only once, then erased from list
     elif self.ruletype == 'oneshot':
         _oneshot.add(weakref.ref(self))
     # of course rule must have a 'condition' attribute
     elif self.ruletype == 'conditional':
         _conditional.add(weakref.ref(self))
     else:
         print ':: unrecognized type of rule'
     self.setup()
     print "::"
     print ":: new rule :::::::::::::::::::::::::::::::::::::::::::::::::::"
     print "::"
     dumpObj(self)
Ejemplo n.º 2
0
Archivo: rules.py Proyecto: msarch/py
 def __init__(self, *args, **kwargs):
     self._items = set()
     if args:
         self._items.update(args)
     else:
         self._items.add(dummy)
     for i in kwargs:
         setattr(self, i, kwargs[i])
     if not hasattr(self, 'ruletype'):
         self.ruletype = 'persistent'
     # default ruletype
     if self.ruletype == 'persistent':
         _persistent.add(weakref.ref(self))
     # periodic rules, of course rule must have a 'period' attribute
     elif self.ruletype == 'periodic':
         _periodic.add(weakref.ref(self))  # is this necessary ?
         schedule_interval(self,
                           self.period)  # or schedule a oneshot rule ?
     # will run only once, then erased from list
     elif self.ruletype == 'oneshot':
         _oneshot.add(weakref.ref(self))
     # of course rule must have a 'condition' attribute
     elif self.ruletype == 'conditional':
         _conditional.add(weakref.ref(self))
     else:
         print ':: unrecognized type of rule'
     self.setup()
     print "::"
     print ":: new rule :::::::::::::::::::::::::::::::::::::::::::::::::::"
     print "::"
     dumpObj(self)
Ejemplo n.º 3
0
Archivo: agent.py Proyecto: msarch/py
 def __init__(self, *args, **kwargs):
     self._id = chr((Agent.new_id() % 26) + 97)  # converts int to letters
     self._items = set()
     if args:
         self._items.update(args)
     else:
         self._items.add(dummy)
     for i in kwargs:
         setattr(self, i, kwargs[i])
     if not hasattr(self, 'agenttype'):
         self.agenttype = 'persistent'
     # default agenttype
     if self.agenttype == 'persistent':
         _persistent.add(self)
     # periodic agents, of course agent must have a 'period' attribute
     elif self.agenttype == 'periodic':
         _periodic.add(self)  # is this necessary ?
         schedule_interval(self.tick,
                           self.period)  # or schedule a oneshot agent ?
     # will run only once, then erased from list
     elif self.agenttype == 'oneshot':
         _oneshot.add(self)
     # of course agent must have a 'condition' attribute
     elif self.agenttype == 'conditional':
         _conditional.add(self)
     else:
         print ':: unrecognized type of agent'
     self.setup()
     print "::"
     print ":: new agent :::::::::::::::::::::::::::::::::::::::::::::::::::"
     print "::"
     dumpObj(self)
Ejemplo n.º 4
0
Archivo: agent.py Proyecto: msarch/py
 def __init__(self, *args, **kwargs):
     self._id = chr((Agent.new_id()%26)+97)  # converts int to letters
     self._items=set()
     if args:
         self._items.update(args)
     else:
         self._items.add(dummy)
     for i in kwargs:
         setattr(self,i,kwargs[i])
     if not hasattr (self,'agenttype'):
         self.agenttype='persistent'
     # default agenttype
     if self.agenttype == 'persistent':
         _persistent.add(self)
     # periodic agents, of course agent must have a 'period' attribute
     elif self.agenttype == 'periodic':
         _periodic.add(self)  # is this necessary ?
         schedule_interval(self.tick,self.period) # or schedule a oneshot agent ?
     # will run only once, then erased from list
     elif self.agenttype == 'oneshot':
         _oneshot.add(self)
     # of course agent must have a 'condition' attribute
     elif self.agenttype == 'conditional':
         _conditional.add(self)
     else:
         print ':: unrecognized type of agent'
     self.setup()
     print "::"
     print ":: new agent :::::::::::::::::::::::::::::::::::::::::::::::::::"
     print "::"
     dumpObj(self)
Ejemplo n.º 5
0
Archivo: action.py Proyecto: msarch/py
    def __init__(self, *args, **kwargs):
        self._id = chr((Action.new_id()%26)+97)  # converts int to letters
        for i in kwargs:
            setattr(self,i,kwargs[i])
        self._actions.append(self)
        self.setup()

        print "::"
        print ":: new agent :::::::::::::::::::::::::::::::::::::::::::::::::::"
        print "::"
        dumpObj(self)
Ejemplo n.º 6
0
Archivo: shapes.py Proyecto: msarch/py
 def __init__(self, **kwargs):
     for key in kwargs:
         setattr(self,key,kwargs[key])
     if not hasattr(self,'peg'):  # peg must be tuple (x, y, a)
         self.peg = DOCKED
     if not hasattr(self,'vel'):  # peg must be tuple (vx, vy, av)
         self.vel = IDLE
     self.build()
     self.flat_verts = None
     self.batch=None
     self._instances.add(weakref.ref(self))
     print "::"
     print ":: new shape ::::::::::::::::::::::::::::::::::::::::::::::::::"
     print "::"
     dumpObj(self)
Ejemplo n.º 7
0
Archivo: rules.py Proyecto: msarch/py
    def start(self, period=0):
        self.period = period
        if self.period == -1:
            _oneshot.add(weakref.ref(self))
        elif self.period == 0:
            _persistent.add(weakref.ref(self))
        else:  # period >0
            _periodic.add(weakref.ref(self))
            pyglet.clock.schedule_interval(self.schedule_interval, self.period)

        self.setup()
        print "::"
        print ":: new rule :::::::::::::::::::::::::::::::::::::::::::::::::::"
        print "::"
        dumpObj(self)
Ejemplo n.º 8
0
Archivo: shapes.py Proyecto: msarch/py
 def __init__(self, **kwargs):
     for key in kwargs:
         setattr(self, key, kwargs[key])
     if not hasattr(self, 'peg'):  # peg must be tuple (x, y, a)
         self.peg = DOCKED
     if not hasattr(self, 'vel'):  # peg must be tuple (vx, vy, av)
         self.vel = IDLE
     self.build()
     self.flat_verts = None
     self.batch = None
     self._instances.add(weakref.ref(self))
     print "::"
     print ":: new shape ::::::::::::::::::::::::::::::::::::::::::::::::::"
     print "::"
     dumpObj(self)
Ejemplo n.º 9
0
Archivo: rules.py Proyecto: msarch/py
    def start(self,period=0):
        self.period=period
        if self.period == -1:
            _oneshot.add(weakref.ref(self))
        elif self.period == 0:
            _persistent.add(weakref.ref(self))
        else:  # period >0
            _periodic.add(weakref.ref(self))
            pyglet.clock.schedule_interval(self.schedule_interval,self.period)

        self.setup()
        print "::"
        print ":: new rule :::::::::::::::::::::::::::::::::::::::::::::::::::"
        print "::"
        dumpObj(self)
Ejemplo n.º 10
0
Archivo: shapes.py Proyecto: msarch/py
    def __init__(self, *args, **kwargs):
        self.shapes = []
        self.batch = None
        if args:
            self.add_items(args)
        for i in kwargs:
            setattr(self,i,kwargs[i])
        if not hasattr(self,'peg'):  # peg must be tuple (x, y, a)
            self.peg = DOCKED
        if not hasattr(self,'vel'):  # peg must be tuple (vx, vy, av)
            self.vel = IDLE
        self._instances.add(weakref.ref(self))

        print "::"
        print ":: new C shape ::::::::::::::::::::::::::::::::::::::::::::::::"
        print "::"
        dumpObj(self)
Ejemplo n.º 11
0
Archivo: shapes.py Proyecto: msarch/py
    def __init__(self, *args, **kwargs):
        self.shapes = []
        self.get_batch
        if args:
            self.add_items(args)
        for i in kwargs:
            setattr(self,i,kwargs[i])
        if not hasattr(self,'peg'):  # peg must be tuple (x, y, a)
            self.peg = DOCKED
        if not hasattr(self,'vel'):  # peg must be tuple (vx, vy, av)
            self.vel = IDLE
        self._instances.add(weakref.ref(self))

        print "::"
        print ":: new C shape ::::::::::::::::::::::::::::::::::::::::::::::::"
        print "::"
        dumpObj(self)
Ejemplo n.º 12
0
Archivo: shape.py Proyecto: msarch/py
    def __init__(self, **kwargs):
        for key in kwargs:
            setattr(self,key,kwargs[key])
        self.verts=[]
        self.shapes=[]
        self.build()
        if not hasattr(self,'color'):
            self.color = red
        if not hasattr(self,'peg'):  # peg must be tuple (x, y, a)
            self.peg = DOCKED
        if not hasattr(self,'vel'):  # peg must be tuple (vx, vy, av)
            self.vel = IDLE
        if not hasattr (self,'pivot'):
            self.pivot=(0,0)  #  or pivot at AABB center ??                   # TODO

        self.aabb=self.get_aabb()
        self.flat_verts = None
        self.batch=None
        print "::"
        print ":: new shape ::::::::::::::::::::::::::::::::::::::::::::::::::"
        print "::"
        dumpObj(self)
Ejemplo n.º 13
0
    def __init__(self, **kwargs):
        for key in kwargs:
            setattr(self, key, kwargs[key])
        self.verts = []
        self.shapes = []
        self.build()
        if not hasattr(self, 'color'):
            self.color = red
        if not hasattr(self, 'peg'):  # peg must be tuple (x, y, a)
            self.peg = DOCKED
        if not hasattr(self, 'vel'):  # peg must be tuple (vx, vy, av)
            self.vel = IDLE
        if not hasattr(self, 'pivot'):
            self.pivot = (
                0, 0)  #  or pivot at AABB center ??                   # TODO

        self.aabb = self.get_aabb()
        self.flat_verts = None
        self.batch = None
        print "::"
        print ":: new shape ::::::::::::::::::::::::::::::::::::::::::::::::::"
        print "::"
        dumpObj(self)
Ejemplo n.º 14
0
    image_name = "my_image_2"
    with open(image_file, 'rb') as fimage:
        image = glance.images.create(name=image_name, 
                                     #is_public="False", 
                                     disk_format="qcow2",
                                     container_format="bare",
                                    )
        glance.images.upload(image.id, fimage)
        return image


keystone = ksclient.Client(auth_url = settings.OPENSTACK_KEYSTONE_URL,
                           username = settings.OPENSTACK_USER,
                           password = settings.OPENSTACK_PASSWORD,
                           tenant_name = settings.OPENSTACK_TENANT_NAME,
                           )
glance_endpoint = keystone.service_catalog.url_for(service_type='image')
glance = glclient.Client(glance_endpoint, token=keystone.auth_token)

#images = list_image(glance)
#dump.dumpObjList(images)

#image_id = "91585914-e76a-463e-9502-3e8b5275ff63"
#image = show_image(glance, image_id)
#dump.dumpObj(image)

image_file = "/home/openstack/cirros-0.3.2-x86_64-disk.img"
image = upload_image(glance, image_file)
dump.dumpObj(image)