<commit_before># Software License Agreement (BSD License)
#
# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms, with or
# without modification, are permitted provided that the following conditions
# are met:
#
#   Redistributions of source code must retain the above
#   copyright notice, this list of conditions and the
#   following disclaimer.
#
#   Redistributions in binary form must reproduce the above
#   copyright notice, this list of conditions and the
#   following disclaimer in the documentation and/or other
#   materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: <EMAIL>



from eutester import sshconnection 
from eutester.sshconnection import SshConnection 
from eutester.eulogger import Eulogger
import time
import re

class WindowsProxyTests():
     
    def __init__(self, 
                  proxy_hostname,  #192.168.23.9
                  proxy_username = 'Administrator',
                  proxy_password = None, 
                  proxy_keypath = None,
                  timeout = 120,
                  retry = 2, 
                  debugmethod = None,
                  verbose = True,
                  win_instance = None,
                  win_keypath = None,
                  win_password = None ):
        '''
        Description: Help class to execute remote powershell cmdlets over an ssh connection in order to 
                    test Windows Instance functionality within the cloud.
                    
        :type proxy_host: string
        :param proxy_host: The ip address or FQDN hostname of the windows server to connect via ssh, and exectute the powershell commands on.
        
        :type proxy_username: string
        :param proxy_username: The username used for created the remote ssh session, and executing the powershell cmdlets
        
        :type proxy_password: string
        :param proxy_passwrd: The password used fro creating the remote ssh session. 
        
        :type proxy_keypath: string
        :param proxy_keypath: The path to the ssh keyfile used for establishing the ssh session to the remote powershell server. 
        
        :type timeout: integer
        :param timeout: Timeout to be used as a default for method timeouts. ie  timeout used for establising an ssh session to powershell server. 
        
        :type retry:
        :param retry: Used to define the amount of times to retry a failed method before giving up. 
        
        :type debugmethod: method
        :param debugmethod: A method which can be pass and used for self.debug
        
        :type verbose: boolean
        :param verbose: A boolean to flag on or off debug messages. 
        
        :type win_instance: instance object
        :param win_instance: instance object used as the default target for running tests against
        
        :type win_keypath: string
        :param win_keypath: A string representing the path to the keyfile used when launching the win_instance instance. 
                            This is used for building the password to win_instance if necessarry. 
                            See ec2ops for get_windows_instance_password method
        
        :type win_password: string
        :param win_password: The cloud generated password associated with win_instance. See ec2ops for get_windows_instance_password method
         
        '''
        
        self.proxy_hostname = proxy_hostname
        self.proxy_username = proxy_username or 'Administrator'
        self.proxy_password = proxy_password
        self.proxy_keypath = proxy_keypath
        self.timeout = timeout
        self.retry = retry
        self.verbose = verbose
        self.win_instance = win_instance
        self.win_keypath = win_keypath
        self.win_password = <PASSWORD>_password
        self.debugmethod = debugmethod
        if self.debugmethod is None:
            logger = Eulogger(identifier= 'winproxy'+ str(proxy_hostname) + ":")
            self.debugmethod = logger.log.debug
            
        #setup ssh connection to power shell proxy server
        self.ssh = SshConnection( proxy_hostname, keypath=proxy_keypath, password=<PASSWORD>, username=proxy_username, 
                                                timeout=timeout, retry=retry,debugmethod=self.debugmethod, verbose=True)
        self.sys = self.ssh.sys
        self.cmd = self.ssh.cmd


    def debug(self,msg):
        '''
        Used to print debug, defaults to print() but over ridden by self.debugmethod if not None
        msg - mandatory -string, message to be printed
        '''
        if ( self.verbose is True ):
            if self.debugmethod:
                self.debugmethod(msg)
            else:
                print(msg)
    def reset_ssh(self):
        self.ssh.close()
        self.ssh.refresh_connection()
