コード例 #1
0
def initExceptionHandling(anaconda):
    file_list = ["/tmp/anaconda.log", "/tmp/packaging.log",
                 "/tmp/program.log", "/tmp/storage.log",
                 "/tmp/dnf.librepo.log", "/tmp/hawkey.log",
                 "/tmp/lvm.log", conf.target.system_root + "/root/install.log",
                 "/proc/cmdline", "/root/lorax-packages.log",
                 "/tmp/blivet-gui-utils.log", "/tmp/dbus.log"]

    if os.path.exists("/tmp/syslog"):
        file_list.extend(["/tmp/syslog"])

    if anaconda.opts and anaconda.opts.ksfile:
        file_list.extend([anaconda.opts.ksfile])

    config = Config(programName="anaconda",
                  programVersion=util.get_anaconda_version_string(),
                  programArch=os.uname()[4],
                  attrSkipList=["_intf._actions",
                                "_intf._currentAction._xklwrapper",
                                "_intf._currentAction._spokes[\"KeyboardSpoke\"]._xkl_wrapper",
                                "_intf._currentAction._storage_playground",
                                "_intf._currentAction._spokes[\"CustomPartitioningSpoke\"]._storage_playground",
                                "_intf._currentAction.language.translations",
                                "_intf._currentAction.language.locales",
                                "_intf._currentAction._spokes[\"PasswordSpoke\"]._oldweak",
                                "_intf._currentAction._spokes[\"PasswordSpoke\"]._password",
                                "_intf._currentAction._spokes[\"UserSpoke\"]._password",
                                "_intf._currentAction._spokes[\"UserSpoke\"]._oldweak",
                                "_intf.storage.bootloader.password",
                                "_intf.storage.data",
                                "_intf.storage.ksdata",
                                "_intf.data",
                                "_bootloader.encrypted_password",
                                "_bootloader.password",
                                "payload._groups"],
                  localSkipList=["passphrase", "password", "_oldweak", "_password", "try_passphrase"],
                  fileList=file_list)

    config.register_callback("lsblk_output", lsblk_callback, attchmnt_only=False)
    config.register_callback("nmcli_dev_list", nmcli_dev_list_callback,
                           attchmnt_only=True)

    # provide extra information for libreport
    config.register_callback("type", lambda: "anaconda", attchmnt_only=True)
    config.register_callback("addons", list_addons_callback, attchmnt_only=False)

    if "/tmp/syslog" not in file_list:
        # no syslog, grab output from journalctl and put it also to the
        # anaconda-tb file
        config.register_callback("journalctl", journalctl_callback, attchmnt_only=False)

    if not product.isFinal:
        config.register_callback("release_type", lambda: "pre-release", attchmnt_only=True)

    handler = AnacondaExceptionHandler(config, anaconda.intf.meh_interface,
                                       AnacondaReverseExceptionDump, anaconda.intf.tty_num,
                                       anaconda.gui_initialized, anaconda.interactive_mode)
    handler.install(anaconda)

    return config
コード例 #2
0
    def runTest(self):
        conf = Config(programName="CallbacksTest",
                      programVersion="1.0",
                      callbackDict={"callback1": (callback1, False),
                                    "callback2": (callback2, False)})

        # another way to register callback
        conf.register_callback("callback3", callback2)

        # callback with given item name already registered
        with self.assertRaises(ConfigError):
            conf.register_callback("callback3", callback3)

        # should not raise exception
        conf.register_callback("callback3", callback3, override=True)

        conf.register_callback("callback4", callback4, attchmnt_only=True)
        conf.register_callback("callback5", callback5, attchmnt_only=False)

        # should not raise exception
        dump = self.dump(conf, None)

        self.assertIn("callback1:\nThis was generated by the callback1\n",
                      dump)
        self.assertIn("callback2:\nThis was generated by the callback2\n",
                      dump)
        self.assertIn("callback3: Caused error", dump)

        # should not appear in the dump (attachment only)
        self.assertNotIn("callback4", dump)

        # should not appear in the dump (nothing provided)
        self.assertNotIn("callback5", dump)
