Listing everything in a UNC path telling me that the path cannot be found

223
April 29, 2017, at 03:09 AM

I'm connecting to a UNC path using win_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()

I'm able to get it connected and print the path and such, but what I want to do is print everything in the UNC path. If I use os.listdir() I get the following error:

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>/*.*'

Now I don't understand why it is telling me that the path cannot be found when it tells me that the connection status is ok, how can I connect to this path and list everything inside of it?

READ ALSO
How to control EOL and leading spaces in Mako?

How to control EOL and leading spaces in Mako?

With the following, I would like to control the EOL:

217
How to search for a variable in a list of strings

How to search for a variable in a list of strings

I have very basic python knowledgeThis is my code so far: when i run this code the error UnboundLocalError: local variable 'response' referenced before assignment on line 7 displays

248
Trying to wrap my head around python property decorator [duplicate]

Trying to wrap my head around python property decorator [duplicate]

This question already has an answer here:

234
How to recognize Chinese or English name using python [on hold]

How to recognize Chinese or English name using python [on hold]

Given a bunch of names, how can we find out which are Chinese names and which are English names? For the Chinese names, I build a list of the Chinese last names to find out the Chinese namesFor example, Bruce Lee, Lee is a Chinese last name, so we regard...

464