Esempio n. 1
0
    def _action(self):
        from kano_updater.commands.download import download

        Gtk.main_quit()

        while Gtk.events_pending():
            Gtk.main_iteration()

        make_low_prio()
        download()
Esempio n. 2
0
def install(progress=None, gui=True):
    progress.split(
        Phase('checks', _('Checking system'), 1, is_main=True),
        Phase('download', _("Downloading updates"), 39, is_main=True),
        Phase('install', _("Installing updates"), 60, is_main=True),
    )

    progress.start('checks')
    status = UpdaterStatus.get_instance()
    logger.debug("Installing update (updater state = {})".format(status.state))

    if not progress:
        progress = DummyProgress()

    priority = Priority.NONE

    if status.is_urgent:
        priority = Priority.URGENT

    run_cmd('sudo kano-empty-trash')
    enough_space, space_msg = check_disk_space(priority)
    if not enough_space:
        logger.error(space_msg)
        progress.abort(_(space_msg))
        RCState.get_instance().rc = RC.NOT_ENOUGH_SPACE
        return False

    logger.debug("Downloading any new updates that might be available.")
    progress.start('download')
    if not download(progress):
        logger.error("Downloading updates failed, cannot update.")
        return False

    progress.start('install')

    logger.debug("Installing with priority {}".format(priority.priority))

    try:
        return do_install(progress, status, priority=priority)
    except Relaunch as err:
        raise
    except Exception as err:
        # Reset the state back to the previous one, so the updater
        # doesn't get stuck in 'installing' forever.
        status.state = UpdaterStatus.UPDATES_DOWNLOADED
        status.save()

        logger.error(err.message)
        progress.fail(err.message)
        RCState.get_instance().rc = RC.UNEXPECTED_ERROR
        return False
Esempio n. 3
0
def install(progress=None):
    status = UpdaterStatus.get_instance()
    logger.debug("Installing update (updater state = {})".format(status.state))

    if not progress:
        progress = DummyProgress()

    if status.state == UpdaterStatus.INSTALLING_UPDATES:
        msg = 'The install is already running'
        logger.warn(msg)
        progress.abort(_(msg))
        return False
    elif status.state != UpdaterStatus.UPDATES_DOWNLOADED:
        logger.debug('Updates weren\'t downloaded, running download first.')
        progress.split(
            Phase('download', _('Downloading updates'), 40, is_main=True),
            Phase('install', _('Installing updates'), 60, is_main=True),
        )

        progress.start('download')
        if not download(progress):
            logger.error('Downloading updates failed, cannot update.')
            return False

        progress.start('install')

    try:
        return do_install(progress, status)
    except Relaunch as err:
        raise
    except Exception as err:
        # Reset the state back to the previous one, so the updater
        # doesn't get stuck in 'installing' forever.
        status.state = UpdaterStatus.UPDATES_DOWNLOADED
        status.save()

        logger.error(err.message)
        progress.fail(err.message)

        return False
Esempio n. 4
0
def install(progress=None, gui=True):
    progress.split(
        Phase(
            'checks',
            _('Checking system'),
            1,
            is_main=True
        ),
        Phase(
            'download',
            _("Downloading updates"),
            39,
            is_main=True
        ),
        Phase(
            'install',
            _("Installing updates"),
            60,
            is_main=True
        ),
    )

    progress.start('checks')
    status = UpdaterStatus.get_instance()
    logger.info("Installing update (updater state = {})".format(status.state))

    if not progress:
        progress = DummyProgress()

    priority = Priority.NONE

    if status.is_urgent:
        priority = Priority.URGENT

    run_cmd('sudo kano-empty-trash')
    enough_space, space_msg = check_disk_space(priority)
    if not enough_space:
        logger.error(space_msg)
        progress.abort(_(space_msg))
        RCState.get_instance().rc = RC.NOT_ENOUGH_SPACE
        return False

    logger.info("Downloading any new updates that might be available.")
    progress.start('download')
    if not download(progress):
        logger.error("Downloading updates failed, cannot update.")
        return False

    progress.start('install')

    logger.info("Installing with priority {}".format(priority.priority))

    try:
        return do_install(progress, status, priority=priority)
    except Relaunch as err:
        raise
    except Exception as err:
        # Reset the state back to the previous one, so the updater
        # doesn't get stuck in 'installing' forever.
        status.state = UpdaterStatus.UPDATES_DOWNLOADED
        status.save()

        logger.error(err.message)
        progress.fail(err.message)
        RCState.get_instance().rc = RC.UNEXPECTED_ERROR
        return False
