CovenantEyes/py_win_unc — pull request #15 by smetnana (2013-06-28 18:05:02+00:00)
Title: Bugfix: is_connected() not working correctly when using credentials

Dear developers,

thanks for sharing the py_win_unc project. This is a really helpful tool and saves me writing my own wrapper for NET USE.

I have found a small bug when using credentials. My code looks something like this:

unc_path = "\\\\192.168.93.2\\ifs"
creds = UncCredentials('root', 'a')
unc_dir = UncDirectory(unc_path, creds)

conn = UncDirectoryConnection(unc_dir, persistent=True)
print 'Connected?', conn.get_connection_status()
conn.connect()
print 'Connected?', conn.get_connection_status()
conn.disconnect()
print 'Connected?', conn.get_connection_status()

"""
Returns:

Connected? None
Connected? None
Connected? None
"""

Clearly, the expected output is "None, ok, None", so something has gone wrong. I have fixed the bug and I am hoping to contribute it back to the project. My code includes a unit test and the fix (one line change).

Please let me know if there are any questions.