# Path: cfme/utils/dockerbot/dockerbot.py
# class SeleniumDocker(DockerInstance):
#     def __init__(self, bindings, image, dry_run=False):
#         self.dry_run = dry_run
#         self.container_name = fauxfactory.gen_alphanumeric(8)
#         self.process_bindings(bindings)
#         if not self.dry_run:
#             self.container = self.docker_client.containers.create(image,
#                                                                   tty=True,
#                                                                   privileged=True,
#                                                                   ports=self.port_bindings,
#                                                                   name=self.container_name,)
#         else:
#             self.container_name = "DRY_RUN_SELENIUM_CONTAINER"
# 
#     def run(self):
#         print(f"{'DRY RUN' if self.dry_run else self.container.id}: Running Selenium container")
#         if not self.dry_run:
#             self.container.start()


import socket
import subprocess
import sys
import click
from wait_for import TimedOutError
from wait_for import wait_for
from cfme.utils.conf import docker as docker_conf
from cfme.utils.dockerbot.dockerbot import SeleniumDocker
from cfme.utils.net import random_port
        soc = socket.create_connection((addr, int(port)), timeout=2)
    except OSError:
        return False
    # docker-proxy opens the port immediately after container is started.
    # Receive data from the socket to check if VNC session is really running.
    if not soc.recv(1024):
        return False
    soc.close()
    return True


@click.command(help='Starts selenium container for testing against')
@click.option('--watch', help='Opens VNC session', default=False, is_flag=True)
@click.option('--vnc', help='Chooses VNC port', default=5900)
@click.option('--webdriver', help='Chooses webdriver port', default=4444)
@click.option('--image', help='Chooses selenium container image',
              default=docker_conf.get('selff', 'cfmeqe/sel_ff_chrome'))
@click.option('--vncviewer', help='Chooses VNC viewer command',
              default=docker_conf.get('vncviewer', 'vncviewer'))
@click.option('--random-ports', is_flag=True, default=False,
              help='Choose random ports for VNC, webdriver, (overrides --webdriver and --vnc)')
def main(watch, vnc, webdriver, image, vncviewer, random_ports):
    """Main function for running"""

    ip = '127.0.0.1'

    print("Starting container...")
    vnc = random_port() if random_ports else vnc
    webdriver = random_port() if random_ports else webdriver


# Path: cfme/utils/dockerbot/dockerbot.py
# class SeleniumDocker(DockerInstance):
#     def __init__(self, bindings, image, dry_run=False):
#         self.dry_run = dry_run
#         self.container_name = fauxfactory.gen_alphanumeric(8)
#         self.process_bindings(bindings)
#         if not self.dry_run:
#             self.container = self.docker_client.containers.create(image,
#                                                                   tty=True,
#                                                                   privileged=True,
#                                                                   ports=self.port_bindings,
#                                                                   name=self.container_name,)
#         else:
#             self.container_name = "DRY_RUN_SELENIUM_CONTAINER"
# 
#     def run(self):
#         print(f"{'DRY RUN' if self.dry_run else self.container.id}: Running Selenium container")
#         if not self.dry_run:
#             self.container.start()


# Path: cfme/utils/dockerbot/sel_container.py
import socket
import subprocess
import sys
import click
from wait_for import TimedOutError
from wait_for import wait_for
from cfme.utils.conf import docker as docker_conf
from cfme.utils.dockerbot.dockerbot import SeleniumDocker
from cfme.utils.net import random_port

        soc = socket.create_connection((addr, int(port)), timeout=2)
    except OSError:
        return False
    # docker-proxy opens the port immediately after container is started.
    # Receive data from the socket to check if VNC session is really running.
    if not soc.recv(1024):
        return False
    soc.close()
    return True


@click.command(help='Starts selenium container for testing against')
@click.option('--watch', help='Opens VNC session', default=False, is_flag=True)
@click.option('--vnc', help='Chooses VNC port', default=5900)
@click.option('--webdriver', help='Chooses webdriver port', default=4444)
@click.option('--image', help='Chooses selenium container image',
              default=docker_conf.get('selff', 'cfmeqe/sel_ff_chrome'))
@click.option('--vncviewer', help='Chooses VNC viewer command',
              default=docker_conf.get('vncviewer', 'vncviewer'))
@click.option('--random-ports', is_flag=True, default=False,
              help='Choose random ports for VNC, webdriver, (overrides --webdriver and --vnc)')
def main(watch, vnc, webdriver, image, vncviewer, random_ports):
    """Main function for running"""

    ip = '127.0.0.1'

    print("Starting container...")
    vnc = random_port() if random_ports else vnc
    webdriver = random_port() if random_ports else webdriver


    dkb = SeleniumDocker(bindings={'VNC_PORT': (5999, vnc),