<commit_msg>Remove ssh close on remote powershell command<commit_after># Software License Agreement (BSD License)
#
# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms, with or
# without modification, are permitted provided that the following conditions
# are met:
#
#   Redistributions of source code must retain the above
#   copyright notice, this list of conditions and the
#   following disclaimer.
#
#   Redistributions in binary form must reproduce the above
#   copyright notice, this list of conditions and the
#   following disclaimer in the documentation and/or other
#   materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Author: <EMAIL>



from eutester import sshconnection 
from eutester.sshconnection import SshConnection 
from eutester.eulogger import Eulogger
import time
import re

class WindowsProxyTests():
     
    def __init__(self, 
                  proxy_hostname,  #192.168.23.9
                  proxy_username = 'Administrator',
                  proxy_password = None, 
                  proxy_keypath = None,
                  timeout = 120,
                  retry = 2, 
                  debugmethod = None,
                  verbose = True,
                  win_instance = None,
                  win_keypath = None,
                  win_password = None ):
        '''
        Description: Help class to execute remote powershell cmdlets over an ssh connection in order to 
                    test Windows Instance functionality within the cloud.
                    
        :type proxy_host: string
        :param proxy_host: The ip address or FQDN hostname of the windows server to connect via ssh, and exectute the powershell commands on.
        
        :type proxy_username: string
        :param proxy_username: The username used for created the remote ssh session, and executing the powershell cmdlets
        
        :type proxy_password: string
        :param proxy_passwrd: The password used fro creating the remote ssh session. 
        
        :type proxy_keypath: string
        :param proxy_keypath: The path to the ssh keyfile used for establishing the ssh session to the remote powershell server. 
        
        :type timeout: integer
        :param timeout: Timeout to be used as a default for method timeouts. ie  timeout used for establising an ssh session to powershell server. 
        
        :type retry:
        :param retry: Used to define the amount of times to retry a failed method before giving up. 
        
        :type debugmethod: method
        :param debugmethod: A method which can be pass and used for self.debug
        
        :type verbose: boolean
        :param verbose: A boolean to flag on or off debug messages. 
        
        :type win_instance: instance object
        :param win_instance: instance object used as the default target for running tests against
        
        :type win_keypath: string
        :param win_keypath: A string representing the path to the keyfile used when launching the win_instance instance. 
                            This is used for building the password to win_instance if necessarry. 
                            See ec2ops for get_windows_instance_password method
        
        :type win_password: string
        :param win_password: The cloud generated password associated with win_instance. See ec2ops for get_windows_instance_password method
         
        '''
        
        self.proxy_hostname = proxy_hostname
        self.proxy_username = proxy_username or 'Administrator'
        self.proxy_password = <PASSWORD>
        self.proxy_keypath = proxy_keypath
        self.timeout = timeout
        self.retry = retry
        self.verbose = verbose
        self.win_instance = win_instance
        self.win_keypath = win_keypath
        self.win_password = <PASSWORD>
        self.debugmethod = debugmethod
        if self.debugmethod is None:
            logger = Eulogger(identifier= 'winproxy'+ str(proxy_hostname) + ":")
            self.debugmethod = logger.log.debug
            
        #setup ssh connection to power shell proxy server
        self.ssh = SshConnection( proxy_hostname, keypath=proxy_keypath, password=<PASSWORD>, username=proxy_username, 
                                                timeout=timeout, retry=retry,debugmethod=self.debugmethod, verbose=True)
        self.sys = self.ssh.sys
        self.cmd = self.ssh.cmd


    def debug(self,msg):
        '''
        Used to print debug, defaults to print() but over ridden by self.debugmethod if not None
        msg - mandatory -string, message to be printed
        '''
        if ( self.verbose is True ):
            if self.debugmethod:
                self.debugmethod(msg)
            else:
                print(msg)
    def reset_ssh(self):
        self.ssh.refresh_connection()

{'fraction_non_alphanumeric': 0.05179704016913319, 'fraction_numerical': 0.00405214940098661, 'mean_word_length': 2.364848844101956, 'pattern_counts': {'":': 2, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4438290', 'n_tokens_mistral': 2941, 'n_tokens_neox': 2698, 'n_words': 1169}