Ejemplo n.º 1
0
    def __init__(self, name, attr, logger=None, logpath=None, shareData=None):
        dut.__init__(self, name, attr, logger, logpath, shareData)

        exe_cmd = ['cmd.exe']
        a = [
            'C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe',
            '/c', 'pwd'
        ]

        self.shellsession = subprocess.Popen(args=exe_cmd,
                                             shell=True,
                                             stdout=subprocess.PIPE,
                                             stdin=subprocess.PIPE,
                                             stderr=subprocess.PIPE)
        self.q_out = Queue()
        self.q_err = Queue()
        import threading
        self.lockStreamOut = threading.Lock()
        self.streamOut = ''
        th = threading.Thread(target=self.ReadOutput)
        th.start()
        th2 = threading.Thread(target=self.fill_queue_of_stdout)
        th3 = threading.Thread(target=self.fill_queue_of_stderr)
        th2.start()
        th3.start()
        self.debuglevel = 0
Ejemplo n.º 2
0
    def __init__(self, name, attr=None, logger=None, logpath=None, shareData=None):
        try:
            dut.__init__(self, name, attr, logger, logpath, shareData)
            import re

            reSSHcmd1 = re.compile("ssh\s+([\w._-]+)@([\w._-]+)\s*:\s*(\d+)", re.I)
            reSSHcmd2 = re.compile("ssh\s+([\w._-]+)@([\w._-]+)", re.I)
            if not self.attribute.has_key("CMD"):
                self.attribute["CMD"] = "ssh user@localhost"
                self.attribute["PASSWORD"] = "******"
            m1 = re.match(reSSHcmd1, self.attribute["CMD"])
            m2 = re.match(reSSHcmd2, self.attribute["CMD"])
            if m1:
                self.attribute["USER"] = m1.group(1)
                self.attribute["HOST"] = m1.group(2)
                self.attribute["PORT"] = int(m1.groups(3))
            elif m2:
                self.attribute["USER"] = m2.group(1)
                self.attribute["HOST"] = m2.group(2)
                self.attribute["PORT"] = 22
            # self.login()
            import threading

            self.lockStreamOut = threading.Lock()
            self.streamOut = ""
            th = threading.Thread(target=self.ReadOutput)
            th.start()
            self.debuglevel = 0

            self.login()
        except Exception as e:
            self.closeSession()
            raise e
Ejemplo n.º 3
0
    def __init__(self,
                 name,
                 attr=None,
                 logger=None,
                 logpath=None,
                 shareData=None):
        dut.__init__(self, name, attr, logger, logpath, shareData)

        try:
            host = ""
            port = 23

            reHostOnly = re.compile('\s*telnet\s+([\d.\w\-_]+)\s*', re.I)
            reHostPort = re.compile('\s*telnet\s+([\d.\w]+)\s+(\d+)', re.I)

            command = self.attribute.get('CMD')
            m1 = re.match(reHostOnly, command)
            m2 = re.match(reHostPort, command)
            if m2:
                host = m2.group(1)
                port = int(m2.group(2))
            elif m1:
                host = m1.group(1)

            #import socket
            #timeout = 30
            #self.sock = socket.create_connection((host, port), timeout)
            self.debuglevel = DEBUGLEVEL
            self.host = host
            self.port = port
            timeout = 0.5
            self.timeout = timeout
            self.sock = None
            self.rawq = ''
            self.irawq = 0
            self.cookedq = ''
            self.eof = 0
            self.iacseq = ''  # Buffer for IAC sequence.
            self.sb = 0  # flag for SB and SE sequence.
            self.sbdataq = ''
            self.option_callback = None
            self._has_poll = hasattr(select, 'poll')
            if host is not None and self.is_simulation() == False:
                self.open(str(host), port, timeout)

            th = threading.Thread(target=self.ReadOutput)
            th.start()
            time.sleep(1)
            if self.attribute.has_key('LOGIN'):
                self.login()
            self.debuglevel = 0
        except Exception as e:
            self.closeSession()
            import traceback
            print(traceback.format_exc())
            raise e
Ejemplo n.º 4
0
    def __init__(self, name, attr =None,logger=None,  logpath= None, shareData=None):
        dut.__init__(self, name,attr,logger, logpath , shareData)

        try:
            host=""
            port=23

            reHostOnly=  re.compile('\s*telnet\s+([\d.\w\-_]+)\s*',re.I)
            reHostPort = re.compile('\s*telnet\s+([\d.\w]+)\s+(\d+)', re.I )

            command = self.attribute.get('CMD')
            m1=re.match(reHostOnly, command)
            m2=re.match(reHostPort, command)
            if m2:
                host= m2.group(1)
                port= int(m2.group(2))
            elif m1:
                host= m1.group(1)

            #import socket
            #timeout = 30
            #self.sock = socket.create_connection((host, port), timeout)
            self.debuglevel = DEBUGLEVEL
            self.host = host
            self.port = port
            timeout=0.5
            self.timeout = timeout
            self.sock = None
            self.rawq = ''
            self.irawq = 0
            self.cookedq = ''
            self.eof = 0
            self.iacseq = '' # Buffer for IAC sequence.
            self.sb = 0 # flag for SB and SE sequence.
            self.sbdataq = ''
            self.option_callback = None
            self._has_poll = hasattr(select, 'poll')
            if host is not None and self.is_simulation() == False:
                self.open(str(host), port, timeout)

            th =threading.Thread(target=self.ReadOutput)
            th.start()
            time.sleep(1)
            if self.attribute.has_key('LOGIN'):
                self.login()
            self.debuglevel=0
        except Exception as e:
            self.closeSession()
            import traceback
            print(traceback.format_exc())
            raise e
