Ejemplo n.º 1
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'])
Ejemplo n.º 3
0
    def _before_cluster_sync(self):
        self.announce('Started scap: %s', self.arguments.message)

        # Validate php syntax of wmf-config and multiversion
        lint.check_valid_syntax(
            ['%(stage_dir)s/wmf-config' % self.config,
             '%(stage_dir)s/multiversion' % self.config],
            utils.cpus_for_jobs())
Ejemplo n.º 4
0
def test_check_valid_syntax__skip_dir_matching_name_predicate():
    """Make sure that we skip directories that look like php files"""
    with tempfile.NamedTemporaryFile(suffix=".php") as php_file:
        # Delete temp file and make it a dir
        f_name = php_file.name
        php_file.close()
        os.mkdir(f_name)
        lint.check_valid_syntax(f_name)
Ejemplo n.º 5
0
    def _before_cluster_sync(self):
        self.announce('Started scap: %s', self.arguments.message)

        # Validate php syntax of wmf-config and multiversion
        lint.check_valid_syntax([
            '%(stage_dir)s/wmf-config' % self.config,
            '%(stage_dir)s/multiversion' % self.config
        ], utils.cpus_for_jobs())
Ejemplo n.º 6
0
def test_check_valid_syntax__invalid_php_file_raise_exception():
    """Make sure we raise exceptions when passed bad PHP files"""
    with tempfile.NamedTemporaryFile(suffix=".php") as php_file:
        php_file.write(b'<?php blba')
        php_file.flush()
        with pytest.raises(CalledProcessError) as cpe:
            lint.check_valid_syntax(php_file.name)
        exc = cpe.value
        assert exc.returncode == 124, 'php -l command exited with status 255'
Ejemplo n.º 7
0
    def _before_cluster_sync(self):
        # assert file exists
        abspath = os.path.join(self.config['stage_dir'], self.arguments.file)
        if not os.path.exists(abspath):
            raise IOError(errno.ENOENT, 'File/directory not found', abspath)

        relpath = os.path.relpath(abspath, self.config['stage_dir'])
        if os.path.isdir(abspath):
            relpath = '%s/***' % relpath
        self.include = relpath

        # Notify when syncing a symlink.
        if os.path.islink(abspath):
            symlink_dest = os.path.realpath(abspath)
            self.get_logger().info("%s: syncing symlink, not its target [%s]",
                                   abspath, symlink_dest)
        else:
            lint.check_valid_syntax(abspath, utils.cpus_for_jobs())
Ejemplo n.º 8
0
    def _before_cluster_sync(self):
        # assert file exists
        abspath = os.path.join(
            self.config['stage_dir'], self.arguments.file)
        if not os.path.exists(abspath):
            raise IOError(errno.ENOENT, 'File/directory not found', abspath)

        relpath = os.path.relpath(abspath, self.config['stage_dir'])
        if os.path.isdir(abspath):
            relpath = '%s/***' % relpath
        self.include = relpath

        # Notify when syncing a symlink.
        if os.path.islink(abspath):
            symlink_dest = os.path.realpath(abspath)
            self.get_logger().info("%s: syncing symlink, not its target [%s]",
                                   abspath, symlink_dest)
        else:
            lint.check_valid_syntax(abspath, utils.cpus_for_jobs())