Command for applying upgrades.
484591
def run():
    """"""
    logfilename = os.path.join(current_app.config['CFG_LOGDIR'],
                               'invenio_upgrader.log')
    upgrader = InvenioUpgrader()
    logger = upgrader.get_logger(logfilename=logfilename)

    try:
        upgrades = upgrader.get_upgrades()

        if not upgrades:
            logger.info("All upgrades have been applied.")
            return

        logger.info("Following upgrade(s) will be applied:")

        for u in upgrades:
            logger.info(" * %s (%s)" % (u.name, u.info))

        logger.info("Running pre-upgrade checks...")
        upgrader.pre_upgrade_checks(upgrades)

        logger.info("Calculating estimated upgrade time...")
        estimate = upgrader.human_estimate(upgrades)

        click.confirm(
            "You are going to upgrade your installation "
            "(estimated time: {0})!".format(estimate), abort=True)

        for u in upgrades:
            logger.info("Applying %s (%s)" % (u.name, u.info))
            upgrader.apply_upgrade(u)

        logger.info("Running post-upgrade checks...")
        upgrader.post_upgrade_checks(upgrades)

        if upgrader.has_warnings():
            logger.warning("Upgrade completed with %s warnings - please check "
                           "log-file for further information:\nless %s"
                           % (upgrader.get_warnings_count(), logfilename))
        else:
            logger.info("Upgrade completed successfully.")
    except RuntimeError as e:
        for msg in e.args:
            logger.error(unicode(msg))
        logger.info("Please check log file for further information:\n"
                    "less %s" % logfilename)
        click.Abort()
410553
def upgrade():
    """"""
    op.create_table(
        'accounts_role',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=80), nullable=True),
        sa.Column('description', sa.String(length=255), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('name')
    )
    op.create_table(
        'accounts_user',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('email', sa.String(length=255), nullable=True),
        sa.Column('password', sa.String(length=255), nullable=True),
        sa.Column('active', sa.Boolean(name='active'), nullable=True),
        sa.Column('confirmed_at', sa.DateTime(), nullable=True),
        sa.Column('last_login_at', sa.DateTime(), nullable=True),
        sa.Column('current_login_at', sa.DateTime(), nullable=True),
        sa.Column('last_login_ip',
                  sqlalchemy_utils.types.ip_address.IPAddressType(),
                  nullable=True),
        sa.Column('current_login_ip',
                  sqlalchemy_utils.types.ip_address.IPAddressType(),
                  nullable=True),
        sa.Column('login_count', sa.Integer(), nullable=True),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('email')
    )
    op.create_table(
        'accounts_user_session_activity',
        sa.Column('created', sa.DateTime(), nullable=False),
        sa.Column('updated', sa.DateTime(), nullable=False),
        sa.Column('sid_s', sa.String(length=255), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['user_id'], [u'accounts_user.id'],
            name='fk_accounts_session_activity_user_id',
        ),
        sa.PrimaryKeyConstraint('sid_s')
    )
    op.create_table(
        'accounts_userrole',
        sa.Column('user_id', sa.Integer(), nullable=True),
        sa.Column('role_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['role_id'], ['accounts_role.id'],
            name='fk_accounts_userrole_role_id',
        ),
        sa.ForeignKeyConstraint(
            ['user_id'], ['accounts_user.id'],
            name='fk_accounts_userrole_user_id',
        ),
    )
    with op.batch_alter_table('transaction') as batch_op:
        batch_op.add_column(sa.Column(
            'user_id',
            sa.Integer(),
            sa.ForeignKey('accounts_user.id'),
            nullable=True,
        ))
        batch_op.create_index(
            op.f('ix_transaction_user_id'), ['user_id'], unique=False
        )
448034
def release(path, repository):
    """"""
    upgrader = InvenioUpgrader()
    logger = upgrader.get_logger()

    try:
        endpoints = upgrader.find_endpoints()

        if not endpoints:
            logger.error("No upgrades found.")
            click.Abort()

        depends_on = []
        for repo, upgrades in endpoints.items():
            depends_on.extend(upgrades)

        return recipe(path,
                      repository=repository,
                      depends_on=depends_on,
                      release=True,
                      output_path=output_path)

    except RuntimeError as e:
        for msg in e.args:
            logger.error(unicode(msg))
        raise
