testing



In [1]:
import IoT_sources
import IoT_universe
reload(IoT_sources)
reload(IoT_universe)


Out[1]:
<module 'IoT_universe' from 'IoT_universe.pyc'>

In [2]:
s = IoT_sources.InfluxSource()
s1 = IoT_sources.InfluxSource()
sr = IoT_sources.MQTTSource()


Connecting

In [3]:
u = IoT_universe.Universe()


Class MQTTSource, instance: Nameless 0: Connected!

In [4]:
c = IoT_sources.Collection()
c1 = IoT_sources.Collection()

In [5]:
c.add(s)
c.add(s1)

In [6]:
l = c.to_dict()

In [7]:
l


Out[7]:
[{'Name': 'Nameless 0',
  'UUID': '37d4cd8c-884c-11e4-8869-6c400892f89e',
  'class': 'InfluxSource',
  'url': 'influx://root:root@localhost:8086/test'},
 {'Name': 'Nameless 1',
  'UUID': '37d59fca-884c-11e4-b74f-6c400892f89e',
  'class': 'InfluxSource',
  'url': 'influx://root:root@localhost:8086/test'}]

In [8]:
c1.objects


Out[8]:
{}

In [9]:
c1.from_dict(l)

In [10]:
c1.classes.append("InfluxSource")

In [11]:
c1


Out[11]:
<IoT_sources.Collection instance at 0x10dcd5a70>

In [12]:
s


Out[12]:
<Class: InfluxSource | Name: Nameless 0 | UUID: 37d4cd8c-884c-11e4-8869-6c400892f89e>

In [209]:
u


Out[209]:
<Class: Universe | Name: Nameless 0 | UUID: 9d40a651-7c03-11e4-9286-6c400892f89e>

In [210]:
s


Out[210]:
<Class: InfluxSource | Name: Nameless 0 | UUID: 9cdb9e9c-7c03-11e4-8265-6c400892f89e>

In [212]:
s


Out[212]:
<Class: InfluxSource | Name: Nameless 0 | UUID: 9cdb9e9c-7c03-11e4-8265-6c400892f89e>

In [214]:
locals()["s"]["test"] = 0


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-214-31cbf34ea114> in <module>()
----> 1 locals()["s"]["test"] = 0

TypeError: 'InfluxSource' object does not support item assignment

In [218]:
vars(s)["test"]  =0

In [221]:
st = "  kk nk"

In [222]:
st.replace(" ", "_")


Out[222]:
'__kk_nk'

In [228]:
c.Nameless_0


Out[228]:
<Class: InfluxSource | Name: Nameless 0 | UUID: 101b1cc7-7c06-11e4-a5b3-6c400892f89e>

In [229]:
c.objects.popitem()


Out[229]:
('101b1cc7-7c06-11e4-a5b3-6c400892f89e',
 <Class: InfluxSource | Name: Nameless 0 | UUID: 101b1cc7-7c06-11e4-a5b3-6c400892f89e>)

In [230]:
c.objects


Out[230]:
{'101b21d1-7c06-11e4-9e59-6c400892f89e': <Class: InfluxSource | Name: Nameless 1 | UUID: 101b21d1-7c06-11e4-9e59-6c400892f89e>}

In [231]:
c.Nameless_1


Out[231]:
<Class: InfluxSource | Name: Nameless 1 | UUID: 101b21d1-7c06-11e4-9e59-6c400892f89e>

In [237]:
C


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-237-b39bfc0e26a3> in <module>()
----> 1 C

NameError: name 'C' is not defined

In [238]:
c


Out[238]:
<IoT_sources.Collection instance at 0x10730c4d0>

In [257]:
c.objects.keys()[0]


Out[257]:
'3d2a0570-7c07-11e4-b16c-6c400892f89e'

In [258]:
c.remove_by_UUID(c.objects.keys()[0])

In [262]:
c.objects


Out[262]:
{'3d29ff6b-7c07-11e4-ba36-6c400892f89e': <Class: InfluxSource | Name: Nameless 0 | UUID: 3d29ff6b-7c07-11e4-ba36-6c400892f89e>,
 '3d2a0570-7c07-11e4-b16c-6c400892f89e': <Class: InfluxSource | Name: Nameless 1 | UUID: 3d2a0570-7c07-11e4-b16c-6c400892f89e>}

In [260]:
c.Nameless_0


Out[260]:
<Class: InfluxSource | Name: Nameless 0 | UUID: 3d29ff6b-7c07-11e4-ba36-6c400892f89e>

In [263]:
c.Nameless_1


Out[263]:
<Class: InfluxSource | Name: Nameless 1 | UUID: 3d2a0570-7c07-11e4-b16c-6c400892f89e>

In [272]:
u.to_dict()


Out[272]:
{'Drivers': [],
 'Feeds': [],
 'Name': 'Nameless 0',
 'Sources': [],
 'UUID': 'e9f2f461-7c66-11e4-a37d-6c400892f89e'}

In [275]:
u.Sources.objects


Out[275]:
{}

In [275]:


In [276]:
s


Out[276]:
<Class: InfluxSource | Name: Nameless 0 | UUID: e99ae2b5-7c66-11e4-b21e-6c400892f89e>

In [277]:
u


Out[277]:
<Class: Universe | Name: Nameless 0 | UUID: e9f2f461-7c66-11e4-a37d-6c400892f89e>

In [279]:
u.Sources.add(s)
u.Sources.add(s1)

In [280]:
u.to_dict()


Out[280]:
{'Drivers': [],
 'Feeds': [],
 'Name': 'Nameless 0',
 'Sources': [{'Name': 'Nameless 0',
   'UUID': 'e99ae2b5-7c66-11e4-b21e-6c400892f89e',
   'class': 'InfluxSource',
   'url': 'influx://root:root@localhost:8086/test'},
  {'Name': 'Nameless 1',
   'UUID': 'e99ae854-7c66-11e4-be87-6c400892f89e',
   'class': 'InfluxSource',
   'url': 'influx://root:root@localhost:8086/test'}],
 'UUID': 'e9f2f461-7c66-11e4-a37d-6c400892f89e'}

In [13]:
l


Out[13]:
[{'Name': 'Nameless 0',
  'UUID': '37d4cd8c-884c-11e4-8869-6c400892f89e',
  'class': 'InfluxSource',
  'url': 'influx://root:root@localhost:8086/test'},
 {'Name': 'Nameless 1',
  'UUID': '37d59fca-884c-11e4-b74f-6c400892f89e',
  'class': 'InfluxSource',
  'url': 'influx://root:root@localhost:8086/test'}]

In [286]:
li=[1,23,4,5,6]

In [288]:
li.remove(23)

In [289]:
class test:
    def test(self,i):
        print i

In [290]:
t  = test()

In [291]:
fn = t.test

In [292]:
fn(4)


4