GRAYBYTE WORDPRESS FILE MANAGER3734

Server IP : 149.255.58.128 / Your IP : 216.73.216.158
System : Linux cloud516.thundercloud.uk 5.14.0-427.26.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jul 17 15:51:13 EDT 2024 x86_64
PHP Version : 8.2.28
Disable Function : allow_url_include, apache_child_terminate, apache_setenv, exec, passthru, pcntl_exec, posix_kill, posix_mkfifo, posix_getpwuid, posix_setpgid, posix_setsid, posix_setuid, posix_setgid, posix_seteuid, posix_setegid, posix_uname, proc_close, proc_get_status, proc_open, proc_terminate, shell_exec, show_source, system
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /usr/lib/python3.9/site-packages/up2date_client/
Upload Files :
Current_dir [ Not Writeable ] Document_root [ Writeable ]

Command :


Current File : /usr/lib/python3.9/site-packages/up2date_client//haltree.py
# HalTree Purpose:
#
# HalTree is a way to organize the mess of data you get from hal.  In general,
# if you want to get all the information about every device in the system, you
# end up with a list of dicts, where each dict contains the property name/values
# for a device.  This list isn't very useful as the hal data is actually
# organized into a tree.  For example, you have the computer as the head, then
# there may be a scsi card plugged in.  That in turn will have scsi channels
# and luns, which scsi devices may be connected to.  So this module will help
# you reorganize your hal data back to the way they were intended.
#
# HalTree Usage:
#
# The tree gets built one device at a time.  Once you've created a HalTree
# object, devices get added to the tree with HalTree.add(hw_dev_dict).  The
# devices can be added in any particular order, and the tree gets properly
# structured as the devices get added.  But the tree structure isn't likely
# to be ready until all the devices have been added.  Those devices without a
# parent get stuck in the no_parent_yet list.
#
# When a device gets added, it is no longer a plain dict.  It is stored in a
# HalDevice.  The original dict can be found in HalDevice.properties.

try: # python2
    from types import StringType, IntType
except ImportError: # python3
    StringType = bytes
    IntType = int


class HalDevice:
    "An object containing its udi, properties and children"
    def __init__ (self, properties):
        self.udi = properties['info.udi']

        self.properties = properties
        self.children = []
        self.classification = None

        if 'info.parent' in properties:
            self.parent_udi = properties['info.parent']
        else:
            self.parent_udi = None

        self.parent = None

    def print_properties(self):
        print(self.udi, ":")
        for property, value in self.properties.items():
            print("    ", property," ==> ",  value)




class HalTree:
    def __init__ (self):
        self.head = None
        self.no_parent_yet = []


    def add(self, hal_device):
        if hal_device.parent_udi:
            parent = self.__find_node(hal_device.parent_udi)
            if parent:
                parent.children.append(hal_device)
                hal_device.parent = parent
            else:  #parent isn't in the main tree yet, stick it in waiting
                self.no_parent_yet.append(hal_device)
        else: #if it doesn't have a parent, it must be the head 'computer'
            self.head = hal_device

        #check to see if there are any children waiting for this dev
        self.__get_lost_children(hal_device)


    def __get_lost_children(self, hal_device):
        found_list = []
        indexes = []
        no_parent_yet_copy = self.no_parent_yet[:]
        for dev in no_parent_yet_copy:
            if dev.parent_udi == hal_device.udi:
                dev.parent = hal_device
                hal_device.children.append(dev)
                self.no_parent_yet.remove(dev)

    def __find_node(self, udi):
        """
        This takes a node in the HalDevice tree and returns the HalDevice with
        the given udi.
        """
        if self.head:
            node = HalTree.__find_node_worker(self.head, udi)
            if node:
                return node

        for node in self.no_parent_yet:
            found_node = HalTree.__find_node_worker(node, udi)
            if found_node:
                return found_node
        return None

    @staticmethod
    def __find_node_worker(node, udi):
        if node.udi == udi:
            return node
        for device in node.children:
            res = HalTree.__find_node_worker(device, udi)
            if res:
                return res
        return None

    def print_tree(self):
        self.__print_dev_tree(self.head, "")

    def __print_dev_tree(self, node, indent):
        print(indent, node.udi)
        print(indent, "CLASS:", node.classification)
        for name, property in node.properties.items():
            if (type(property) == StringType):
                if property.isdigit():
                    print(indent + "    ", "%-20s ==> %s" % (name, hex(int(property))))
                else:
                    print(indent + "    ", "%-20s ==> %s" % (name, property))
            elif (type(property) == IntType):
                print(indent + "    ", "%-20s ==> %s" % (name, hex(int(property))))
            else:
                print(indent + "    ", "%-20s ==> %s" % (name, property))
        print
        for child in node.children:
            self.__print_dev_tree(child, indent + "    ")

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
March 19 2025 22:42:16
0 / root
0755
__pycache__
--
March 18 2025 22:42:18
0 / root
0755
__init__.py
0 KB
February 26 2025 11:13:36
0 / root
0644
capabilities.py
7.277 KB
February 26 2025 11:13:36
0 / root
0644
clientCaps.py
2.156 KB
February 26 2025 11:13:36
0 / root
0644
clpwd.py
3.558 KB
February 26 2025 11:13:36
0 / root
0644
config.py
12.505 KB
February 26 2025 11:13:36
0 / root
0644
debUtils.py
2.764 KB
February 26 2025 11:13:36
0 / root
0644
getMethod.py
4.201 KB
February 26 2025 11:13:36
0 / root
0644
haltree.py
4.533 KB
February 26 2025 11:13:36
0 / root
0644
hardware.py
31.91 KB
February 26 2025 11:13:36
0 / root
0644
hardware_gudev.py
12.906 KB
February 26 2025 11:13:36
0 / root
0644
hardware_hal.py
11.332 KB
February 26 2025 11:13:36
0 / root
0644
hardware_udev.py
12.988 KB
February 26 2025 11:13:36
0 / root
0644
pkgUtils.py
0.288 KB
February 26 2025 11:13:36
0 / root
0644
pkgplatform.py
0.302 KB
February 26 2025 11:56:05
0 / root
0644
pmPlugin.py
2.792 KB
February 26 2025 11:13:36
0 / root
0644
rhnChannel.py
4.913 KB
February 26 2025 11:13:36
0 / root
0644
rhnHardware.py
0.32 KB
February 26 2025 11:13:36
0 / root
0644
rhnPackageInfo.py
2.34 KB
February 26 2025 11:13:36
0 / root
0644
rhncli.py
9.116 KB
February 26 2025 11:13:36
0 / root
0644
rhnreg.py
31.219 KB
February 26 2025 11:13:36
0 / root
0644
rhnreg_constants.py
18.134 KB
February 26 2025 11:13:36
0 / root
0644
rhnserver.py
8.655 KB
February 26 2025 11:13:36
0 / root
0644
rpcServer.py
10.959 KB
February 26 2025 11:13:36
0 / root
0644
rpmUtils.py
5.196 KB
February 26 2025 11:13:36
0 / root
0644
transaction.py
4.095 KB
February 26 2025 11:13:36
0 / root
0644
tui.py
43.702 KB
February 26 2025 11:13:36
0 / root
0644
up2dateAuth.py
9.472 KB
February 26 2025 11:13:36
0 / root
0644
up2dateErrors.py
10.256 KB
February 26 2025 11:13:36
0 / root
0644
up2dateLog.py
2.059 KB
February 26 2025 11:13:36
0 / root
0644
up2dateUtils.py
5.033 KB
February 26 2025 11:56:05
0 / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF