def test_get_modified_conffiles(self):
        '''get_modified_conffiles()'''

        # very shallow
        self.assertEqual(type(impl.get_modified_conffiles('bash')), type({}))
        self.assertEqual(type(impl.get_modified_conffiles('apport')), type({}))
        self.assertEqual(type(impl.get_modified_conffiles('nonexisting')), type({}))
示例#2
0
    def test_get_modified_conffiles(self):
        '''get_modified_conffiles()'''

        # very shallow
        self.assertEqual(type(impl.get_modified_conffiles('bash')), type({}))
        self.assertEqual(type(impl.get_modified_conffiles('apport')), type({}))
        self.assertEqual(type(impl.get_modified_conffiles('nonexisting')), type({}))
def attach_conffiles(report, package, conffiles=None, ui=None):
    '''Attach information about any modified or deleted conffiles.

    If conffiles is given, only this subset will be attached. If ui is given,
    ask whether the contents of the file may be added to the report; if this is
    denied, or there is no UI, just mark it as "modified" in the report.
    '''
    modified = packaging.get_modified_conffiles(package)

    for path, contents in modified.items():
        if conffiles and path not in conffiles:
            continue

        key = 'modified.conffile.' + path_to_key(path)
        if type(contents) == str and (contents == '[deleted]'
                                      or contents.startswith('[inaccessible')):
            report[key] = contents
            continue

        if ui:
            response = ui.yesno(
                'It seems you have modified the contents of "%s".  Would you like to add the contents of it to your bug report?'
                % path)
            if response:
                report[key] = contents
            else:
                report[key] = '[modified]'
        else:
            report[key] = '[modified]'

        mtime = datetime.datetime.fromtimestamp(os.stat(path).st_mtime)
        report['mtime.conffile.' + path_to_key(path)] = mtime.isoformat()
示例#4
0
def attach_conffiles(report, package, conffiles=None, ui=None):
    """Attach information about any modified or deleted conffiles.

    If conffiles is given, only this subset will be attached. If ui is given,
    ask whether the contents of the file may be added to the report; if this is
    denied, or there is no UI, just mark it as "modified" in the report.
    """
    modified = packaging.get_modified_conffiles(package)

    for path, contents in modified.items():
        if conffiles and path not in conffiles:
            continue

        key = "modified.conffile." + path_to_key(path)
        if contents == "[deleted]":
            report[key] = contents
            continue

        if ui:
            response = ui.yesno(
                'It seems you have modified the contents of "%s".  Would you like to add the contents of it to your bug report?'
                % path
            )
            if response:
                report[key] = contents
            else:
                report[key] = "[modified]"
        else:
            report[key] = "[modified]"

        mtime = datetime.datetime.fromtimestamp(os.stat(path).st_mtime)
        report["mtime.conffile." + path_to_key(path)] = mtime.isoformat()