Example #1
0
def get_current_connections():
    """
    Returns a list of `UncDirectoryConnection` or `UncDirectoryMount` objects. Each object
    represents a connection or mount currently recognized by the system.
    """
    net_use = get_current_net_use_table()
    return [_get_connection_or_mount(row['remote'], row['local']) for row in net_use.rows]
Example #2
0
def get_connection_for_disk_drive(disk_drive):
    """
    Returns a `UncDirectoryMount` representing a mounted UNC directory that matches a disk drive
    (`disk_drive`) or `None` if no system mounts match `disk_drive`.
    `disk_drive` is a `DiskDrive`.
    """
    net_use = get_current_net_use_table()
    matching = net_use.get_matching_rows(local=disk_drive)
    return UncDirectoryMount(matching[0]['remote'], matching[0]['local']) if matching else None
def get_current_connections():
    """
    Returns a list of `UncDirectoryConnection` or `UncDirectoryMount` objects. Each object
    represents a connection or mount currently recognized by the system.
    """
    net_use = get_current_net_use_table()
    return [
        _get_connection_or_mount(row['remote'], row['local'])
        for row in net_use.rows
    ]
def get_connection_for_disk_drive(disk_drive):
    """
    Returns a `UncDirectoryMount` representing a mounted UNC directory that matches a disk drive
    (`disk_drive`) or `None` if no system mounts match `disk_drive`.
    `disk_drive` is a `DiskDrive`.
    """
    net_use = get_current_net_use_table()
    matching = net_use.get_matching_rows(local=disk_drive)
    return UncDirectoryMount(matching[0]['remote'],
                             matching[0]['local']) if matching else None
Example #5
0
def get_connection_for_unc_directory(unc):
    """
    Returns a `UncDirectoryConnection` or `UncDirectoryMount` representing a connected or mounted
    UNC directory that matches a given UNC directory (`unc`) or `None` if no system connections or
    mounts match `unc`.
    `unc` is a `UncDirectory`.
    """
    net_use = get_current_net_use_table()
    matching = net_use.get_matching_rows(remote=unc)
    return _get_connection_or_mount(matching[0]['remote'], matching[0]['local']) if matching else None
def get_connection_for_unc_directory(unc):
    """
    Returns a `UncDirectoryConnection` or `UncDirectoryMount` representing a connected or mounted
    UNC directory that matches a given UNC directory (`unc`) or `None` if no system connections or
    mounts match `unc`.
    `unc` is a `UncDirectory`.
    """
    net_use = get_current_net_use_table()
    matching = net_use.get_matching_rows(remote=unc)
    return _get_connection_or_mount(matching[0]['remote'],
                                    matching[0]['local']) if matching else None
Example #7
0
 def get_connection_status(self):
     """
     Returns one of the following based on this `UncDirectoryConnection`'s status according to
     the system:
         `'ok'`           - connected
         `'disconnected'` - recognized but inactive
         `'unavailable'`  - a previous connection attempt failed
         `None`           - not connected
     """
     net_use = get_current_net_use_table()
     matching = net_use.get_matching_rows(local=self.disk_drive, remote=self.unc.get_path())
     return matching[0]['status'] if matching else None
Example #8
0
 def get_connection_status(self):
     """
     Returns one of the following based on this `UncDirectoryConnection`'s status according to
     the system:
         `'ok'`           - connected
         `'disconnected'` - recognized but inactive
         `'unavailable'`  - a previous connection attempt failed
         `None`           - not connected
     """
     net_use = get_current_net_use_table()
     matching = net_use.get_matching_rows(local=self.disk_drive,
                                          remote=self.unc)
     return matching[0]['status'] if matching else None
 def localhost_is_connected(self):
     net_use = get_current_net_use_table()
     return UncDirectory(self.LOCALHOST_UNC) in net_use.get_connected_paths()