Beispiel #1
0
    def execute(self, args):
        logger = logging.getLogger(__name__)
        if args.workspace_subcommand is None:
            self.parser.print_help()
            return None

        color = Color()
        if (args.workspace_subcommand == "add"):
            ws_name = slashes2dash(args.name)
            self.ws.add(ws_name, args.path)
            logger.info(color.colored(
                "Workspace `%s` successfuly added" % ws_name, "green"))
        elif (args.workspace_subcommand == "remove"):
            ws_name = slashes2dash(args.name)
            self.ws.remove(ws_name)
            logger.info(color.colored(
                "Workspace `%s` successfuly removed" % ws_name, "green"))
        elif (args.workspace_subcommand == "list"):
            table = PrettyTable(["Name", "Path"])
            table.align["Name"] = "l"
            table.align["Path"] = "l"
            for key, ws in sorted(self.ws.list().items()):
                table.add_row([key, ws["path"]])

            logger.info(table)
Beispiel #2
0
 def print_update(self, repo_name, repo_path):
     """Print repository update."""
     color = Color()
     self.logger.info(color.colored(
         "=> [%s] %s" % (repo_name, repo_path), "green"))
     try:
         repo = Repository(repo_path)
         repo.update()
     except RepositoryError as e:
         self.logger.error(e)
         pass
     print("\n")
Beispiel #3
0
 def print_status(self, repo_name, repo_path):
     """Print repository status."""
     color = Color()
     try:
         repo = Repository(repo_path)
         self.logger.info(color.colored(
             "=> [%s] %s" % (repo_name, repo_path), "green"))
         repo.status()
         self.logger.info("\n")
     except ValueError as e:
         self.logger.error(e)
         pass
Beispiel #4
0
    def show_workspace(self, name):
        """Show specific workspace."""
        if not self.workspace.exists(name):
            raise ValueError("Workspace `%s` doesn't exists." % name)

        color = Color()
        workspaces = self.workspace.list()

        self.logger.info("<== %s workspace ==>" % color.colored(name, "green"))
        self.logger.info("\tPath: %s" % workspaces[name]["path"])
        self.logger.info("\tNumber of repositories: %s"
                         % color.colored(
                             len(workspaces[name]["repositories"]),
                             "yellow"))

        repo_colored = color.colored("Repositories", "blue")
        path_colored = color.colored("Path", "blue")
        trepositories = PrettyTable(
            [repo_colored, path_colored, color.colored("+", "blue")])
        trepositories.align[repo_colored] = "l"
        trepositories.align[path_colored] = "l"

        for repo_name in workspaces[name]["repositories"]:
            fullname = "%s/%s" % (name, repo_name)
            fullpath = find_path(fullname, self.config)[fullname]
            try:
                repo = Repository(fullpath)
                repo_scm = repo.get_scm()
            except RepositoryAdapterNotFound:
                repo_scm = None
            trepositories.add_row(
                [color.colored(repo_name, "cyan"), fullpath, repo_scm])

        self.logger.info(trepositories)
Beispiel #5
0
    def sync(self, ws_name):
        """Synchronise workspace's repositories."""
        path = self.config["workspaces"][ws_name]["path"]
        repositories = self.config["workspaces"][ws_name]["repositories"]

        logger = logging.getLogger(__name__)
        color = Color()

        for r in os.listdir(path):
            try:
                repo = Repository(os.path.join(path, r))
            except RepositoryError:
                continue
            else:
                repositories[r] = repo.path

        for repo_name, path in repositories.items():
            logger.info(color.colored(
                " - %s" % repo_name, "blue"))

        self.config["workspaces"][ws_name]["repositories"]
        self.config.write()
Beispiel #6
0
    def sync(self, ws_name):
        """Synchronise workspace's repositories."""
        path = self.config["workspaces"][ws_name]["path"]
        repositories = self.config["workspaces"][ws_name]["repositories"]

        repo_list = {}

        for r in listdir(path):
            try:
                repo = Repository(join(path, r))
            except RepositoryError:
                continue
            else:
                repositories[r] = repo.path
                repo_list[r] = repo.path

        logger = logging.getLogger(__name__)
        color = Color()
        logger.info("Workspace `%s` synchronized" % ws_name)
        logger.info("Added %d repositories:" % len(repo_list))
        for repo_name, path in repo_list.items():
            logger.info(color.colored(
                " - %s" % repo_name, "blue"))