Ejemplo n.º 1
0
    def get_devices(path=None, *args, **kwargs):
        devices = []
        for (k, v) in pytomation_system.get_instances_detail().iteritems():
            try:
                v.update({'id': k})
                a = v['instance']
                b = a.state
                del v['instance']
#                devices.append({k: v})
                devices.append(v)
            except Exception, ex:
                pass
Ejemplo n.º 2
0
 def get_devices(path=None, *args, **kwargs):
     devices = []
     for (k, v) in pytomation_system.get_instances_detail().iteritems():
         try:
             v.update({'id': k})
             a = v['instance']
             b = a.state
             del v['instance']
             #                devices.append({k: v})
             devices.append(v)
         except Exception, ex:
             pass
Ejemplo n.º 3
0
    def update_device(self, levels, data=None, source=None, *args, **kwargs):
        """
        Issues command in POST from JSON format.
        """
        command = None
        response = None
        if not source:
            source = self

        if data:
            if isinstance(data, list):
                for d in data:
                    #                    print 'ff' + str(d)
                    e = d.split('=')
                    #                    print 'eee' + str(e)
                    if e[0] == 'command':
                        command = e[1]
            else:
                e = data.split('=')
                command = e[1]
#        print 'Set Device' + str(command) + ":::" + str(levels)
        id = levels[1]
        # look for tuples in the command and make it a tuple
        if ',' in command:
            e = command.split(',')
            l = []
            # lets convert any strings to int's if we can
            for i in e:
                t = i
                try:
                    t = int(i)
                except:
                    pass
                l.append(t)
            command = tuple(l)
        try:
            detail = pytomation_system.get_instances_detail()[id]
            device = detail['instance']
            device.command(command=command, source=source)
            response = PytomationAPI.get_device(levels)
        except Exception, ex:
            pass
Ejemplo n.º 4
0
    def update_device(self, levels, data=None, source=None, *args, **kwargs):
        """
        Issues command in POST from JSON format.
        """
        command = None
        response = None
        if not source:
            source = self

        if data:
            if isinstance(data, list):
                for d in data:
#                    print 'ff' + str(d)
                    e = d.split('=')
#                    print 'eee' + str(e)
                    if e[0] == 'command':
                        command = e[1]
            else:
                e = data.split('=')
                command = e[1]
#        print 'Set Device' + str(command) + ":::" + str(levels)
        id = levels[1]
        # look for tuples in the command and make it a tuple
        if ',' in command:
            e = command.split(',')
            l = []
            # lets convert any strings to int's if we can
            for i in e:
                t = i
                try:
                    t = int(i)
                except:
                    pass
                l.append(t)
            command = tuple(l)
        try:
            detail = pytomation_system.get_instances_detail()[id]
            device = detail['instance']
            device.command(command=command, source=source)
            response = PytomationAPI.get_device(levels)
        except Exception, ex:
            pass
    def update_device(self, levels, data=None, *args, **kwargs):
        command = None
        if data:
            if isinstance(data, list):
                for d in data:
#                    print 'ff' + str(d)
                    e = d.split('=')
#                    print 'eee' + str(e)
                    if e[0]== 'command':
                        command = e[1]
            else:
                e = data.split('=')
                command = e[1]
#        print 'Set Device' + str(command) + ":::" + str(levels)
        id = levels[1]
        detail = pytomation_system.get_instances_detail()[id]
        device = detail['instance']
        device.command(command=command, source=self)
        response =  PytomationAPI.get_device(levels)
#        print 'res['+ str(response)
        return response
 def get_device(levels, *args, **kwargs):
     id = levels[1]
     detail = pytomation_system.get_instances_detail()[id]
     detail.update({'id': id})
     del detail['instance']
     return detail
Ejemplo n.º 7
0
 def get_device(levels, *args, **kwargs):
     id = levels[1]
     detail = pytomation_system.get_instances_detail()[id]
     detail.update({'id': id})
     del detail['instance']
     return detail