示例#1
0
 def inner():
     try:
         self.wharf.checkout()
         return super(WharfFactory, self).create(url_key)
     except URLError as ex:
         # connection to selenum was refused for unknown reasons
         log.error('URLError connecting to selenium; recycling container. URLError:')
         write_line('URLError caused container recycle, see log for details', red=True)
         log.exception(ex)
         self.wharf.checkin()
         raise
示例#2
0
 def processed_browser_args(self):
     command_executor = self.wharf.config['webdriver_url']
     view_msg = 'tests can be viewed via vnc on display {}'.format(
         self.wharf.config['vnc_display'])
     log.info('webdriver command executor set to %s', command_executor)
     log.info(view_msg)
     write_line(view_msg, cyan=True)
     return dict(
         super().processed_browser_args(),
         command_executor=command_executor,
     )
示例#3
0
 def processed_browser_args(self):
     command_executor = self.wharf.config['webdriver_url']
     view_msg = 'tests can be viewed via vnc on display {}'.format(
         self.wharf.config['vnc_display'])
     log.info('webdriver command executor set to %s', command_executor)
     log.info(view_msg)
     write_line(view_msg, cyan=True)
     return dict(
         super(WharfFactory, self).processed_browser_args(),
         command_executor=command_executor,
     )
示例#4
0
def shutdown(config):
    app = find_appliance(config, require=False)
    if app is not None:
        with lock:
            proc = config._art_proc
            if proc and proc.returncode is None:
                if not store.slave_manager:
                    write_line('collecting artifacts')
                    fire_art_hook(config, 'finish_session')
                if not store.slave_manager:
                    config._art_client.terminate()
                    proc.wait()
示例#5
0
def shutdown(config):
    app = find_appliance(config, require=False)
    if app is not None:
        with lock:
            proc = config._art_proc
            if proc and proc.returncode is None:
                if not store.slave_manager:
                    write_line('collecting artifacts')
                    fire_art_hook(config, 'finish_session')
                fire_art_hook(config, 'teardown_merkyl',
                              ip=app.hostname)
                if not store.slave_manager:
                    config._art_client.terminate()
                    proc.wait()
示例#6
0
    def set_trace(self, *args, **kwargs):
        """Start a pdb debugger available via telnet, and optionally email people the endpoint

        The endpoint will always be seen in the py.test runner output.

        Keyword Args:
            recipients: A list where, if set, an email will be sent to email addresses
                in this list.
            subject: If set, an optional custom email subject

        """
        host, port = self.sock.getsockname()
        endpoint = 'host {} port {}'.format(store.my_ip_address, port)

        recipients = kwargs.pop('recipients', None)
        if recipients:
            # write and send an email
            subject = kwargs.pop('subject', 'RDB Breakpoint: Manually invoked')
            body = dedent("""\
            A py.test run encountered an error. The remote debugger is running
            on {} (TCP), waiting for telnet connection.
            """).format(endpoint)

            try:
                smtp_server = smtp_conf['server']
                smtp = smtplib.SMTP(smtp_server)
                msg = MIMEText(body)
                msg['Subject'] = subject
                msg['To'] = ', '.join(recipients)
                smtp.sendmail('*****@*****.**', recipients,
                              msg.as_string())
            except socket.error:
                logger.critical("Couldn't send email")

        msg = 'Remote debugger listening on {}'.format(endpoint)
        logger.critical(msg)
        write_line(msg, red=True, bold=True)
        self.sock.listen(1)
        (client_socket, address) = self.sock.accept()
        client_fh = client_socket.makefile('rw')
        Pdb.__init__(self,
                     completekey='tab',
                     stdin=client_fh,
                     stdout=client_fh)
        sys.stdout = sys.stdin = client_fh
        Pdb.set_trace(self, *args, **kwargs)
        msg = 'Debugger on {} shut down'.format(endpoint)
        logger.critical(msg)
        write_line(msg, green=True, bold=True)
示例#7
0
 def inner():
     try:
         self.wharf.checkout()
         return super(WharfFactory, self).create(url_key)
     except URLError as ex:
         # connection to selenum was refused for unknown reasons
         log.error(
             'URLError connecting to selenium; recycling container. URLError:'
         )
         write_line(
             'URLError caused container recycle, see log for details',
             red=True)
         log.exception(ex)
         self.wharf.checkin()
         raise
示例#8
0
def shutdown(config):
    app = find_appliance(config, require=False)
    if app is not None:
        with lock:
            proc = config._art_proc
            if proc:
                if not store.slave_manager:
                    write_line('collecting artifacts')
                    fire_art_hook(config, 'finish_session')
                fire_art_hook(config, 'teardown_merkyl',
                              ip=app.hostname)
                if not store.slave_manager:
                    config._art_client.terminate()
                    proc = config._art_proc
                    if proc:
                        proc.wait()
示例#9
0
文件: rdb.py 项目: apagac/cfme_tests
    def set_trace(self, *args, **kwargs):
        """Start a pdb debugger available via telnet, and optionally email people the endpoint

        The endpoint will always be seen in the py.test runner output.

        Keyword Args:
            recipients: A list where, if set, an email will be sent to email addresses
                in this list.
            subject: If set, an optional custom email subject

        """
        host, port = self.sock.getsockname()
        endpoint = 'host {} port {}'.format(store.my_ip_address, port)

        recipients = kwargs.pop('recipients', None)
        if recipients:
            # write and send an email
            subject = kwargs.pop('subject', 'RDB Breakpoint: Manually invoked')
            body = dedent("""\
            A py.test run encountered an error. The remote debugger is running
            on {} (TCP), waiting for telnet connection.
            """).format(endpoint)

            try:
                smtp_server = smtp_conf['server']
                smtp = smtplib.SMTP(smtp_server)
                msg = MIMEText(body)
                msg['Subject'] = subject
                msg['To'] = ', '.join(recipients)
                smtp.sendmail('*****@*****.**', recipients, msg.as_string())
            except socket.error:
                logger.critical("Couldn't send email")

        msg = 'Remote debugger listening on {}'.format(endpoint)
        logger.critical(msg)
        write_line(msg, red=True, bold=True)
        self.sock.listen(1)
        (client_socket, address) = self.sock.accept()
        client_fh = client_socket.makefile('rw')
        Pdb.__init__(self, completekey='tab', stdin=client_fh, stdout=client_fh)
        sys.stdout = sys.stdin = client_fh
        Pdb.set_trace(self, *args, **kwargs)
        msg = 'Debugger on {} shut down'.format(endpoint)
        logger.critical(msg)
        write_line(msg, green=True, bold=True)