benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 5aa8e913-c2c0-537d-aa7d-520670bac55f

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import subprocess
import os
import time
from datetime import datetime


def task_func(script_dir, scripts, delay):
    """
    Execute a list of bash scripts with a specified delay between each script.

    Parameters:
    script_dir (str): Path to the directory containing the scripts.
    scripts (list): List of script filenames to be executed. Must not be empty.
                    If a script is not found, the function raises a FileNotFoundError.
    delay (int): The delay in seconds between each script execution. Must at least 0.

    Returns:
    list: A list of timestamps indicating the start time of each script execution.

    Raises:
    - ValueError: If the delay is negative or no scripts are provided.
    
    Requirements:
    - subprocess
    - os
    - time
    - datetime.datetime

    Example:
    >>> task_func('/path/to/scripts/', ['script1.sh', 'script2.sh'], 5)
    ['2023-09-09 10:10:10', '2023-09-09 10:10:15']
    """

instruct prompt

Execute a list of bash scripts with a specified delay between each script.
The function should raise the exception for: ValueError: If the delay is negative or no scripts are provided.
The function should output with:
    list: A list of timestamps indicating the start time of each script execution.
You should write self-contained code starting with:

Code

import subprocess
import os
import time
from datetime import datetime
def task_func(script_dir, scripts, delay):

code prompt

Code

import subprocess
import os
import time
from datetime import datetime
def task_func(script_dir, scripts, delay):

entry point

task_func

libs

  • subprocess
  • time
  • datetime
  • os

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import