def handle(self, *args, **options): try: import bpdb as pdb except ImportError: import pdb try: Event.sync_from_meetup() except Exception as exc: self.stderr.write("ERROR: %s" % exc) pdb.pm()
def main(): logging.basicConfig(level=logging.INFO, format='%(levelname)s %(funcName)s: %(message)s') parser = argparse.ArgumentParser() parser.add_argument('files', metavar="THUMBNAIL MASTER", nargs="+") parser.add_argument('--save-visualization', action="store_true", help="Save match visualization") parser.add_argument('--save-thumbnail', action="store_true", help="Save reconstructed thumbnail at full size") parser.add_argument('--thumbnail-format', default='jpg', help='Format for reconstructed thumbnails (png or default %(default)s)') parser.add_argument('--display', action="store_true", help="Display match visualization") parser.add_argument('--debug', action="store_true", help="Open debugger for errors") args = parser.parse_args() if len(args.files) % 2 != 0: parser.error("Files must be provided in thumbnail and master pairs") if args.thumbnail_format not in ('jpg', 'png'): parser.error('Thumbnail format must be either jpg or png') if args.debug: try: import bpdb as pdb except ImportError: import pdb for i in xrange(0, len(args.files), 2): thumbnail = args.files[i] source = args.files[i + 1] try: locate_thumbnail(thumbnail, source, display=args.display, save_reconstruction=args.save_thumbnail, reconstruction_format=args.thumbnail_format, save_visualization=args.save_visualization) except Exception as e: logging.error("Error processing %s %s: %s", thumbnail, source, e) if args.debug: pdb.pm()
user_map = dict(user_map) elif "users" in config: user_map = config["users"] else: user_map = {} try: m = Migrator( trac_url=trac_url, github_username=args.github_username, github_password=github_password, github_api_url=args.github_api_url, github_project=args.github_project, username_map=user_map, config=config, should_verify_ssl=args.ssl_verify, is_dry_run=args.dry_run, should_import_attachments=args.import_attachments, attachments_local_path=args.attachments_local_path, attachments_github_repo=args.attachments_github_repo, ) m.run(ticket_range=args.ticket_range) except Exception as e: print("Exception: %s" % e, file=sys.stderr) tb = sys.exc_info()[2] sys.last_traceback = tb pdb.pm() raise
output_base = os.path.join(output_dir, base_name) print "Processing %s" % f boxes = [] for i, bbox in enumerate(extractor.find_figures(source_image), 1): extracted = source_image[bbox.image_slice] extract_filename = os.path.join(output_dir, "%s-%d.jpg" % (output_base, i)) print "\tSaving %s" % extract_filename cv2.imwrite(extract_filename, extracted) boxes.append(bbox.as_dict()) if args.save_json and boxes: json_data = {"source_image": {"filename": f, "dimensions": {"width": source_image.shape[1], "height": source_image.shape[0]}}, "regions": boxes} json_filename = os.path.join(output_dir, "%s.json" % output_base) with open(json_filename, "wb") as json_f: json.dump(json_data, json_f, allow_nan=False) print "\tSaved extract information to %s" % json_filename except Exception as exc: if args.debug: print >>sys.stderr, exc pdb.pm() raise