コード例 #3
0
def initExceptionHandling(anaconda):
    fileList = [
        "/tmp/anaconda.log", "/tmp/packaging.log", "/tmp/program.log",
        "/tmp/storage.log", "/tmp/ifcfg.log", "/tmp/dnf.log",
        "/tmp/dnf.rpm.log", "/tmp/yum.log",
        iutil.getSysroot() + "/root/install.log", "/proc/cmdline"
    ]

    if os.path.exists("/tmp/syslog"):
        fileList.extend(["/tmp/syslog"])

    if anaconda.opts and anaconda.opts.ksfile:
        fileList.extend([anaconda.opts.ksfile])

    conf = Config(
        programName="anaconda",
        programVersion=startup_utils.get_anaconda_version_string(),
        programArch=os.uname()[4],
        attrSkipList=[
            "_intf._actions", "_intf._currentAction._xklwrapper",
            "_intf._currentAction._spokes[\"KeyboardSpoke\"]._xkl_wrapper",
            "_intf._currentAction._storage_playground",
            "_intf._currentAction._spokes[\"CustomPartitioningSpoke\"]._storage_playground",
            "_intf._currentAction.language.translations",
            "_intf._currentAction.language.locales",
            "_intf._currentAction._spokes[\"PasswordSpoke\"]._oldweak",
            "_intf._currentAction._spokes[\"PasswordSpoke\"]._password",
            "_intf._currentAction._spokes[\"UserSpoke\"]._password",
            "_intf._currentAction._spokes[\"UserSpoke\"]._oldweak",
            "_intf.storage.bootloader.password", "_intf.storage.data",
            "_intf.storage.encryptionPassphrase",
            "_bootloader.encrypted_password", "_bootloader.password",
            "payload._groups", "payload._yum"
        ],
        localSkipList=["passphrase", "password", "_oldweak", "_password"],
        fileList=fileList)

    conf.register_callback("lsblk_output", lsblk_callback, attchmnt_only=True)
    conf.register_callback("nmcli_dev_list",
                           nmcli_dev_list_callback,
                           attchmnt_only=True)
    conf.register_callback("type", lambda: "anaconda", attchmnt_only=True)
    conf.register_callback("addons", list_addons_callback, attchmnt_only=False)

    if "/tmp/syslog" not in fileList:
        # no syslog, grab output from journalctl and put it also to the
        # anaconda-tb file
        conf.register_callback("journalctl",
                               journalctl_callback,
                               attchmnt_only=False)

    interactive = not anaconda.displayMode == 'c'
    handler = AnacondaExceptionHandler(conf, anaconda.intf.meh_interface,
                                       ReverseExceptionDump,
                                       anaconda.intf.tty_num,
                                       anaconda.gui_initialized, interactive)
    handler.install(anaconda)

    return conf
コード例 #4
0
    def runTest(self):
        example = Example()

        conf = Config(programName="test",
                      programVersion="47",
                      attrSkipList=["rootPassword"])

        dump = self.dump(conf, example)

        self.assertIn("rootPassword: Skipped", dump)
        self.assertNotIn("dontSkipMe: Skipped", dump)
コード例 #5
0
    def runTest(self):
        unicode_example = UnicodeExample()

        conf = Config(programName="UnicodeTest",
                      programVersion="1.0",
                      fileList=[self.uni_file_path, self.ascii_file_path])

        # should not raise exception
        dump = self.dump(conf, unicode_example)

        self.assertIn("_str: " + str(UNICODE_STR.encode("utf-8")), dump)
        self.assertIn("encoded_str: " + str(UNICODE_STR.encode("utf-8")), dump)
        self.assertIn(UNICODE_LINE, dump)

        self.assertIn("ascii_str: " + ASCII_STR, dump)
        self.assertIn(ASCII_LINE.rstrip(), dump)
コード例 #6
0
    def runTest(self):
        binary_example = BinaryExample()

        conf = Config(programName="UnicodeTest", programVersion="1.0")

        # should not raise exception
        dump = self.dump(conf, binary_example)

        # should contain the attribute name and hexa representation of binary
        # data ('\x61' == 'a' which shouldn't be translated)
        self.assertTrue("bin_data: \\xff\\x61\\xfe\\xdd\n" in dump
                        or "bin_data: b'\\xffa\\xfe\\xdd'\n" in dump)

        # should contain the binary-keyed dict
        self.assertTrue(
            "dict: {'\\xfe\\x61\\xff\\xdd': \\xfe\\x61\\xff\\xdd" in dump
            or "dict: {b'\\xfea\\xff\\xdd': b'\\xfea\\xff\\xdd'" in dump)

        # should contain the list with binary item(s)
        self.assertTrue("list: [\\xfe\\x62\\xff\\xdd]" in dump
                        or "list: [b'\\xfeb\\xff\\xdd']" in dump)
コード例 #7
0
CONFIG_DIR = user_config_dir("spotify-graveyard")
CONFIG_LOCATION = CONFIG_DIR + "/config.cfg"

PLAYLIST_MAX_LIMIT = 50
PLAYLIST_TRACKS_MAX_LIMIT = 100


def is_int(obj):
    return type(obj) is int


def is_float(obj):
    return type(obj) is float


config = Config()
config.add(Option("access_token", None))
config.add(Option("valid_until", 0.0, validator=is_float))
config.add(Option("inbox_playlist_id", None))
config.add(Option("graveyard_playlist_id", None))
config.add(Option("livespan", 7, validator=is_int))


def can_edit_playlist(playlist, owner):
    return playlist["owner"]["id"] == owner


def load_config():
    global config

    cfg = None