#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""enums - Enumerates for apt daemon dbus messages"""

__all__ = (
            #错误枚举
            "ERROR_OTHER_PROGRESS_OCCUPATION","ERROR_NETWORK_FAILED","ERROR_CANCELLED","ERROR_NOT_ROLLBAK_DEPLOYMENT",
            "ERROR_ORIGIN_IS_NONE","INSTALL_FAILED_FALG","INSTALL_SUCCESS_FLAG","INSTALL_DEFAULT_FLAG",
            # 方法
            "get_error_description_from_enum"
        )

import gettext
gettext.bindtextdomain('kylin-system-updater', '/usr/share/locale')
gettext.textdomain('kylin-system-updater')
_ = gettext.gettext

#系统更新的所有枚举
PRIORITY_UPGRADE_SUCCCESSED = "priority-upgrade-successed"
INSTALL_DEFAULT_FLAG = 'none'
INSTALL_FAILED_FALG = 'failed'
INSTALL_SUCCESS_FLAG = 'success'
#apt update阶段出现的错误解析





#通用错误
ERROR_PROGRAM_EXCEPTION = "#0000"
ERROR_OTHER_PROGRESS_OCCUPATION = "#0001"
ERROR_NETWORK_FAILED = "#0002"

#检查更新错误 1
ERROR_ORIGIN_IS_NONE = "#0100"


#下载错误 2
ERROR_CANCELLED = "#0200"

#部署错误 3
ERROR_NOT_ROLLBAK_DEPLOYMENT = "#0300"


GLIB_ERROR_NETWORK_FAILED = "While fetching mirrorlist"

_DESCS_ERROR = {
                    ERROR_OTHER_PROGRESS_OCCUPATION: _("Other tasks are being updated and upgraded, please try again later."),
                    ERROR_NETWORK_FAILED: _("Network anomaly, can't check for updates!"),
                    ERROR_CANCELLED: _("_Cancel Upgrade"),
                    ERROR_NOT_ROLLBAK_DEPLOYMENT: _("There is no way to rollback to the previous version, there is nothing to rollback."),
                    ERROR_ORIGIN_IS_NONE: _("Check for update exceptions! Please verify that the system deployment is complete.")

                }

def get_error_description_from_enum(enum):
    """Get a long description of an error.

    :param enum: The transaction error enum, e.g. :data:`ERROR_NO_LOCK`.
    :returns: The description string.
    """
    try:
        return _DESCS_ERROR[enum]
    except KeyError:
        return ''

# vim:ts=4:sw=4:et
