benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 9ddffbcb-cb4f-5b61-b00d-6237a9561206

Problem

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

complete prompt

import subprocess
import os
import shutil
import sys

# Constants
DIRECTORY = 'c:\Program Files\VMware\VMware Server'
BACKUP_DIRECTORY = 'c:\Program Files\VMware\VMware Server\Backup'

def task_func(filename):
    """
    Backs up a specified file from a predefined directory to a backup directory and executes it as a subprocess.
    
    Parameters:
    filename (str): The name of the file to be backed up and executed.

    Returns:
    int: The exit code of the subprocess, or -1 if the backup process fails.

    Requirements:
    - subprocess
    - shutil

    Example:
    >>> task_func('vmware-cmd.bat') # Assuming successful execution
    0
    >>> task_func('nonexistent.bat') # If backup fails or file doesn't exist
    -1
    """

instruct prompt

Backs up a specified file from a predefined directory to a backup directory and executes it as a subprocess.
The function should output with:
    int: The exit code of the subprocess, or -1 if the backup process fails.
You should write self-contained code starting with:

Code

import subprocess
import os
import shutil
import sys
# Constants
DIRECTORY = 'c:\Program Files\VMware\VMware Server'
BACKUP_DIRECTORY = 'c:\Program Files\VMware\VMware Server\Backup'
def task_func(filename):

code prompt

Code

import subprocess
import os
import shutil
import sys
# Constants
DIRECTORY = 'c:\Program Files\VMware\VMware Server'
BACKUP_DIRECTORY = 'c:\Program Files\VMware\VMware Server\Backup'
def task_func(filename):

entry point

task_func

libs

  • subprocess
  • shutil
  • os
  • sys

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