Example #1
0
    def __call__(self):
        """Run the checks
        """
        scm.tested_for_scms(('svn', 'gitsvn', 'git'), '.')
        if not os.path.exists('setup.py'):
            raise Exception('Could not find setup.py')
        if scm.has_local_changes('.'):
            output.error('You have local changes, please commit them first.',
                         exit=True)

        self.checks = []

        all_checks = []
        # get all checks from parser
        for option in self.parser.option_list:
            # get all options with a dest= starting with check_
            if option.dest and option.dest.startswith('check_'):
                opt_value = getattr(self.options, option.dest)
                short_name = option.dest[len('check_'):]
                if opt_value:
                    self.checks.append(short_name)
                all_checks.append(short_name)

        # if there are no checks activated by parementer, activate all
        if not len(self.checks):
            self.checks = all_checks

        # run the checks
        if 'setup' in self.checks:
            self.check_setup_py()
        if 'paster' in self.checks:
            self.check_paster_stuff()
        if 'description' in self.checks:
            self.check_description()
        if 'requires' in self.checks:
            self.check_requires()
        if 'zcml' in self.checks:
            self.check_zcml()
Example #2
0
 def analyse(self):
     output.part_title('Checking subversion project')
     if not scm.is_scm('.'):
         # without subversion or gitsvn it doesnt work...
         output.error('Current directory is not a repository of type svn, '
         'git-svn, git.',
                      exit=True)
     # update newest remote changes
     if scm.is_git('.') or scm.is_git_svn('.'):
         git.pull_changes('.')
         git.push_committed_changes('.')
     elif scm.is_subversion('.'):
         svn.update('.')
     # remote should be there
     if scm.is_git('.') and not scm.is_git_svn('.'):
         if not git.has_remote('origin'):
             output.error('There is no remote "origin", which is needd',
             exit=True)
     # run it at repo root
     if scm.is_subversion('.') or scm.is_git_svn('.'):
         root_svn = scm.get_package_root_url('.')
         if not svn.check_project_layout(root_svn, raise_exception=False,
         ask_for_creation=False):
             # we should have the folders trunk, tags, branches in the project
             output.error('Project does not have default layout with trunk, ' +\
                              'tags and branches. At least one folder is missing.',
                          exit=True)
         if not self.options.release_egg_only:
             here_url = scm.get_svn_url('.')
             here_root = scm.get_package_root_url('.')
             is_trunk = here_url == here_root +'/trunk'
             is_branch = '/'.join(here_url.split('/')[:-1]) == here_root + '/branches'
             if not is_trunk and not is_branch:
                 # command must be run at the "trunk" folder of a package
                 output.error('Please run this command at the root of the package ' +\
                                  '(trunk/branch folder)', exit=True)
     elif scm.is_git('.'):
         if not os.path.exists('.git'):
             output.error('Please run this command at the root of the package ' +\
                              'checkout', exit=True)
     # .. other checks
     if not os.path.isfile('setup.py'):
         # setup.py is required
         output.error('Could not find the file ./setup.py', exit=True)
     if not os.path.isfile('docs/HISTORY.txt'):
         # docs/HISTORY.txt is required
         output.error('Could not find the file ./docs/HISTORY.txt', exit=True)
     if os.path.isfile('setup.cfg'):
         # setup.cfg is not necessary, it should not be used since the development
         # stuff makes bad distribution versions
         output.error('setup.cfg should not be used anymore')
         if input.prompt_bool('Should I delete setup.cfg?'):
             scm.remove_files('setup.cfg')
             scm.commit_files('Removed setup.cfg', 'setup.cfg')
     version_file = os.path.join(scm.get_package_name('.').replace('.', '/'),
                                 'version.txt')
     if not os.path.isfile(version_file):
         # version.txt is required
         output.error('Could not find the file %s' % version_file, exit=True)
     # check MANIFEST.in
     self.check_manifest()
     # check subversion state
     if scm.has_local_changes('.'):
         output.error('You have local changes, please commit them first.',
                      exit=True)