Пример #1
0
    def run(cmd_class, parse_config=True, args_start_loc=2):
        """

        Arguments:
            args_start_loc (int): where the arguments this command should use start
        """

        try:
            runtime_git = GitWrapper()

            if parse_config:
                runtime_config = Config(Runtime.conf_file_path(runtime_git.git_dir))
            else:
                runtime_config = ConfigI()

            args = sys.argv[args_start_loc:]

            # To make argparse print "usage: dvc cmd" instead of "usage: dvc"
            sys.argv[0] = sys.argv[0] + " " + sys.argv[1]

            instance = cmd_class(Settings(args, runtime_git, runtime_config))
            sys.exit(instance.run())
        except DvcException as e:
            Logger.error(e)
            sys.exit(1)
Пример #2
0
    def run(self):
        target = self.args.target
        if not target:
            target = self.project.config._config['Global'].get('Target', '')
            self.project.logger.debug(u'Set show workflow target as {}'.format(target))

        wf = GitWrapper.get_all_commits(target, self.settings)
        wf.build_graph(self.args.dvc_commits,
                       self.args.all_commits,
                       self.args.max_commits)
        return 0
Пример #3
0
    def _validate_file_states(repo_change):
        error = False
        for data_item in repo_change.removed_data_items:
            Logger.error('Error: file "{}" was removed'.format(data_item.data.relative))
            error = True

        for file in GitWrapper.abs_paths_to_relative(repo_change.externally_created_files):
            Logger.error('Error: file "{}" was created outside of the data directory'.format(file))
            error = True

        return not error
Пример #4
0
    def _init_file_states(self):
        statuses = GitWrapper.git_file_statuses()

        for status, file in statuses:
            file_path = os.path.join(self._settings.git.git_dir_abs, file)

            if not os.path.isdir(file_path):
                self._add_stated_data_item(status, file_path)
            else:
                files = []
                self.get_all_files_from_dir(file_path, files)
                state = StatedDataItem.STATUS_UNTRACKED + StatedDataItem.STATUS_UNTRACKED
                for f in files:
                    self._add_stated_data_item(state, f)
        pass
Пример #5
0
    def setUp(self):
        self.test_dir = System.get_long_path(tempfile.mkdtemp())
        self._old_curr_dir_abs = System.realpath(os.curdir)

        self.tearDown()
        os.mkdir(self.test_dir)
        os.chdir(self.test_dir)
        os.mkdir('data')
        os.mkdir('cache')
        os.mkdir('state')

        self.init_git_repo()
        self.git = GitWrapper()

        self.config = ConfigI('data', 'cache', 'state')
        self.path_factory = PathFactory(self.git, self.config)

        self.settings = Settings([], self.git, self.config)
        pass
Пример #6
0
    def setUp(self):
        self.test_dir = System.get_long_path(tempfile.mkdtemp())
        self._old_curr_dir_abs = System.realpath(os.curdir)

        self.tearDown()
        os.mkdir(self.test_dir)
        os.chdir(self.test_dir)
        os.mkdir('data')
        os.mkdir(ConfigI.CONFIG_DIR)
        os.mkdir(os.path.join(ConfigI.CONFIG_DIR, ConfigI.CACHE_DIR_NAME))
        os.mkdir(os.path.join(ConfigI.CONFIG_DIR, ConfigI.STATE_DIR_NAME))

        self.init_git_repo()
        self.git = GitWrapper()

        self.config = ConfigI('data')
        self.path_factory = PathFactory(self.git, self.config)

        self.settings = Settings('run cmd', self.git, self.config)
        pass
Пример #7
0
    def __init__(self, argv=None, git=None, config=None):
        self._args = None
        args = None

        if argv != None and len(argv) != 0:
            args = parse_args(argv)
            self._args = argv[2:]

        if git == None:
            git = GitWrapper()

        if config == None:
            if args != None and args.cmd != 'init':
                config = Config()
            else:
                config = ConfigI()

        self._git = git
        self._config = config
        self._path_factory = PathFactory(git, config)
        self._parsed_args = args
Пример #8
0
    def __init__(self, argv=None, git=None, config=None):
        self._args = None
        args = None

        if argv is not None and len(argv) != 0:
            args = parse_args(argv)
            self._args = argv[2:]

        if git is None:
            git = GitWrapper()

        if config is None:
            if args is not None and args.cmd != 'init':
                config = Config()
            else:
                config = ConfigI()

        self._git = git
        self._config = config
        self._path_factory = PathFactory(self)
        self._parsed_args = args
        self._cloud = DataCloud(self)