コード例 #1
0
ファイル: test_config.py プロジェクト: xinpengliu/checkbox
    def test_parser(self):
        conf_file = StringIO("[testsection]\nlower = low\nUPPER = up")
        config = PlainBoxConfigParser()
        config.read_file(conf_file)

        self.assertEqual(['testsection'], config.sections())
        all_keys = list(config['testsection'].keys())
        self.assertTrue('lower' in all_keys)
        self.assertTrue('UPPER' in all_keys)
        self.assertFalse('upper' in all_keys)
コード例 #2
0
    def test_parser(self):
        conf_file = StringIO("[testsection]\nlower = low\nUPPER = up")
        config = PlainBoxConfigParser()
        config.read_file(conf_file)

        self.assertEqual(['testsection'], config.sections())
        all_keys = list(config['testsection'].keys())
        self.assertTrue('lower' in all_keys)
        self.assertTrue('UPPER' in all_keys)
        self.assertFalse('upper' in all_keys)
コード例 #3
0
    def __init__(
        self, *,
        app_name: str=None,
        app_generic_name: str=None,
        app_comment: str=None,
        app_icon: str=None,
        app_terminal: bool=False,
        app_categories: str=None,
        app_startup_notify: bool=False
    ):
        """
        Initialize the XDG resume strategy.

        :param cmd_callback:
            The command callback
        """
        self.config = config = PlainBoxConfigParser()
        section = 'Desktop Entry'
        config.add_section(section)
        config.set(section, 'Type', 'Application')
        config.set(section, 'Version', '1.0')
        config.set(section, 'Name',
                   app_name or 'Resume Testing Session')
        config.set(section, 'GenericName',
                   app_generic_name or 'Resume Testing Session')
        config.set(section, 'Comment',
                   app_comment or 'Automatically resume the testing session')
        config.set(section, 'Terminal', 'true' if app_terminal else 'false')
        if app_icon:
            config.set(section, 'Icon', app_icon)
        config.set(section, 'Categories', app_categories or 'System')
        config.set(section, 'StartupNotify',
                   'true' if app_startup_notify else 'false')
コード例 #4
0
    def __init__(self):
        self.config = config = PlainBoxConfigParser()

        section = 'Unit'
        config.add_section(section)
        config.set(section, 'Description', 'Plainbox Resume Wrapper')
        config.set(section, 'After', 'ubuntu-snappy.frameworks.target')
        config.set(section, 'Requires', 'ubuntu-snappy.frameworks.target')
        config.set(section, 'X-Snappy', 'yes')

        section = 'Service'
        config.add_section(section)
        config.set(section, 'Type', 'oneshot')

        section = 'Install'
        config.add_section(section)
        config.set(section, 'WantedBy', 'multi-user.target')
コード例 #5
0
ファイル: restart.py プロジェクト: alex-tu-cc/checkbox-ng
    def __init__(self):
        self.config = config = PlainBoxConfigParser()

        section = 'Unit'
        config.add_section(section)
        config.set(section, 'Description', 'Plainbox Resume Wrapper')
        config.set(section, 'After', 'ubuntu-snappy.frameworks.target')
        config.set(section, 'Requires', 'ubuntu-snappy.frameworks.target')
        config.set(section, 'X-Snappy', 'yes')

        section = 'Service'
        config.add_section(section)
        config.set(section, 'Type', 'oneshot')
        config.set(section, 'StandardOutput', 'tty')
        config.set(section, 'StandardError', 'tty')
        config.set(section, 'TTYPath', '/dev/console')
        if os.getenv('USER'):
            config.set(section, 'User', os.getenv('USER'))

        section = 'Install'
        config.add_section(section)
        config.set(section, 'WantedBy', 'multi-user.target')