1088956
def list_upgrades(refresh=True, **kwargs):  # pylint: disable=W0613
    '''
    
    '''
    if salt.utils.data.is_true(refresh):
        refresh_db()
    upgrades = {}
    lines = __salt__['cmd.run_stdout'](
        '/opt/csw/bin/pkgutil -A --parse').splitlines()
    for line in lines:
        comps = line.split('\t')
        if comps[2] == "SAME":
            continue
        if comps[2] == "not installed":
            continue
        upgrades[comps[0]] = comps[1]
    return upgrades
1371593
def upgrade():
    """"""
    with op.batch_alter_table('accounts_user_session_activity') as batch_op:
        batch_op.add_column(sa.Column('browser', sa.String(80), nullable=True))
        batch_op.add_column(
            sa.Column('browser_version', sa.String(30), nullable=True))
        batch_op.add_column(
            sa.Column('country', sa.String(3), nullable=True))
        batch_op.add_column(
            sa.Column('device', sa.String(80), nullable=True))
        batch_op.add_column(
            sa.Column('ip', sa.String(80), nullable=True))
        batch_op.add_column(
            sa.Column('os', sa.String(80), nullable=True))
1266675
def _do_upgrade(self):
        
        self.current.output['cmd'] = 'upgrade'
        self.current.output['user_id'] = self.current.user_id
        self.terminate_existing_login()
        self.current.user.bind_private_channel(self.current.session.sess_id)
        user_sess = UserSessionID(self.current.user_id)
        user_sess.set(self.current.session.sess_id)
        self.current.user.is_online(True)
        # Clean up the locale from session to allow it to be re-read from the user preferences after login
        for k in translation.DEFAULT_PREFS.keys():
            self.current.session[k] = ''
692889
def upgrade():
    """"""
    op.create_table(
        'collection',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('name', sa.String(length=255), nullable=False),
        sa.Column('dbquery', sa.Text(), nullable=True),
        sa.Column('rgt', sa.Integer(), nullable=False),
        sa.Column('lft', sa.Integer(), nullable=False),
        sa.Column('level', sa.Integer(), nullable=False),
        sa.Column('parent_id', sa.Integer(), nullable=True),
        sa.Column('tree_id', sa.Integer(), nullable=True),
        sa.ForeignKeyConstraint(
            ['parent_id'], ['collection.id'], ondelete='CASCADE'
        ),
        sa.PrimaryKeyConstraint('id')
    )
    op.create_index(
        'collection_level_idx', 'collection', ['level'], unique=False
    )
    op.create_index('collection_lft_idx', 'collection', ['lft'], unique=False)
    op.create_index('collection_rgt_idx', 'collection', ['rgt'], unique=False)
    op.create_index(
        op.f('ix_collection_name'), 'collection', ['name'], unique=True
    )
585647
def _get_upgradable(dist_upgrade=True, **kwargs):
    '''
    
    '''

    cmd = ['apt-get', '--just-print']
    if dist_upgrade:
        cmd.append('dist-upgrade')
    else:
        cmd.append('upgrade')
    try:
        cmd.extend(['-o', 'APT::Default-Release={0}'.format(kwargs['fromrepo'])])
    except KeyError:
        pass

    call = _call_apt(cmd)
    if call['retcode'] != 0:
        msg = 'Failed to get upgrades'
        for key in ('stderr', 'stdout'):
            if call[key]:
                msg += ': ' + call[key]
                break
        raise CommandExecutionError(msg)
    else:
        out = call['stdout']

    # rexp parses lines that look like the following:
    # Conf libxfont1 (1:1.4.5-1 Debian:testing [i386])
    rexp = re.compile('(?m)^Conf '
                      '([^ ]+) '          # Package name
                      r'\(([^ ]+)')       # Version
    keys = ['name', 'version']
    _get = lambda l, k: l[keys.index(k)]

    upgrades = rexp.findall(out)

    ret = {}
    for line in upgrades:
        name = _get(line, 'name')
        version_num = _get(line, 'version')
        ret[name] = version_num

    return ret
1088224
def upgrade_all(self):
        
        for pkg in self.installed_package_names:
            self.install(pkg, upgrade=True)
