Creates the working directory and the input files of the :class:`Task`.
        It does not overwrite files if they already exist.
196891
def build(self, *args, **kwargs):
        
        # Create dirs for input, output and tmp data.
        self.indir.makedirs()
        self.outdir.makedirs()
        self.tmpdir.makedirs()

        # Write files file and input file.
        if not self.files_file.exists:
            self.files_file.write(self.filesfile_string)

        self.input_file.write(self.make_input())
        self.manager.write_jobfile(self)
1004933
def add_task(self, fn, inputs=None, outputs=None):
        
        # self.tasks.append({'task': task, 'inputs': inputs, 'outputs': outputs})
        self.tasks.append(Task(fn, inputs, outputs))
        return self
1120027
private void setupFile() {
        if (!new File(directory).exists() && !new File(directory).mkdirs()) {
            try {
                throw new IOException("Unable to create output directory");
            } catch (IOException e) {
                log.info(e);
            }
        }
        if (!file.exists()) {
            try {
                if (!file.createNewFile()) {
                    throw new IOException("Unable to create output file");
                }
            } catch (IOException e) {
                log.error(e);
            }
        }
    }
854892
def create(cls, **kwargs):
        
        linkname = kwargs.setdefault('linkname', cls.clientclass.linkname_default)
        # Don't use setdefault b/c we don't want to build a JobArchive
        # Unless it is needed
        job_archive = kwargs.get('job_archive', None)
        if job_archive is None:
            job_archive = JobArchive.build_temp_job_archive()
            kwargs.setdefault('job_archive', job_archive)
        kwargs_client = dict(linkname=linkname,
                             link_prefix=kwargs.get('link_prefix', ''),
                             file_stage=kwargs.get('file_stage', None),
                             job_archive=job_archive)
        link = cls.clientclass.create(**kwargs_client)
        sg = cls(link, **kwargs)
        return sg
1252821
def create_tasks(self):
        
        roles = self.get_roles()

        if self.task_type in ["A", "D"]:
            instances = self.create_wf_instances(roles=roles)
            self.create_task_invitation(instances)

        elif self.task_type in ["C", "B"]:
            instances = self.create_wf_instances()
            self.create_task_invitation(instances, roles)
233043
def createWorkDir(baseDir,
                  projName,
                  expUUID,
                  expNames = [],
                  nanos    = True,
                  utc      = False):
	""""""
	
	#
	# First, ensure the project's top-level hierarchy, especially by-uuid/,
	# exists, so that the only possible failure is due to the creation of
	# one additional directory.
	#
	projDir    = os.path.join(baseDir, projName)
	byuuidDir  = os.path.join(projDir, "by-uuid")
	bytimeDir  = os.path.join(projDir, "by-time")
	bynameDir  = os.path.join(projDir, "by-name", *expNames)
	byuuidPath = os.path.join(byuuidDir, expUUID)
	os.makedirs(byuuidDir, mode=0o755, exist_ok=True)
	os.makedirs(bytimeDir, mode=0o755, exist_ok=True)
	os.makedirs(bynameDir, mode=0o755, exist_ok=True)
	
	#
	# Attempt the creation of the experiment workDir by its UUID. Record
	# whether we were the original creators.
	#
	try:
		preexisting = False
		os.makedirs(byuuidPath,
		            mode     = 0o755,
		            exist_ok = False)
	except FileExistsError:
		preexisting = True
	
	#
	# If we were the first to create this working directory, additionally
	# make symlinks pointing to it from the auxiliary directories.
	#
	if not preexisting:
		expTime     = iso8601timestamp(nanos=nanos, utc=utc)
		expTimeUUID = expTime+"-"+expUUID
		bytimePath  = os.path.join(bytimeDir, expTimeUUID)
		bynamePath  = os.path.join(bynameDir, expUUID)
		os.symlink(os.path.relpath(byuuidPath, bytimeDir), bytimePath, True)
		os.symlink(os.path.relpath(byuuidPath, bynameDir), bynamePath, True)
	
	#
	# Create handy .rsync-filter files.
	#
	with contextlib.suppress(OSError):
		with open(os.path.join(baseDir, ".rsync-filter"), "x") as f:
			f.write("#\n"
			        "# rsync filter rules.\n"
			        "#\n"
			        "# When the argument -F is given to rsync, the rules within will be obeyed.\n"
			        "#\n")
	
	with contextlib.suppress(OSError):
		with open(os.path.join(projDir, ".rsync-filter"), "x") as f:
			f.write("#\n"
			        "# rsync filter rules.\n"
			        "#\n"
			        "# When the argument -F is given to rsync, the rules within will be obeyed.\n"
			        "#\n")
	
	#
	# Return the constructed workDir.
	#
	return byuuidPath
