Exemple #1
0
def _interactive_update():
    from core.update_handling import registry
    from core.dialogs.update_dialog import UpdateDialog, qapplication
    from core.config import global_config

    registry = setup_updaters()

    def script(add_info_line, add_update_info):
        exchange_folder = global_config.get("exchange_folder")
        if exchange_folder:
            yield add_info_line, ("configured exchange folder is %s" % exchange_folder,)
        else:
            yield add_info_line, ("no exchange folder configured. use emzed.config.edit() to "
                                    "configure an exchange folder",)

        for name, updater in registry.updaters.items():

            flag, msg = updater.check_for_newer_version_on_exchange_folder()
            if flag is True:
                flag, msg = updater.fetch_update_from_exchange_folder()
                if flag:
                    yield add_info_line, ("%s: copied update from exchange folder" % name,)
                elif flag is None:
                    pass
                else:
                    yield add_info_line, ("%s: failed to update from exchange folder: %s" % (name,
                        msg),)
            elif flag is False:
                yield add_info_line, ("%s: local version still up to date" % name,)
            elif flag is None:
                if msg is None:
                    pass
                else:
                    yield add_info_line, ("%s: %s" % (name, msg),)

            if updater.offer_update_lookup():
                id_, ts, info, offer_update = updater.query_update_info()
                yield add_update_info, (name, info, offer_update)
            else:
                yield add_update_info, (name, "no update lookup today", False)

    app = qapplication()
    dlg = UpdateDialog(script)
    dlg.exec_()

    at_least_one_sucess = False
    for id_ in dlg.get_updates_to_run():
        updater = registry.get(id_)
        ok, msg = updater.do_update(None)
        if not ok:
            print
            print "UPDATE FAILED:", msg
            print
        else:
            at_least_one_sucess = True
    if at_least_one_sucess:
        import emzed.gui
        emzed.gui.showInformation("please restart emzed to activate updates")
Exemple #2
0
def run(id_):
    registry = setup_updaters()
    updater = registry.get(id_)
    if updater is None:
        raise Exception("no updater with id %r registered" % id_)
    ok, msg = updater.do_update()
    if not ok:
        print
        print "UPDATE FAILED:", msg
        print
Exemple #3
0
def run(id_):
    registry = setup_updaters()
    updater = registry.get(id_)
    if updater is None:
        raise Exception("no updater with id %r registered" % id_)
    ok, msg = updater.do_update()
    if not ok:
        print
        print "UPDATE FAILED:", msg
        print
Exemple #4
0
def get(id_):
    registry = setup_updaters()
    updater = registry.get(id_)
    return updater
Exemple #5
0
def reset(id_):
    registry = setup_updaters()
    updater = registry.get(id_)
    if updater is None:
        raise Exception("no updater with id %r registered" % id_)
    updater.remove_ts_file()
