コード例 #1
0
def get_current_net_use_table():
    """
    Returns a `NetUseTable` that describes the current Windows session's status regarding
    all UNC paths.
    """
    stdout, _ = run('NET USE')
    return parse_net_use_table(stdout)
コード例 #2
0
    def test_valid_table(self):
        table = parse_net_use_table(VALID_TABLE)

        mounted_paths = [UncDirectory(r'\\a'),
                         UncDirectory(r'\\localhost'),
                         UncDirectory(r'\\localhost\IPC$'),
                         UncDirectory(r'\\localhost\has    spaces'),
                         UncDirectory(r'\\some.remote.path\with-a-long-path')]
        self.assertEqualAsSets(table.get_connected_paths(), mounted_paths)

        mounted_drives = [DiskDrive('A:'),
                          DiskDrive('B:'),
                          DiskDrive('C:'),
                          DiskDrive('D:')]
        self.assertEqualAsSets(table.get_connected_devices(), mounted_drives)
コード例 #3
0
    def test_valid_table(self):
        table = parse_net_use_table(VALID_TABLE)

        mounted_paths = [
            UncDirectory(r'\\a'),
            UncDirectory(r'\\localhost'),
            UncDirectory(r'\\localhost\IPC$'),
            UncDirectory(r'\\localhost\has    spaces'),
            UncDirectory(r'\\some.remote.path\with-a-long-path')
        ]
        self.assertEqualAsSets(table.get_connected_paths(), mounted_paths)

        mounted_drives = [
            DiskDrive('A:'),
            DiskDrive('B:'),
            DiskDrive('C:'),
            DiskDrive('D:')
        ]
        self.assertEqualAsSets(table.get_connected_devices(), mounted_drives)
コード例 #4
0
 def test_empty_table(self):
     table = parse_net_use_table(EMPTY_TABLE)
     self.assertEqual(table.get_connected_paths(), [])
     self.assertEqual(table.get_connected_devices(), [])
コード例 #5
0
 def test_empty_table(self):
     table = parse_net_use_table(EMPTY_TABLE)
     self.assertEqual(table.get_connected_paths(), [])
     self.assertEqual(table.get_connected_devices(), [])