import os
from rackattack.tcp import client


_VAR_NAME = "RACKATTACK_PROVIDER"


def factory():
    if _VAR_NAME not in os.environ:
        raise Exception(
            "The environment variable '%s' must be defined properly" % _VAR_NAME)
    request, subscribe, http = os.environ[_VAR_NAME].split("@@")
    return client.Client(
        providerRequestLocation=request,
        providerSubscribeLocation=subscribe,
        providerHTTPLocation=http)

import os
from rackattack.tcp import client


_VAR_NAME = "RACKATTACK_PROVIDER"


def factory(connectionString=None):
    if connectionString is None:
        if _VAR_NAME not in os.environ:
            raise Exception(
                "The environment variable '%s' must be defined properly" % _VAR_NAME)
        connectionString = os.environ[_VAR_NAME]
    request, subscribe, http = connectionString.split("@@")
    return client.Client(
        providerRequestLocation=request,
        providerSubscribeLocation=subscribe,
        providerHTTPLocation=http)

Allow passing the rackattack connection string as an argument to the client factory
Allow passing the rackattack connection string as an argument to the client factory

  import os
  from rackattack.tcp import client
  
  
  _VAR_NAME = "RACKATTACK_PROVIDER"
  
  
- def factory():
+ def factory(connectionString=None):
+     if connectionString is None:
-     if _VAR_NAME not in os.environ:
+         if _VAR_NAME not in os.environ:
-         raise Exception(
+             raise Exception(
-             "The environment variable '%s' must be defined properly" % _VAR_NAME)
+                 "The environment variable '%s' must be defined properly" % _VAR_NAME)
-     request, subscribe, http = os.environ[_VAR_NAME].split("@@")
+         connectionString = os.environ[_VAR_NAME]
+     request, subscribe, http = connectionString.split("@@")
      return client.Client(
          providerRequestLocation=request,
          providerSubscribeLocation=subscribe,
          providerHTTPLocation=http)
  
Allow passing the rackattack connection string as an argument to the client factory
## Code Before:
import os
from rackattack.tcp import client


_VAR_NAME = "RACKATTACK_PROVIDER"


def factory():
    if _VAR_NAME not in os.environ:
        raise Exception(
            "The environment variable '%s' must be defined properly" % _VAR_NAME)
    request, subscribe, http = os.environ[_VAR_NAME].split("@@")
    return client.Client(
        providerRequestLocation=request,
        providerSubscribeLocation=subscribe,
        providerHTTPLocation=http)

## Instruction:
Allow passing the rackattack connection string as an argument to the client factory
## Code After:
import os
from rackattack.tcp import client


_VAR_NAME = "RACKATTACK_PROVIDER"


def factory(connectionString=None):
    if connectionString is None:
        if _VAR_NAME not in os.environ:
            raise Exception(
                "The environment variable '%s' must be defined properly" % _VAR_NAME)
        connectionString = os.environ[_VAR_NAME]
    request, subscribe, http = connectionString.split("@@")
    return client.Client(
        providerRequestLocation=request,
        providerSubscribeLocation=subscribe,
        providerHTTPLocation=http)