Exemple #6
0
def _interactive_update():
    from core.update_handling import registry
    from core.dialogs.update_dialog import UpdateDialog, qapplication
    from core.config import global_config

    registry = setup_updaters()

    def script(add_info_line, add_update_info):
        """
        add_info_line and add_upate_info are two tokens to communicate with the GUI.
        Actually both are methods.
        For calling the methods we yield a pair where the first entry is the method and
        the second is a tuple of arguments.

        This method allows async updating the dialog without blocking the GUI until all
        update info is retrieved.

        add_info_line adds text to the upper text field in the dialog and add_update_info
        adds a row to the table below this text field.
        """

        exchange_folder = global_config.get("exchange_folder")
        if exchange_folder:
            yield add_info_line, ("configured exchange folder is %s" %
                                  exchange_folder, )
        else:
            yield add_info_line, (
                "no exchange folder configured. use emzed.config.edit() to "
                "configure an exchange folder", )

        for name, updater in registry.updaters.items():

            flag, msg = updater.check_for_newer_version_on_exchange_folder()
            if flag is True:
                flag, msg = updater.fetch_update_from_exchange_folder()
                if flag:
                    yield add_info_line, (
                        "%s: copied update from exchange folder" % name, )
                elif flag is None:
                    pass
                else:
                    yield add_info_line, (
                        "%s: failed to update from exchange folder: %s" %
                        (name, msg), )
            elif flag is False:
                yield add_info_line, ("%s: local version still up to date" %
                                      name, )
            elif flag is None:
                if msg is None:
                    pass
                else:
                    yield add_info_line, ("%s: %s" % (name, msg), )

            if updater.offer_update_lookup():
                id_, ts, info, offer_update = updater.query_update_info()
                if "\n" in info:  # multiline info
                    yield add_info_line, ("\n%s" % info, )
                yield add_update_info, (name, info, offer_update)
            else:
                yield add_update_info, (name, "no update lookup today", False)

    app = qapplication()
    dlg = UpdateDialog(script)
    dlg.exec_()

    at_least_one_sucess = False
    for id_ in dlg.get_updates_to_run():
        updater = registry.get(id_)
        ok, msg = updater.do_update(None)
        if not ok:
            print
            print "UPDATE FAILED:", msg
            print
        else:
            at_least_one_sucess = True
    if at_least_one_sucess:
        import emzed.gui
        emzed.gui.showInformation("please restart emzed to activate updates")
Exemple #7
0
def get(id_):
    registry = setup_updaters()
    updater = registry.get(id_)
    return updater
Exemple #8
0
def reset(id_):
    registry = setup_updaters()
    updater = registry.get(id_)
    if updater is None:
        raise Exception("no updater with id %r registered" % id_)
    updater.remove_ts_file()
Exemple #9
0
def _interactive_update():
    from core.update_handling import registry  
    from core.dialogs.update_dialog import UpdateDialog, qapplication
    from core.config import global_config

    registry = setup_updaters()

    def script(add_info_line, add_update_info):
        """
        add_info_line and add_upate_info are two tokens to communicate with the GUI.
        Actually both are methods.
        For calling the methods we yield a pair where the first entry is the method and
        the second is a tuple of arguments.

        This method allows async updating the dialog without blocking the GUI until all
        update info is retrieved.

        add_info_line adds text to the upper text field in the dialog and add_update_info
        adds a row to the table below this text field.
        """

        exchange_folder = global_config.get("exchange_folder")
        if exchange_folder:
            yield add_info_line, ("configured exchange folder is %s" % exchange_folder,)
        else:
            yield add_info_line, ("no exchange folder configured. use emzed.config.edit() to "
                                  "configure an exchange folder",)

        for name, updater in registry.updaters.items():

            flag, msg = updater.check_for_newer_version_on_exchange_folder()
            if flag is True:
                flag, msg = updater.fetch_update_from_exchange_folder()
                if flag:
                    yield add_info_line, ("%s: copied update from exchange folder" % name,)
                elif flag is None:
                    pass
                else:
                    yield add_info_line, ("%s: failed to update from exchange folder: %s" % (name,
                                                                                             msg),)
            elif flag is False:
                yield add_info_line, ("%s: local version still up to date" % name,)
            elif flag is None:
                if msg is None:
                    pass
                else:
                    yield add_info_line, ("%s: %s" % (name, msg),)

            if updater.offer_update_lookup():
                id_, ts, info, offer_update = updater.query_update_info()
                if "\n" in info:  # multiline info
                    yield add_info_line, ("\n%s" % info,)
                yield add_update_info, (name, info, offer_update)
            else:
                yield add_update_info, (name, "no update lookup today", False)

    app = qapplication()
    dlg = UpdateDialog(script)
    dlg.exec_()

    at_least_one_sucess = False
    for id_ in dlg.get_updates_to_run():
        updater = registry.get(id_)
        ok, msg = updater.do_update(None)
        if not ok:
            print
            print "UPDATE FAILED:", msg
            print
        else:
            at_least_one_sucess = True
    if at_least_one_sucess:
        import emzed.gui
        emzed.gui.showInformation("please restart emzed to activate updates")