def create_project(self, directory_path, make_directory=False, name=None, icon=None, description=None): """Create a project skeleton in the given directory. Returns a Project instance even if creation fails or the directory doesn't exist, but in those cases the ``problems`` attribute of the Project will describe the problem. If the anaconda-project.yml already exists, this simply loads it. This will not prepare the project (create environments, etc.), use the separate prepare calls if you want to do that. Args: directory_path (str): directory to contain anaconda-project.yml make_directory (bool): True to create the directory if it doesn't exist name (str): Name of the new project or None to leave unset (uses directory name) icon (str): Icon for the new project or None to leave unset (uses no icon) description (str): Description for the new project or None to leave unset Returns: a Project instance """ return project_ops.create(directory_path=directory_path, make_directory=make_directory, name=name, icon=icon, description=description)
def init_command(project_dir, assume_yes): """Initialize a new project. Returns: Exit code (0 on success) """ # we don't want False right now because either you specify # --yes or we go with the default in project_ops.create # (depends on whether project file already exists). assert assume_yes is None or assume_yes is True if not os.path.exists(project_dir): if assume_yes: make_directory = True else: make_directory = console_ask_yes_or_no("Create directory '%s'?" % project_dir, default=False) else: make_directory = False project = project_ops.create(project_dir, make_directory=make_directory, fix_problems=assume_yes) if print_project_problems(project): return 1 else: print("Project configuration is in %s" % project.project_file.filename) return 0
def check(dirname): with fake_server(monkeypatch, expected_basename='foo.zip'): project = project_ops.create(dirname) archivefile = os.path.join(dirname, "tmp.zip") project_ops.archive(project, archivefile) status = _upload(project, archivefile, "foo.zip", site='unit_test') assert status
def check(dirname): with fake_server(monkeypatch, expected_basename='foo.zip', fail_these=('stage', )): project = project_ops.create(dirname) archivefile = os.path.join(dirname, "tmp.zip") project_ops.archive(project, archivefile) status = _upload(project, archivefile, "foo.zip", site='unit_test') assert not status assert '501' in status.errors[0]
def upload_project(project_path, args, username): try: from anaconda_project import project_ops except ImportError: raise errors.BinstarError("To upload projects such as {}, install the anaconda-project package.".format(project_path)) from anaconda_project import project if os.path.exists(project_path) and not os.path.isdir(project_path): # make the single file into a temporary project directory with (_TmpDir(prefix="anaconda_upload_")) as dirname: shutil.copy(project_path, dirname) basename_no_extension = os.path.splitext(os.path.basename(project_path))[0] project = project_ops.create(dirname, name=basename_no_extension) return _real_upload_project(project, args, username) else: project = project.Project(directory_path=project_path) return _real_upload_project(project, args, username)
def upload_project(project_path, args, username): try: from anaconda_project import project_ops except ImportError: raise errors.BinstarError("To upload projects such as {}, install the anaconda-project package.".format(project_path)) from anaconda_project import project if os.path.exists(project_path) and not os.path.isdir(project_path): # make the single file into a temporary project directory with (_TmpDir(prefix="anaconda_upload_")) as dirname: shutil.copy(project_path, dirname) basename_no_extension = os.path.splitext(os.path.basename(project_path))[0] project = project_ops.create(dirname, name=basename_no_extension) return _real_upload_project(project, args, username) else: project = project.Project(directory_path=project_path) return _real_upload_project(project, args, username)