Exemplo n.º 1
0
    def process(self):
        """Process the arguments, distribute the work. """

        # Load the config file, setup logging and read the arguments.
        super().process()

        #ready to go.
        #This is where we do what we need based on the config file and arguments.

        # Everything we need should be in self.ARGS. Except for our project
        # section. We can ask our super to merge the config section in as
        # soon as we know it's name.

        # You can raise errors this way or with an exception...
        if __doc__ is None:
            raise apperror("This program has not doc comment.")

        # Need some debug for understanding???? Here it is.
        #self.logger.info(self.ARGS)
        #self.logger.info(self.config)   #  Probably don't need this.
        #self.print_config()             #  Or this.

        # run our default functions for our subparsers.
        # It's either this, or process them all the hard way.
        # self.args.func() will farm out the arguments to each
        # subparser's default function.

        # surround it all with a try to handle errors nicely.
        if 'func' in self.args:
            try:
                self.args.func()
                return 0
            except Exception as e:
                self.logger.error(e)
                return 1
Exemplo n.º 2
0
    def make(self):
        """create the directory when we don't have a repo."""
        path = self.abs_project_path

        if os.path.isdir(path) or os.path.isfile(path):
            raise  apperror('Project directory exists: %s' % path)
        else:
            self.logger.info("making directory %s" % path)
            os.makedirs(path)
Exemplo n.º 3
0
    def clone(self):
        """ get the project from it's git repository."""
        # Going to need to check repository type if we want to support
        # something other than git.
        os.chdir(self.project_root)
        if self.repository == 'local':
            if os.path.isdir(self.local_repository):
                command = "git clone %s" % self.local_repository
            else:
                raise  apperror('Sorry, no repository for this project')
        else:
            command = "git clone %s" % self.repository

        command = ('%s %s' % (command, self.directory))
        self.cmd.run(command)
Exemplo n.º 4
0
 def find_working_project(self):
     if self.name is None:
         if (self.directory):
             os.chdir(os.path.join(self.project_root, self.directory))
         #find the top of the current project and get the name from
         # the projects rc file.  Set the project abs path while we are at it.
         self.find_project_root()
         if self.abs_project_path is not None:
             self.logger.debug("Found root %s" % self.abs_project_path)
             self.project_config = Project_config(self.abs_project_path)
             self.name = self.project_config.name
         else:
             raise apperror("This is not a valid project directory")
     else:
         self.abs_project_path = os.path.join(self.project_root, self.directory)