sandbox/utils.py
def executed_env(request: HttpRequest, config: dict) -> str:
    """Returns the UUID4 corresponding to the environment that will be used in the execution.
    
    If an environment is provided both in the body and the config, this function will do the merge
    through 'merge_tar_gz()'.
    
    raises:
        - django_http_exceptions.HTTPExceptions.NOT_FOUND if the environment asked in request's
          config cannot be found.
    """
    body_env = request.FILES.get("environment")
    
    sandbox_env = None
    sandbox_env_uuid = config.get("environment")
    if sandbox_env_uuid is not None:
        sandbox_env = get_env(sandbox_env_uuid)
        if not sandbox_env:
            raise HTTPExceptions.NOT_FOUND.with_content(
                f"No environment with UUID '{sandbox_env_uuid}' found"
            )
        sandbox_env = open(sandbox_env, "rb")
    
    env = merge_tar_gz(body_env, sandbox_env)
    
    if body_env is not None:
        body_env.close()
    if sandbox_env is not None:
        sandbox_env.close()
    
    uuid_env = str(uuid.uuid4())
    path = os.path.join(settings.ENVIRONMENT_ROOT, f"{uuid_env}.tgz")
    if env is not None:
        with open(path, "w+b") as f:
            f.write(env.read())
    else:
        tarfile.open(path, "x:gz").close()
    
    return uuid_env
Returns the UUID4 corresponding to the environment that will be used in the execution.
    
    If an environment is provided both in the body and the config, this function will do the merge
    through 'merge_tar_gz()'.
    
    raises:
        - django_http_exceptions.HTTPExceptions.NOT_FOUND if the environment asked in request's
          config cannot be found.
    
Returns the UUID4 corresponding to the environment that will be used in the execution.
If an environment is provided both in the body and the config, this function will do the merge
through 'merge_tar_gz()'.

django_http_exceptions.HTTPExceptions.NOT_FOUND if the environment asked in request's
config cannot be found.
Returns the UUID4 corresponding to the environment that will be used in the execution . If an environment is provided both in the body and the config this function will do the merge through ' merge_tar_gz () ' . django_http_exceptions . HTTPExceptions . NOT_FOUND if the environment asked in request ' s config cannot be found .
def executed_env(request: HttpRequest, config: dict) -> str:
    body_env = request.FILES.get("environment")
    sandbox_env = None
    sandbox_env_uuid = config.get("environment")
    if sandbox_env_uuid is not None:
        sandbox_env = get_env(sandbox_env_uuid)
        if not sandbox_env:
            raise HTTPExceptions.NOT_FOUND.with_content(
                f"No environment with UUID '{sandbox_env_uuid}' found"
            )
        sandbox_env = open(sandbox_env, "rb")
    env = merge_tar_gz(body_env, sandbox_env)
    if body_env is not None:
        body_env.close()
    if sandbox_env is not None:
        sandbox_env.close()
    uuid_env = str(uuid.uuid4())
    path = os.path.join(settings.ENVIRONMENT_ROOT, f"{uuid_env}.tgz")
    if env is not None:
        with open(path, "w+b") as f:
            f.write(env.read())
    else:
        tarfile.open(path, "x:gz").close()
    return uuid_env
def executed_env ( request : HttpRequest , config : dict ) -> str : body_env = request . FILES . get ( "environment" ) sandbox_env = None sandbox_env_uuid = config . get ( "environment" ) if sandbox_env_uuid is not None : sandbox_env = get_env ( sandbox_env_uuid ) if not sandbox_env : raise HTTPExceptions . NOT_FOUND . with_content ( f"No environment with UUID '{sandbox_env_uuid}' found" ) sandbox_env = open ( sandbox_env , "rb" ) env = merge_tar_gz ( body_env , sandbox_env ) if body_env is not None : body_env . close ( ) if sandbox_env is not None : sandbox_env . close ( ) uuid_env = str ( uuid . uuid4 ( ) ) path = os . path . join ( settings . ENVIRONMENT_ROOT , f"{uuid_env}.tgz" ) if env is not None : with open ( path , "w+b" ) as f : f . write ( env . read ( ) ) else : tarfile . open ( path , "x:gz" ) . close ( ) return uuid_env
Returns the UUID4 corresponding to the environment that will be used in the execution.
Returns the UUID4 corresponding to the environment that will be used in the execution .
"""Returns the UUID4 corresponding to the environment that will be used in the execution.
    
    If an environment is provided both in the body and the config, this function will do the merge
    through 'merge_tar_gz()'.
    
    raises:
        - django_http_exceptions.HTTPExceptions.NOT_FOUND if the environment asked in request's
          config cannot be found.
    """
request
HttpRequest
config
dict