Beispiel #1
0
 def buttonClickedLoad(self):
     # Read the redaction configuration file
     config_path = self.SelectConfigEdit.text()
     cfg = config.parse(config_path)
     logging.debug('Combined config & arguments:\n%s' % cfg)
     # validate the config against schema and show any errors
     self.redactor = Redactor(**cfg)
Beispiel #2
0
 def buttonClickedLoad(self):
     # Read the redaction configuration file
     config_path = self.SelectConfigEdit.text()
     cfg = config.parse(config_path)
     logging.debug('Combined config & arguments:\n%s' % cfg)
     # validate the config against schema and show any errors
     self.redactor = Redactor(**cfg)
Beispiel #3
0
def main():
    from docopt import docopt
    from libredact import __version__
    args = docopt(__doc__, version=__version__)

    if args.get('--chelp'):
        print(config_help)
        exit()

    # Set up console log levels (default=warn, quiet=error, debug=debug)
    log_level = logging.WARN
    if args.get('--quiet'):
        log_level = logging.ERROR
    if args.get('--detail'):  # debug overrides quiet
        log_level = logging.DEBUG
    logging.basicConfig(level=log_level)

    # Read the redaction configuration file
    from libredact.config import parse
    cfg = parse(args.get('--config'))

    # Override any CLI arguments
    if args.get('--input'):
        cfg['image_file'] = args.get('--input')
    if args.get('--output'):
        cfg['output_file'] = args.get('--output')
    if args.get('--dfxml'):
        cfg['dfxml_file'] = args.get('--dfxml')
    if args.get('--report'):
        cfg['report_file'] = args.get('--report')
    if args.get('--dry-run'):  # if True then override COMMIT
        cfg['commit'] = False
    # TODO cfg['detail'] = args.get('--detail')

    logging.debug('Combined config & arguments:\n%s' % cfg)

    redactor = Redactor(**cfg)

    import time
    t0 = time.time()
    redactor.execute()
    t1 = time.time()
    print("Time to run: %d seconds" % (t1 - t0))
Beispiel #4
0
def main():
    from docopt import docopt
    from libredact import __version__
    args = docopt(__doc__, version=__version__)

    if args.get('--chelp'):
        print(config_help)
        exit()

    # Set up console log levels (default=warn, quiet=error, debug=debug)
    log_level = logging.WARN
    if args.get('--quiet'):
        log_level = logging.ERROR
    if args.get('--detail'):  # debug overrides quiet
        log_level = logging.DEBUG
    logging.basicConfig(level=log_level)

    # Read the redaction configuration file
    from libredact.config import parse
    cfg = parse(args.get('--config'))

    # Override any CLI arguments
    if args.get('--input'):
        cfg['image_file'] = args.get('--input')
    if args.get('--output'):
        cfg['output_file'] = args.get('--output')
    if args.get('--dfxml'):
        cfg['dfxml_file'] = args.get('--dfxml')
    if args.get('--report'):
        cfg['report_file'] = args.get('--report')
    if args.get('--dry-run'):  # if True then override COMMIT
        cfg['commit'] = False
    # TODO cfg['detail'] = args.get('--detail')

    logging.debug('Combined config & arguments:\n%s' % cfg)

    redactor = Redactor(**cfg)

    import time
    t0 = time.time()
    redactor.execute()
    t1 = time.time()
    print("Time to run: %d seconds" % (t1 - t0))
Beispiel #5
0
 def buttonClickedSelectConfig(self):
     # TODO implement GUI controls for config overrides
     # if args.get('--input'):
     #     cfg['image_file'] = args.get('--input')
     # if args.get('--output'):
     #     cfg['output_file'] = args.get('--output')
     # if args.get('--dfxml'):
     #     cfg['dfxml_file'] = args.get('--dfxml')
     # if args.get('--report'):
     #     cfg['report_file'] = args.get('--report')
     # if args.get('--dry-run'):  # if True then override COMMIT
     #     cfg['commit'] = False
     # cfg['detail'] = args.get('--detail')
     filenames = QtWidgets.QFileDialog.getOpenFileName(self, "Open file", "", "Configuration text files (*.*)")
     if filenames[0]:
         self.fname = filenames[0]
         self.SelectConfigEdit.setText(self.fname)
         try:
             self.redact_config = config.parse(self.fname)
             logging.debug("Combined config & arguments:\n%s" % self.redact_config)
         except Exception as e:
             logging.error(e)
Beispiel #6
0
 def buttonClickedSelectConfig(self):
     # TODO implement GUI controls for config overrides
     # if args.get('--input'):
     #     cfg['image_file'] = args.get('--input')
     # if args.get('--output'):
     #     cfg['output_file'] = args.get('--output')
     # if args.get('--dfxml'):
     #     cfg['dfxml_file'] = args.get('--dfxml')
     # if args.get('--report'):
     #     cfg['report_file'] = args.get('--report')
     # if args.get('--dry-run'):  # if True then override COMMIT
     #     cfg['commit'] = False
     # cfg['detail'] = args.get('--detail')
     filenames = QtWidgets.QFileDialog.getOpenFileName(
         self, 'Open file', '', "Configuration text files (*.*)")
     if filenames[0]:
         self.fname = filenames[0]
         self.SelectConfigEdit.setText(self.fname)
         try:
             self.redact_config = config.parse(self.fname)
             logging.debug('Combined config & arguments:\n%s' %
                           self.redact_config)
         except Exception as e:
             logging.error(e)