463831
def setup():
    

    init_tasks()

    run_hook("before_setup")

    # Create shared folder
    env.run("mkdir -p %s" % (paths.get_shared_path()))
    env.run("chmod 755 %s" % (paths.get_shared_path()))

    # Create backup folder
    env.run("mkdir -p %s" % (paths.get_backup_path()))
    env.run("chmod 750 %s" % (paths.get_backup_path()))

    # Create uploads folder
    env.run("mkdir -p %s" % (paths.get_upload_path()))
    env.run("chmod 775 %s" % (paths.get_upload_path()))

    run_hook("setup")
    run_hook("after_setup")
1003319
def make_dir_structure(base_dir):
    

    def maybe_makedir(*args):

        p = join(base_dir, *args)

        if exists(p) and not isdir(p):
            raise IOError("File '{}' exists but is not a directory ".format(p))

        if not exists(p):
            makedirs(p)

    maybe_makedir(DOWNLOAD_DIR)
    maybe_makedir(PACKAGE_DIR)
    maybe_makedir(OLD_DIR)
391502
def add_folder_task(self, dir_name=None):
        ''''''
        folder_dialog = Gtk.FileChooserDialog(_('Choose Folders..'),
                self.app.window, Gtk.FileChooserAction.SELECT_FOLDER,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        folder_dialog.set_modal(True)
        folder_dialog.set_select_multiple(True)
        folder_dialog.set_default_response(Gtk.ResponseType.OK)
        folder_dialog.set_current_folder(Config.HOME_DIR)
        response = folder_dialog.run()
        if response != Gtk.ResponseType.OK:
            folder_dialog.destroy()
            return
        source_paths = folder_dialog.get_filenames()
        folder_dialog.destroy()
        if source_paths:
            self.upload_files(source_paths, dir_name)
1079659
def make_local_dirs(dl_dir, dl_inputs, keep_subdirs):
    

    # Make the local download dir if it doesn't exist
    if not os.path.isdir(dl_dir):
        os.makedirs(dl_dir)
        print('Created local base download directory: %s' % dl_dir)
    # Create all required local subdirectories
    # This must be out of dl_pb_file to
    # avoid clash in multiprocessing
    if keep_subdirs:
        dl_dirs = set([os.path.join(dl_dir, d[1]) for d in dl_inputs])
        for d in dl_dirs:
            if not os.path.isdir(d):
                os.makedirs(d)
    return
1003679
def taskdir(self):
        
        return os.path.join(self.BASE, self.TAG, self.task_family)
1003592
def add_files(self, files):
        
        for file in files:
            file.copy(project=self.id)
972299
def _create_data_files_directory(symlink=False):
        """"""
        current_directory = os.path.abspath(os.path.dirname(__file__))

        etc_kytos = os.path.join(BASE_ENV, ETC_KYTOS)

        if not os.path.exists(etc_kytos):
            os.makedirs(etc_kytos)

        src = os.path.join(current_directory, KYTOS_SKEL_PATH)
        dst = os.path.join(BASE_ENV, KYTOS_SKEL_PATH)

        if os.path.exists(dst):
            if not os.listdir(dst):
                # Path already exists but it's empty, so we'll populate it
                # We remove it first to avoid an exception from copytree
                os.rmdir(dst)
                shutil.copytree(src, dst)
        else:
            # It doesn't exist yet, so we should symlink or copy contents
            if symlink:
                os.symlink(src, dst)
            else:
                shutil.copytree(src, dst)
398981
def create_dirs(path):
    
    fname = os.path.basename(path)

    # if file name exists in path, skip the filename
    if fname.__contains__('.'):
        path = os.path.dirname(path)

    if not os.path.exists(path):
        os.makedirs(path)
320102
def parallel_worker(self, task_num):
        
        while True:
            base, path = self.unsearched.get()
            dirs = self.explore_path(task_num, (base, path))
            for newdir in dirs:
                self.unsearched.put(newdir)
            self.unsearched.task_done()
660537
def set_up_dirs(proc_name, output_dir=None, work_dir=None, log_dir=None):
    
    output_dir = safe_mkdir(adjust_path(output_dir or join(os.getcwd(), proc_name)), 'output_dir')
    debug('Saving results into ' + output_dir)

    work_dir = safe_mkdir(work_dir or join(output_dir, 'work'), 'working directory')
    info('Using work directory ' + work_dir)

    log_fpath = set_up_log(log_dir or safe_mkdir(join(work_dir, 'log')), proc_name + '.log')

    return output_dir, work_dir, log_fpath
105038
def _set_WorkingDir(self, path):
        
        self._curr_working_dir = path
        try:
            mkdir(self.WorkingDir)
        except OSError:
            # Directory already exists
            pass