Fixed NotImplemented error in __init__ method
This commit is contained in:
parent
321c93063e
commit
6b315d96c0
|
@ -47,7 +47,7 @@ class CommunicateAsNewUser(PBA):
|
|||
|
||||
def communicate_as_new_user_linux(self, username):
|
||||
try:
|
||||
with create_auto_new_user(username, PASSWORD) as new_user:
|
||||
with create_auto_new_user(username, PASSWORD, False) as new_user:
|
||||
commandline = "sudo -u {username} ping -c 1 {domain}".format(
|
||||
username=new_user.username,
|
||||
domain=PING_TEST_DOMAIN)
|
||||
|
@ -64,7 +64,7 @@ class CommunicateAsNewUser(PBA):
|
|||
import win32event
|
||||
|
||||
try:
|
||||
with create_auto_new_user(username, PASSWORD) as new_user:
|
||||
with create_auto_new_user(username, PASSWORD, True) as new_user:
|
||||
# Using os.path is OK, as this is on windows for sure
|
||||
ping_app_path = os.path.join(os.environ["WINDIR"], "system32", "PING.exe")
|
||||
if not os.path.exists(ping_app_path):
|
||||
|
|
|
@ -32,7 +32,8 @@ class AutoNewUser:
|
|||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
def __init__(self, username, password):
|
||||
raise NotImplementedError()
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
||||
@abc.abstractmethod
|
||||
def __enter__(self):
|
||||
|
@ -60,8 +61,6 @@ class AutoNewLinuxUser(AutoNewUser):
|
|||
:raises: subprocess.CalledProcessError if failed to add the user.
|
||||
"""
|
||||
super(AutoNewLinuxUser, self).__init__(username, password)
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
||||
commands_to_add_user = get_linux_commands_to_add_user(username)
|
||||
logger.debug("Trying to add {} with commands {}".format(self.username, str(commands_to_add_user)))
|
||||
|
@ -87,8 +86,6 @@ class AutoNewWindowsUser(AutoNewUser):
|
|||
:raises: subprocess.CalledProcessError if failed to add the user.
|
||||
"""
|
||||
super(AutoNewWindowsUser, self).__init__(username, password)
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
||||
windows_cmds = get_windows_commands_to_add_user(self.username, self.password, True)
|
||||
_ = subprocess.check_output(windows_cmds, stderr=subprocess.STDOUT, shell=True)
|
||||
|
|
Loading…
Reference in New Issue