Example #1
0
    def confirm_if_flag_missing(self, flag, prompt, default=False, bail=None):
        """
        Get confirmation from the user if a specified cli flag was omitted.
        """

        if flag in self.arguments:
            return True
        if bail:
            bail = Exception(bail)
        utils.confirm(prompt, default, on_rejected=bail)
    def confirm_if_flag_missing(self, flag, prompt, default=False, bail=None):
        """
        Get confirmation from the user if a specified cli flag was omitted.
        """

        if flag in self.arguments:
            return True
        if bail:
            bail = Exception(bail)
        utils.confirm(prompt, default, on_rejected=bail)
Example #3
0
    def _execute_for_groups(self, stages):
        logger = self.get_logger()
        self.continue_all = False
        attempted_groups = []

        try:
            for name, group in self.deploy_groups.items():
                attempted_groups.append(group)
                self._execute_for_group(stages, group, prompt_user=True)

        except DeployGroupFailure as failure:
            logger.error(str(failure))

            if utils.confirm('Rollback all deployed groups?', default=True):
                # Rollback groups in reverse order
                for group in attempted_groups[::-1]:
                    self._execute_for_group([ROLLBACK],
                                            group,
                                            ignore_failure=True)

            return 1

        if self.arguments.dry_run:
            # don't finalize a dry-run
            return 0

        for group in attempted_groups:
            self._execute_for_group([FINALIZE], group, ignore_failure=True)

        return 0
Example #4
0
    def _execute_for_groups(self, stages):
        logger = self.get_logger()
        self.continue_all = False
        attempted_groups = []

        try:
            for name, group in self.deploy_groups.items():
                attempted_groups.append(group)
                self._execute_for_group(stages, group, prompt_user=True)

        except DeployGroupFailure as failure:
            logger.error(str(failure))

            if utils.confirm('Rollback all deployed groups?', default=True):
                # Rollback groups in reverse order
                for group in attempted_groups[::-1]:
                    self._execute_for_group([ROLLBACK], group,
                                            ignore_failure=True)

            return 1

        if self.arguments.dry_run:
            # don't finalize a dry-run
            return 0

        for group in attempted_groups:
            self._execute_for_group([FINALIZE], group, ignore_failure=True)

        return 0
Example #5
0
    def _before_cluster_sync(self):
        interwikifile = os.path.join(
            self.config['stage_dir'], self.arguments.file)
        if not os.path.exists(interwikifile):
            raise IOError(
                errno.ENOENT, 'File/directory not found', interwikifile)

        relpath = os.path.relpath(interwikifile, self.config['stage_dir'])
        self.include = relpath

        with open(interwikifile, 'w') as outfile:
            subprocess.check_call(
                ['/usr/local/bin/mwscript',
                 'extensions/WikimediaMaintenance/dumpInterwiki.php'],
                stdout=outfile
            )

        # This shouldn't happen, but let's be safe
        lint.check_valid_syntax(interwikifile)

        subprocess.check_call(['/usr/bin/git', 'add', interwikifile])
        subprocess.check_call(['/usr/bin/git', 'commit', '-q', '-m',
                               self.arguments.message])

        subprocess.check_call(['/usr/bin/git', 'push', '-q', 'origin',
                               'HEAD:refs/for/master%l=Code-Review+2'])

        if not utils.confirm('Has your change merged yet?'):
            subprocess.check_call(['/usr/bin/git', 'reset', '--hard',
                                   'origin/master'])
            raise RuntimeError('Aborting, you should not sync unmerged code')

        subprocess.check_call(['/usr/bin/git', 'pull', '-q'])
    def _before_cluster_sync(self):
        interwikifile = os.path.join(
            self.config['stage_dir'], self.arguments.file)
        if not os.path.exists(interwikifile):
            raise IOError(
                errno.ENOENT, 'File/directory not found', interwikifile)

        relpath = os.path.relpath(interwikifile, self.config['stage_dir'])
        self.include = relpath

        with open(interwikifile, 'w') as outfile:
            subprocess.check_call(
                ['/usr/local/bin/mwscript',
                 'extensions/WikimediaMaintenance/dumpInterwiki.php'],
                stdout=outfile
            )

        # This shouldn't happen, but let's be safe
        lint.check_valid_syntax(interwikifile)

        subprocess.check_call(['/usr/bin/git', 'add', interwikifile])
        subprocess.check_call(['/usr/bin/git', 'commit', '-q', '-m',
                               self.arguments.message])

        subprocess.check_call(['/usr/bin/git', 'push', '-q', 'origin',
                               'HEAD:refs/for/master%l=Code-Review+2'])

        if not utils.confirm('Has your change merged yet?'):
            subprocess.check_call(['/usr/bin/git', 'reset', '--hard',
                                   'origin/master'])
            raise RuntimeError('Aborting, you should not sync unmerged code')

        subprocess.check_call(['/usr/bin/git', 'pull', '-q'])
Example #7
0
    def main(self, *extra_args):
        # If we're running interactively then warn people: this is not the
        # command you're looking for.
        if not self.arguments.force and sys.stdout.isatty():
            if not utils.confirm(''.join([
                    ansi.esc(ansi.FG_RED, ansi.BRIGHT), '[WARNING] ',
                    ansi.reset(),
                    '"scap sync" rebuilds all l10n and syncs all files.\n',
                    'To deploy a a single file or directory ',
                    'use "scap sync-file" instead.\n\n',
                    'Continue running "scap sync"?'
            ])):
                print('Sync aborted by user...')
                return 0

        try:
            if any('canary_wait_time' in s for s in self.arguments.defines):
                raise ValueError('Canary wait time must be defined with '
                                 '-w or --canary-wait-time')
        except TypeError:
            pass

        wait = self.arguments.canary_wait_time
        if wait is not None:
            self.config['canary_wait_time'] = wait

        return super(ScapWorld, self).main(*extra_args)
Example #8
0
 def approve():
     logger.debug("Approval Message: %s", self.message)
     if utils.confirm('Vote +2 and submit?', True):
         reviewinput={
             "message": self.message,
             "labels": {
                 "Code-Review": "+2"
             },
             "comments": {},
             "drafts": "KEEP"
         }
         change.revision('review').post(data=reviewinput)
         submit()
 def approve():
     logger.debug("Approval Message: %s", self.message)
     if utils.confirm('Vote +2 and submit?', True):
         reviewinput = {
             "message": self.message,
             "labels": {
                 "Code-Review": "+2"
             },
             "comments": {},
             "drafts": "KEEP"
         }
         change.revision('review').post(data=reviewinput)
         submit()
 def submit():
     """Submit the change?"""
     if utils.confirm('Submit the change?', True):
         change.revision('submit').post()
Example #11
0
 def submit():
     """Submit the change?"""
     if utils.confirm('Submit the change?', True):
         change.revision('submit').post()