Ejemplo n.º 5
0
    def __init__(self,
                 name,
                 attr=None,
                 logger=None,
                 logpath=None,
                 shareData=None):
        #try:
        dut.__init__(self, name, attr, logger, logpath, shareData)
        self.log_file = self.logfile

        binary = None
        if FireFox:
            binary_path = './selenium/webdriver/firefox/'

            profile_path = None
            profile = None  # webdriver.FirefoxProfile(profile_path)
            #profile = webdriver.FirefoxProfile()
            a = FirefoxBinary()._get_firefox_start_cmd()
            #print(a, 'firefox file!!!!!!!!!!!!!!!!!!')
            if os.path.exists(binary_path):
                binary = FirefoxBinary(a)
                profile = webdriver.FirefoxProfile(binary_path)

            self.driver = webdriver.Firefox(firefox_binary=binary,
                                            firefox_profile=profile)

            self.driver.log_file = self.logfile
        else:
            self.driver = webdriver.Chrome()
            #webdriver.Chrome.__init__(self)
        #webdriver.Firefox.__init__(self,firefox_profile=profile)#, firefox_profile=profile, firefox_binary=)#

        #except:
        #    webdriver.Chrome.__init__(self)
        #webdriver.Firefox.__init__(self)

        if self.attribute.has_key('INTERVAL'):
            self.common_wait_interval = self.attribute['INTERVAL']
            time.sleep(0.5)
        else:
            self.common_wait_interval = 1
Ejemplo n.º 6
0
    def __init__(self,name,attr,logger=None, logpath=None, shareData=None):
        dut.__init__(self, name,attr,logger, logpath, shareData)

        exe_cmd=['cmd.exe']
        a  = ['C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe',
                 '/c',
                 'pwd']

        self.shellsession = subprocess.Popen(args = exe_cmd ,shell =True, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
        self.q_out = Queue()
        self.q_err = Queue()
        import threading
        self.lockStreamOut =threading.Lock()
        self.streamOut=''
        th =threading.Thread(target=self.ReadOutput)
        th.start()
        th2 =threading.Thread(target=self.fill_queue_of_stdout)
        th3 =threading.Thread(target=self.fill_queue_of_stderr)
        th2.start()
        th3.start()
        self.debuglevel=0
Ejemplo n.º 7
0
    def __init__(self,
                 name,
                 attr=None,
                 logger=None,
                 logpath=None,
                 shareData=None):
        try:
            dut.__init__(self, name, attr, logger, logpath, shareData)
            import re
            reSSHcmd1 = re.compile('ssh\s+([\w._-]+)@([\w._-]+)\s*:\s*(\d+)',
                                   re.I)
            reSSHcmd2 = re.compile('ssh\s+([\w._-]+)@([\w._-]+)', re.I)
            if not self.attribute.has_key('CMD'):
                self.attribute['CMD'] = 'ssh user@localhost'
                self.attribute['PASSWORD'] = '******'
            m1 = re.match(reSSHcmd1, self.attribute['CMD'])
            m2 = re.match(reSSHcmd2, self.attribute['CMD'])
            if m1:
                self.attribute['USER'] = m1.group(1)
                self.attribute['HOST'] = m1.group(2)
                self.attribute['PORT'] = int(m1.groups(3))
            elif m2:
                self.attribute['USER'] = m2.group(1)
                self.attribute['HOST'] = m2.group(2)
                self.attribute['PORT'] = 22
            #self.login()
            import threading
            self.lockStreamOut = threading.Lock()
            self.streamOut = ''
            th = threading.Thread(target=self.ReadOutput)
            th.start()
            self.debuglevel = 0

            self.login()
        except Exception as e:
            self.closeSession()
            raise e
Ejemplo n.º 8
0
    def __init__(self, name, attr =None,logger=None, logpath= None, shareData=None):
        #try:
        dut.__init__(self, name,attr,logger,logpath,shareData)
        self.log_file =self.logfile


        binary = None
        if FireFox:
            binary_path = './selenium/webdriver/firefox/'

            profile_path =None
            profile =None# webdriver.FirefoxProfile(profile_path)
            #profile = webdriver.FirefoxProfile()
            a = FirefoxBinary()._get_firefox_start_cmd()
            #print(a, 'firefox file!!!!!!!!!!!!!!!!!!')
            if os.path.exists(binary_path):
                binary = FirefoxBinary(a)
                profile = webdriver.FirefoxProfile(binary_path)

            self.driver= webdriver.Firefox(firefox_binary=binary,firefox_profile=profile)

            self.driver.log_file= self.logfile
        else:
            self.driver = webdriver.Chrome()
            #webdriver.Chrome.__init__(self)
        #webdriver.Firefox.__init__(self,firefox_profile=profile)#, firefox_profile=profile, firefox_binary=)#

        #except:
        #    webdriver.Chrome.__init__(self)
            #webdriver.Firefox.__init__(self)

        if self.attribute.has_key('INTERVAL'):
            self.common_wait_interval = self.attribute['INTERVAL']
            time.sleep(0.5)
        else:
            self.common_wait_interval = 1