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)
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))
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)
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)