1327525
private void upgradeIfNeeded(File oldPidGenDir) throws IOException {
        if (oldPidGenDir != null && oldPidGenDir.isDirectory()) {
            String[] names = oldPidGenDir.list();
            Arrays.sort(names);
            if (names.length > 0) {
                BufferedReader in =
                        new BufferedReader(new InputStreamReader(new FileInputStream(new File(oldPidGenDir,
                                                                                              names[names.length - 1]))));
                String lastLine = null;
                String line;
                while ((line = in.readLine()) != null) {
                    lastLine = line;
                }
                in.close();
                if (lastLine != null) {
                    String[] parts = lastLine.split("|");
                    if (parts.length == 2) {
                        neverGeneratePID(parts[0]);
                    }
                }
            }
        }
    }
1256021
def __updatable():
    
    # Add argument for console
    parser = argparse.ArgumentParser()
    parser.add_argument('file', nargs='?', type=argparse.FileType(), default=None, help='Requirements file')
    args = parser.parse_args()

    # Get list of packages
    if args.file:
        packages = parse_requirements_list(args.file)
    else:
        packages = get_parsed_environment_package_list()

    # Output updates
    for package in packages:
        __list_package_updates(package['package'], package['version'])
1098090
def _upgrade(system_image, kickstart_image, issu, **kwargs):
    '''
    
    '''
    si = system_image
    ki = kickstart_image
    dev = 'bootflash'
    cmd = 'terminal dont-ask ; install all'

    if ki is None:
        logmsg = 'Upgrading device using combined system/kickstart image.'
        logmsg += '\nSystem Image: {}'.format(si)
        cmd = cmd + ' nxos {0}:{1}'.format(dev, si)
        if issu:
            cmd = cmd + ' non-disruptive'
    else:
        logmsg = 'Upgrading device using separate system/kickstart images.'
        logmsg += '\nSystem Image: {}'.format(si)
        logmsg += '\nKickstart Image: {}'.format(ki)
        if not issu:
            log.info('Attempting upgrade using force option')
            cmd = cmd + ' force'
        cmd = cmd + ' kickstart {0}:{1} system {0}:{2}'.format(dev, ki, si)

    if issu:
        logmsg += '\nIn Service Software Upgrade/Downgrade (non-disruptive) requested.'
    else:
        logmsg += '\nDisruptive Upgrade/Downgrade requested.'

    log.info(logmsg)
    log.info("Begin upgrade using command: '%s'", cmd)

    kwargs.update({'timeout': kwargs.get('timeout', 900)})
    error_pattern_list = ['Another install procedure may be in progress']
    kwargs.update({'error_pattern': error_pattern_list})

    # Begin Actual Upgrade
    try:
        upgrade_result = __salt__['nxos.sendline'](cmd, **kwargs)
    except CommandExecutionError as e:
        upgrade_result = ast.literal_eval(e.message)
    except NxosError as e:
        if re.search('Code: 500', e.message):
            upgrade_result = e.message
        else:
            upgrade_result = ast.literal_eval(e.message)
    return _parse_upgrade_data(upgrade_result)
323649
protected function preUpdateArtisanCommands()
    {
        collect(config('self-update.artisan_commands.pre_update'))->every(function ($commandParams, $commandKey) {
            Artisan::call($commandKey, $commandParams['params']);
        });
    }
441319
def upgrade_available(pkg,
                      bin_env=None,
                      user=None,
                      cwd=None):
    '''
    
    '''
    return pkg in list_upgrades(bin_env=bin_env, user=user, cwd=cwd)
492519
def upgrade_addons_operation(self, addons_state, mode=None):
        
        installed = set(a.name for a in addons_state
                        if a.state in ('installed', 'to upgrade'))

        base_mode = self._get_version_mode()
        addons_list = base_mode.upgrade_addons.copy()
        if mode:
            add_mode = self._get_version_mode(mode=mode)
            addons_list |= add_mode.upgrade_addons

        to_install = addons_list - installed
        to_upgrade = installed & addons_list

        return UpgradeAddonsOperation(self.options, to_install, to_upgrade)
830706
def do_upgrade(self):
        """"""
        sql = text('delete from upgrade where upgrade = :upgrade')
        for upgrade in self.legacy_upgrades:
            db.engine.execute(sql, upgrade=upgrade)
849106
def upgrade(config, revision, **kwargs):
    
    with alembic_lock(
        config.registry["sqlalchemy.engine"], config.alembic_config()
    ) as alembic_config:
        alembic.command.upgrade(alembic_config, revision, **kwargs)