Esempio n. 5
0
def install(progress=None, gui=True):
    status = UpdaterStatus.get_instance()
    logger.debug("Installing update (updater state = {})".format(status.state))

    if not progress:
        progress = DummyProgress()

    #
    run_cmd('sudo kano-empty-trash')

    # Check for available disk space before updating
    # We require at least 1GB of space for the update to proceed
    # TODO: Take this value from apt
    mb_free = get_free_space()
    if mb_free < 1536:
        err_msg = N_("Only {}MB free, at least 1.5GB is needed.".format(mb_free))
        logger.warn(err_msg)
        answer = progress.prompt(
            _("Not enough space to update!"),
            _("But I can make more room if you'd like?"),
            [_("OK"), _("CANCEL")]
        )

        if answer == _("OK"):
            run_cmd('sudo expand-rootfs')

            status.state = UpdaterStatus.INSTALLING_UPDATES
            status.save()

            os.system('sudo systemctl reboot')

        else:
            logger.error(err_msg)
            progress.fail(_(err_msg))

        return False

    if (status.state == UpdaterStatus.INSTALLING_UPDATES or
        status.state == UpdaterStatus.INSTALLING_INDEPENDENT):
        msg = "The install is already running"
        logger.warn(msg)
        progress.abort(msg)
        return False
    elif status.state != UpdaterStatus.UPDATES_DOWNLOADED:
        logger.debug("Updates weren't downloaded, running download first.")
        progress.split(
            Phase(
                'download',
                _("Downloading updates"),
                40,
                is_main=True
            ),
            Phase(
                'install',
                _("Installing updates"),
                60,
                is_main=True
            ),
        )

        progress.start('download')
        if not download(progress):
            logger.error("Downloading updates failed, cannot update.")
            return False

        progress.start('install')

    priority = Priority.NONE

    if status.is_urgent:
        priority = Priority.URGENT

    logger.debug("Installing with priority {}".format(priority.priority))

    try:
        return do_install(progress, status, priority=priority)
    except Relaunch as err:
        raise
    except Exception as err:
        # Reset the state back to the previous one, so the updater
        # doesn't get stuck in 'installing' forever.
        status.state = UpdaterStatus.UPDATES_DOWNLOADED
        status.save()

        logger.error(err.message)
        progress.fail(err.message)

        return False
Esempio n. 6
0
def install(progress=None, gui=True):
    status = UpdaterStatus.get_instance()
    logger.debug("Installing update (updater state = {})".format(status.state))

    if not progress:
        progress = DummyProgress()

    #
    run_cmd('sudo kano-empty-trash')

    # Check for available disk space before updating
    # We require at least 1GB of space for the update to proceed
    # TODO: Take this value from apt
    mb_free = get_free_space()
    if mb_free < 1536:
        err_msg = N_(
            "Only {}MB free, at least 1.5GB is needed.".format(mb_free))
        logger.warn(err_msg)
        answer = progress.prompt(_("Not enough space to update!"),
                                 _("But I can make more room if you'd like?"),
                                 [_("OK"), _("CANCEL")])

        if answer == _("OK"):
            run_cmd('sudo expand-rootfs')

            status.state = UpdaterStatus.INSTALLING_UPDATES
            status.save()

            os.system('sudo systemctl reboot')

        else:
            logger.error(err_msg)
            progress.fail(_(err_msg))

        return False

    if (status.state == UpdaterStatus.INSTALLING_UPDATES
            or status.state == UpdaterStatus.INSTALLING_INDEPENDENT):
        msg = "The install is already running"
        logger.warn(msg)
        progress.abort(msg)
        return False
    elif status.state != UpdaterStatus.UPDATES_DOWNLOADED:
        logger.debug("Updates weren't downloaded, running download first.")
        progress.split(
            Phase('download', _("Downloading updates"), 40, is_main=True),
            Phase('install', _("Installing updates"), 60, is_main=True),
        )

        progress.start('download')
        if not download(progress):
            logger.error("Downloading updates failed, cannot update.")
            return False

        progress.start('install')

    priority = Priority.NONE

    if status.is_urgent:
        priority = Priority.URGENT

    logger.debug("Installing with priority {}".format(priority.priority))

    try:
        return do_install(progress, status, priority=priority)
    except Relaunch as err:
        raise
    except Exception as err:
        # Reset the state back to the previous one, so the updater
        # doesn't get stuck in 'installing' forever.
        status.state = UpdaterStatus.UPDATES_DOWNLOADED
        status.save()

        logger.error(err.message)
        progress.fail(err.message)

        return False
Esempio n. 7
0
def install(progress=None, gui=True):
    status = UpdaterStatus.get_instance()
    logger.debug("Installing update (updater state = {})".format(status.state))

    if not progress:
        progress = DummyProgress()

    #
    run_cmd('sudo kano-empty-trash')

    # Check for available disk space before updating
    # We require at least 1GB of space for the update to proceed
    # TODO: Take this value from apt
    mb_free = get_free_space()
    if mb_free < 1024:
        err_msg = _("Only {}MB free, at least 1GB is needed.".format(mb_free))
        logger.warn(err_msg)
        answer = progress.prompt(
            'Feeling full!',
            'My brain is feeling a bit full, but I can make some more '
            'room if you\'d like?',
            ['OK', 'CANCEL']
        )

        if answer.lower() == 'ok':
            run_cmd('sudo expand-rootfs')

            status.state = UpdaterStatus.INSTALLING_UPDATES
            status.save()

            os.system('sudo reboot')

        else:
            logger.error(err_msg)
            progress.fail(err_msg)

        return False

    if status.state == UpdaterStatus.INSTALLING_UPDATES:
        msg = 'The install is already running'
        logger.warn(msg)
        progress.abort(_(msg))
        return False
    elif status.state != UpdaterStatus.UPDATES_DOWNLOADED:
        logger.debug('Updates weren\'t downloaded, running download first.')
        progress.split(
            Phase(
                'download',
                _('Downloading updates'),
                40,
                is_main=True
            ),
            Phase(
                'install',
                _('Installing updates'),
                60,
                is_main=True
            ),
        )

        progress.start('download')
        if not download(progress):
            logger.error('Downloading updates failed, cannot update.')
            return False

        progress.start('install')

    priority = Priority.NONE

    if status.is_urgent:
        priority = Priority.URGENT

    logger.debug('Installing with priority {}'.format(priority.priority))

    try:
        return do_install(progress, status, priority=priority)
    except Relaunch as err:
        raise
    except Exception as err:
        # Reset the state back to the previous one, so the updater
        # doesn't get stuck in 'installing' forever.
        status.state = UpdaterStatus.UPDATES_DOWNLOADED
        status.save()

        logger.error(err.message)
        progress.fail(err.message)

        return False