sandbox/views.py
def post(self, request):
        """Allows to execute bash commands within an optional environment."""
        start = time.time()
        
        config = request.POST.get("config")
        if config is None:
            return HttpResponseBadRequest("Missing argument 'config'")
        
        try:
            config = json.loads(config)
            if not isinstance(config, dict):
                return HttpResponseBadRequest(f'config must be an object, not {type(config)}')
        except json.JSONDecodeError as e:
            return HttpResponseBadRequest(f"'config' json is invalid - {e}")
        
        env = utils.executed_env(request, config)
        commands = Command.from_config(config)
        result_path = utils.parse_result_path(config)
        save = utils.parse_save(config)
        
        logger.debug(f"Parsing config request took : {time.time() - start} seconds")
        
        sandbox = Sandbox.acquire()
        try:
            response = Executor(commands, sandbox, env, result_path, save).execute()
            logger.debug(f"Total execute request took : {time.time() - start} seconds")
            return JsonResponse(response)
        finally:
            threading.Thread(target=sandbox.release).start()
Allows to execute bash commands within an optional environment.
Allows to execute bash commands within an optional environment.
Allows to execute bash commands within an optional environment .
def post(self, request):
        start = time.time()
        config = request.POST.get("config")
        if config is None:
            return HttpResponseBadRequest("Missing argument 'config'")
        try:
            config = json.loads(config)
            if not isinstance(config, dict):
                return HttpResponseBadRequest(f'config must be an object, not {type(config)}')
        except json.JSONDecodeError as e:
            return HttpResponseBadRequest(f"'config' json is invalid - {e}")
        env = utils.executed_env(request, config)
        commands = Command.from_config(config)
        result_path = utils.parse_result_path(config)
        save = utils.parse_save(config)
        logger.debug(f"Parsing config request took : {time.time() - start} seconds")
        sandbox = Sandbox.acquire()
        try:
            response = Executor(commands, sandbox, env, result_path, save).execute()
            logger.debug(f"Total execute request took : {time.time() - start} seconds")
            return JsonResponse(response)
        finally:
            threading.Thread(target=sandbox.release).start()
def post ( self , request ) : start = time . time ( ) config = request . POST . get ( "config" ) if config is None : return HttpResponseBadRequest ( "Missing argument 'config'" ) try : config = json . loads ( config ) if not isinstance ( config , dict ) : return HttpResponseBadRequest ( f'config must be an object, not {type(config)}' ) except json . JSONDecodeError as e : return HttpResponseBadRequest ( f"'config' json is invalid - {e}" ) env = utils . executed_env ( request , config ) commands = Command . from_config ( config ) result_path = utils . parse_result_path ( config ) save = utils . parse_save ( config ) logger . debug ( f"Parsing config request took : {time.time() - start} seconds" ) sandbox = Sandbox . acquire ( ) try : response = Executor ( commands , sandbox , env , result_path , save ) . execute ( ) logger . debug ( f"Total execute request took : {time.time() - start} seconds" ) return JsonResponse ( response ) finally : threading . Thread ( target = sandbox . release ) . start ( )
Allows to execute bash commands within an optional environment.
Allows to execute bash commands within an optional environment .
"""Allows to execute bash commands within an optional environment."""
self
request