def initExceptionHandling(anaconda):
    fileList = [
        "/tmp/anaconda.log", "/tmp/packaging.log", "/tmp/program.log",
        "/tmp/storage.log", "/tmp/ifcfg.log", "/tmp/yum.log",
        ROOT_PATH + "/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=isys.getAnacondaVersion(),
        programArch=os.uname()[4],
        attrSkipList=[
            "_intf._actions", "_intf._currentAction._xklwrapper",
            "_intf._currentAction._spokes[\"KeyboardSpoke\"]._xkl_wrapper",
            "_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)

    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)

    handler = AnacondaExceptionHandler(conf, anaconda.intf.meh_interface,
                                       ReverseExceptionDump,
                                       anaconda.intf.tty_num)
    handler.install(anaconda)

    return conf
def initExceptionHandling(anaconda):
    fileList = [ "/tmp/anaconda.log", "/tmp/packaging.log",
                 "/tmp/program.log", "/tmp/storage.log", "/tmp/ifcfg.log",
                 "/tmp/yum.log", ROOT_PATH + "/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=isys.getAnacondaVersion(),
                  programArch=os.uname()[4],
                  attrSkipList=["_intf._actions",
                                "_intf._currentAction._xklwrapper",
                                "_intf._currentAction._spokes[\"KeyboardSpoke\"]._xkl_wrapper",
                                "_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)

    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)

    handler = AnacondaExceptionHandler(conf, anaconda.intf.meh_interface,
                                       ReverseExceptionDump, anaconda.intf.tty_num)
    handler.install(anaconda)

    return conf
Example #3
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)
Example #4
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)
Example #5
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)
Example #6
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/lvm.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",
        ],
        localSkipList=["passphrase", "password", "_oldweak", "_password", "try_passphrase"],
        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
Example #7
0
from os import remove
from os.path import isfile
from sys import path
from os.path import abspath
from sys import argv

path.append(abspath("."))

from meh import Config, Option, UnsupportedTypeError, ExceptionInConfigError

CONFIG_PATH = "data_types.cfg"

config = Config()
config.add(Option("list", [1, 2, 3]))
config.add(Option("tuple", (1, 2, 3)))
config.add(Option("dict", {"foo" : "baz", "test" : 123}))
config.add(Option("bytes", b"test"))
config.add(Option("string", "test"))
config.add(Option("float", 42.0))
config.add(Option("complex", (1+2j)))
config.add(Option("int", 42))
config.add(Option("boolean", False))
config.add(Option("none", None))

try:
	config = config.load(CONFIG_PATH)
except (IOError, ExceptionInConfigError):
	config.dump(CONFIG_PATH)
	config = config.load(CONFIG_PATH)

print(config.list)
Example #8
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",
        util.getSysroot() + "/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.storage.encryption_passphrase",
            "_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
Example #9
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", util.getSysroot() + "/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=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.ksdata",
                                "_intf.storage.encryption_passphrase",
                                "_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
Example #10
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
Example #11
0
sys.excepthook = exception_hook

from meh import Config, Option, ExceptionInConfigError

CONFIG_PATH = None

for config_path in [expanduser("~/.config/cmus/cmus-osx/"), expanduser("~/.cmus/cmus-osx/")]:
	if isdir(config_path):
		CONFIG_PATH = config_path + "cmus-osx.config"


if CONFIG_PATH == None:
	raise Exception("cmus config directory not found, aborting...")


config = Config()
config += Option("display_mode", 2, validator=lambda x: x in (0, 1, 2), 
	comment="0: Disables notifications; "
			"1: Keep old notifications around; "
			"2: Clear old notifications")
config += Option("app_icon", expanduser("~/.config/cmus/cmus-osx/cmus-icon.png"), 
	validator=isfile, comment="Fallback icon if no album artwork is avaliable")
config += Option("notification_on_pause", False, 
	comment="Also display notification on pause")
config += Option("itunes_style_notification", True, 
	comment="Display album artwork as app icon instead of notification badge")

try:
    config = config.load(CONFIG_PATH)
except (IOError, ExceptionInConfigError):
    config.dump(CONFIG_PATH)
Example #12
0
from os import remove
from os.path import isfile
from sys import path
from os.path import abspath
from sys import argv

path.append(abspath("."))

from meh import Config, Option, UnsupportedTypeError, ExceptionInConfigError

CONFIG_PATH = "data_types.cfg"

config = Config()
config.add(Option("list", [1, 2, 3]))
config.add(Option("tuple", (1, 2, 3)))
config.add(Option("dict", {"foo": "baz", "test": 123}))
config.add(Option("bytes", b"test"))
config.add(Option("string", "test"))
config.add(Option("float", 42.0))
config.add(Option("complex", (1 + 2j)))
config.add(Option("int", 42))
config.add(Option("boolean", False))
config.add(Option("none", None))

try:
    config = config.load(CONFIG_PATH)
except (IOError, ExceptionInConfigError):
    config.dump(CONFIG_PATH)
    config = config.load(CONFIG_PATH)

print(config.list)
Example #13
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)
Example #14
0
from meh import Config, Option, ExceptionInConfigError

CONFIG_PATH = None

for config_path in [
        expanduser("~/.config/cmus/cmus-osx/"),
        expanduser("~/.cmus/cmus-osx/")
]:
    if isdir(config_path):
        CONFIG_PATH = config_path + "cmus-osx.config"

if CONFIG_PATH == None:
    raise Exception("cmus config directory not found, aborting...")

config = Config()
config += Option("display_mode",
                 2,
                 validator=lambda x: x in (0, 1, 2),
                 comment="0: Disables notifications; "
                 "1: Keep old notifications around; "
                 "2: Clear old notifications")
config += Option("app_icon",
                 expanduser("~/.config/cmus/cmus-osx/cmus-icon.png"),
                 validator=isfile,
                 comment="Fallback icon if no album artwork is avaliable")
config += Option("notification_on_pause",
                 False,
                 comment="Also display notification on pause")
config += Option(
    "itunes_style_notification",
Example #15
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)