列出UNC路径中的所有内容,告诉我无法找到路径

时间:2017-04-28 16:21:09

标签: python windows python-2.7 windows-7 unc

我使用win_unc连接到UNC路径:

import win_unc as unc

def list_all_printers_on_server(servername):
    creds = unc.UncCredentials(r"<USER>", "<PASS>")
    authz_unc = unc.UncDirectory(servername, creds=creds)
    conn = unc.UncDirectoryConnection(authz_unc)
    conn.connect()
    if conn.is_connected():
        print "connected"
        print conn.get_connection_status()
        print conn.get_path()
    else:
        print "not connected "
        print conn.connect()

我能够连接它并打印路径等,但我想要做的是在UNC路径中打印所有内容。如果我使用os.listdir(),我会收到以下错误:

connected
ok
\\<UNC>
Traceback (most recent call last):
  File "fdap.py", line 504, in <module>
    list_all_printers_on_server(r"\\<UNC>")
  File "fdap.py", line 471, in list_all_printers_on_server
    os.listdir(servername)
WindowsError: [Error 67] The network name cannot be found: '<UNC>/*.*'

现在我不明白为什么它告诉我当它告诉我连接状态是ok时找不到路径,我怎样才能连接到这条路径并列出其中的所有内容?

0 个答案:

没有答案