Exemplo n.º 1
0
 def run(self):
     import json
     self.view_tree.fetch(max_depth = -1)
     data = []
     for depth, node in self.view_tree.traverse(include_depth = True):
         data.append(node.dictDescribe())
     cprint(json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')))
     return 0
Exemplo n.º 2
0
 def run(self):
     import json
     self.view_tree.fetch(max_depth=-1)
     data = []
     for depth, node in self.view_tree.traverse(include_depth=True):
         data.append(node.dictDescribe())
     cprint(
         json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')))
     return 0
Exemplo n.º 3
0
 def _displayAttributes(self, device, show_hidden):
     if len(device.attributes) > 0:
         for attr in device.attributes:
             if not show_hidden and attr.attributes.get('hidden', False) is True:
                 continue
             if attr.atype == 'text' and len(attr.value.strip()) == 0:
                 continue
             cprint('%-20s %s' % (attr.name.lower() + ':', attr.value))
         print
Exemplo n.º 4
0
def main(argv):
    """Main siptracklib commandline client entry point.
    
    This is basically just an exception wrapper for run_siptrack.
    """
    try:
        return run_siptrack(argv[1:])
    except SiptrackCommandError, e:
        cprint('ERROR: %s' % (e))
        return 1
Exemplo n.º 5
0
    def run(self, display_attributes=False):
        self.view_tree.fetch(max_depth=-1)
        exclude = ['attribute']
        if display_attributes:
            exclude = []
        for depth, node in self.view_tree.traverse(exclude=exclude,
                                                   include_depth=True):
            cprint('%s%s' % (depth * '    ', node.describe()))

        return 0
Exemplo n.º 6
0
 def _displayNetworks(self, device):
     networks = [
         str(network)
         for network in device.listNetworks(include_ranges=False,
                                            include_interfaces=True)
     ]
     if len(networks) > 0:
         cprint('IP-addresses:')
         cprint('  %s' % (' '.join(networks)))
         print
Exemplo n.º 7
0
    def run(self, display_attributes = False):
        self.view_tree.fetch(max_depth = -1)
        exclude = ['attribute']
        if display_attributes:
            exclude = []
        for depth, node in self.view_tree.traverse(exclude = exclude,
                include_depth = True):
            cprint('%s%s' % (depth * '    ', node.describe()))

        return 0
Exemplo n.º 8
0
 def _displayAttributes(self, device, show_hidden):
     if len(device.attributes) > 0:
         for attr in device.attributes:
             if not show_hidden and attr.attributes.get('hidden',
                                                        False) is True:
                 continue
             if attr.atype == 'text' and len(attr.value.strip()) == 0:
                 continue
             cprint('%-20s %s' % (attr.name.lower() + ':', attr.value))
         print
Exemplo n.º 9
0
def main(argv):
    """Main siptracklib commandline client entry point.
    
    This is basically just an exception wrapper for run_siptrack.
    """
    try:
        return run_siptrack(argv[1:])
    except SiptrackCommandError, e:
        cprint("ERROR: %s" % (e))
        return 1
Exemplo n.º 10
0
    def _displayAssociatedDevices(self, device):
        assoc_devices = device.listAssociations(include = ['device'])
        assoc_devices += device.listReferences(include = ['device'])
        if len(assoc_devices) > 0:
            cprint('Associated devices:')
            for node in assoc_devices:
                node_path = []
                cur = node
                while cur.class_name == 'device':
                    node_path.insert(0, cur)
                    cur = cur.parent
                names = [n.attributes.get('name', 'UNKNOWN') for n in node_path]
                cprint('  %15s: %s' % (node.attributes.get('class', ' - '),
                    ' / '.join(names)))

            print()
Exemplo n.º 11
0
    def _displayAssociatedDevices(self, device):
        assoc_devices = device.listAssociations(include=['device'])
        assoc_devices += device.listReferences(include=['device'])
        if len(assoc_devices) > 0:
            cprint('Associated devices:')
            for node in assoc_devices:
                node_path = []
                cur = node
                while cur.class_name == 'device':
                    node_path.insert(0, cur)
                    cur = cur.parent
                names = [
                    n.attributes.get('name', 'UNKNOWN') for n in node_path
                ]
                cprint(
                    '  %15s: %s' %
                    (node.attributes.get('class', ' - '), ' / '.join(names)))

            print()
Exemplo n.º 12
0
def show_version():
    """Print program version information."""
    cprint('siptrack %s' % (siptracklib.__version__))
    cprint('Written by Simon Ekstrand.')
    cprint('')
    cprint(siptracklib.__copyright__)
Exemplo n.º 13
0
 def _displayDisabled(self, device):
     if device.attributes.get('disabled', False) is True:
         cprint('THIS DEVICE IS CURRENTLY DISABLED')
Exemplo n.º 14
0
    def run(self, oid):
        node = self.object_store.getOID(oid)

        cprint(node.class_name)

        return 0
Exemplo n.º 15
0
    def run(self):
        cprint('Server said: %s' % (self.transport.cmd.ping()))

        return 0
Exemplo n.º 16
0
    cm.config.update(optdict)

    if len(argv) == 0:
        from siptracklib.help import show_global_help
        show_global_help()
        return 1

    return run_command(cm, argv[0], argv[1:])


def main(argv):
    """Main siptracklib commandline client entry point.
    
    This is basically just an exception wrapper for run_siptrack.
    """
    try:
        return run_siptrack(argv[1:])
    except SiptrackCommandError, e:
        cprint('ERROR: %s' % (e))
        return 1
    except SiptrackError, e:
        cprint('ERROR: %s' % (e))
        return 1
    except KeyboardInterrupt:
        cprint('ERROR: command interrupted by user')
#    except Exception, e:
#        cprint('ERROR: %s' % (e))
#        return 1

    return 0
Exemplo n.º 17
0
 def _displayDisabled(self, device):
     if device.attributes.get('disabled', False) is True:
         cprint('THIS DEVICE IS CURRENTLY DISABLED')
Exemplo n.º 18
0
 def _displayNetworks(self, device):
     networks = [str(network) for network in device.listNetworks(include_ranges=False, include_interfaces=True)]
     if len(networks) > 0:
         cprint('IP-addresses:')
         cprint('  %s' % (' '.join(networks)))
         print
Exemplo n.º 19
0
def show_version():
    """Print program version information."""
    cprint('siptrack %s' % (siptracklib.__version__))
    cprint('Written by Simon Ekstrand.')
    cprint('')
    cprint(siptracklib.__copyright__)
Exemplo n.º 20
0
    def run(self):
        cprint('Server said: %s' % (self.transport.cmd.ping()))

        return 0
Exemplo n.º 21
0
    def run(self, oid):
        node = self.object_store.getOID(oid)

        cprint(node.class_name)

        return 0
Exemplo n.º 22
0
    if len(argv) == 0:
        from siptracklib.help import show_global_help

        show_global_help()
        return 1

    return run_command(cm, argv[0], argv[1:])


def main(argv):
    """Main siptracklib commandline client entry point.
    
    This is basically just an exception wrapper for run_siptrack.
    """
    try:
        return run_siptrack(argv[1:])
    except SiptrackCommandError, e:
        cprint("ERROR: %s" % (e))
        return 1
    except SiptrackError, e:
        cprint("ERROR: %s" % (e))
        return 1
    except KeyboardInterrupt:
        cprint("ERROR: command interrupted by user")
    #    except Exception, e:
    #        cprint('ERROR: %s' % (e))
    #        return 1

    return 0