Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions PIconnect/PI.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ def __init__(
if server and server not in self.servers:
message = 'Server "{server}" not found, using the default server.'
warn(message=message.format(server=server), category=UserWarning)
if bool(username) != bool(password):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that a username without a password is a valid case, but a password without a user is still invalid, right? In that case we should not remove this check entirely, but make it more similar to the next check for a domain without a username.

raise ValueError(
"When passing credentials both the username and password must be specified."
)
if domain and not username:
raise ValueError(
"A domain can only specified together with a username and password."
Expand All @@ -92,8 +88,10 @@ def __init__(
from System.Security import SecureString

secure_pass = SecureString()
for c in password:
secure_pass.AppendChar(c)

if password != None:
for c in password:
secure_pass.AppendChar(c)
cred = [username, secure_pass] + ([domain] if domain else [])
self._credentials = (NetworkCredential(*cred), int(authentication_mode))
else:
Expand Down