def METHOD_NAME(app, appmasterconfig, sharedir_roots=None):
    if sharedir_roots is None:
        sharedir_roots = ['']
    logger.debug("RTUTils master_sandbox_prepare")
    # catch errors from not preparing properly
    if not hasattr(stripProxy(app), 'is_prepared') or app.is_prepared is None:
        logger.warning('Application is not prepared properly')
        if hasattr(stripProxy(app), 'is_prepared'):
            logger.warning("app.is_prepared: %s" % str(app.is_prepared))
        import traceback
        traceback.print_stack()
        raise GangaException(None, 'Application not prepared properly')
    # Note EITHER the master inputsandbox OR the job.inputsandbox is added to
    # the subjob inputsandbox depending if the jobmasterconfig object is present
    # or not... Therefore combine the job.inputsandbox with appmasterconfig.
    job = stripProxy(app).getJobObject()
    # user added items from the interactive GPI
    from GangaCore.Utility.Config import getConfig
    if not getConfig('Output')['ForbidLegacyInput']:
        inputsandbox = job.inputsandbox[:]
    else:
        if len(job.inputsandbox) > 0:
            from GangaCore.GPIDev.Lib.Job import JobError
            raise JobError(
                "InputFiles have been requested but there are objects in the inputSandBox... Aborting Job Prepare!")
        for _f in job.inputfiles:
            if isinstance(_f, LocalFile):
                if not os.path.exists(os.path.join(_f.localDir, _f.namePattern)):
                    raise GangaFileError('Requested LocalFile %s does not exist' %
                                         (os.path.join(_f.localDir, _f.namePattern)))
            elif isinstance(_f, DiracFile):
                if not _f.getReplicas():
                    raise GangaFileError("DiracFile inputfile with LFN %s has no replicas" % _f.lfn)
        inputsandbox = []
        fileNames, tmpDir = getInputFilesPatterns(job)
        for filepattern in fileNames:
            inputsandbox.append(File(filepattern))
        if tmpDir:
            shutil.rmtree(tmpDir)
    if len(inputsandbox) > 100:
        logger.warning('InputSandbox exceeds maximum size (100) supported by the Dirac backend')
        raise GangaException(None, 'InputSandbox exceed maximum size')
    outputsandbox = getOutputSandboxPatterns(job)  # job.outputsandbox[:]
    # inputsandbox files stored in share_dir from prepare method
    sharedir_handler(app, sharedir_roots, inputsandbox)
    # Here add any sandbox files/data coming from the appmasterconfig
    # from master_configure. Catch the case where None is passed (as in tests)
    if appmasterconfig:
        inputsandbox += appmasterconfig.getSandboxFiles()
        outputsandbox += appmasterconfig.getOutputSandboxFiles()
    return unique(inputsandbox), unique(outputsandbox)