def main(argv): epilog = "FORMAT options:\n" + formats.print_formats() parser = util.ArgumentParser(usage='%(prog)s [options] in_file out_file', epilog=epilog) parser.add_argument("--format", help="disk format") parser.add_argument("--tracks", type=util.TrackSet, help="which tracks to convert") parser.add_argument("--rpm", type=int, help="convert drive speed to RPM") parser.add_argument("-n", "--no-clobber", action="store_true", help="do not overwrite an existing file") parser.add_argument("in_file", help="input filename") parser.add_argument("out_file", help="output filename") parser.description = description parser.prog += ' ' + argv[1] args = parser.parse_args(argv[2:]) args.out_file, args.out_file_opts = util.split_opts(args.out_file) in_image_class = util.get_image_class(args.in_file) if not args.format and hasattr(in_image_class, 'default_format'): args.format = in_image_class.default_format out_image_class = util.get_image_class(args.out_file) if not args.format and hasattr(out_image_class, 'default_format'): args.format = out_image_class.default_format decoder, def_tracks, args.fmt_cls = None, None, None if args.format: try: args.fmt_cls = formats.formats[args.format]() except KeyError as ex: raise error.Fatal("""\ Unknown format '%s' Known formats:\n%s""" % (args.format, formats.print_formats())) decoder = args.fmt_cls.decode_track def_tracks = args.fmt_cls.default_tracks if def_tracks is None: def_tracks = util.TrackSet('c=0-81:h=0-1') if args.tracks is not None: def_tracks.update_from_trackspec(args.tracks.trackspec) args.tracks = def_tracks print("Converting %s" % args.tracks) if args.format: print("Format " + args.format) in_image = open_input_image(args, in_image_class) with open_output_image(args, out_image_class) as out_image: convert(args, in_image, out_image, decoder=decoder)
def main(argv): epilog = "FORMAT options:\n" + formats.print_formats() parser = util.ArgumentParser(usage='%(prog)s [options] file', epilog=epilog) parser.add_argument("--device", help="device name (COM/serial port)") parser.add_argument("--drive", type=util.drive_letter, default='A', help="drive to write (A,B,0,1,2)") parser.add_argument("--format", help="disk format") parser.add_argument("--tracks", type=util.TrackSet, help="which tracks to write") parser.add_argument("--erase-empty", action="store_true", help="erase empty tracks (default: skip)") parser.add_argument("--no-verify", action="store_true", help="disable verify") parser.add_argument("--retries", type=int, default=3, help="number of retries on verify failure") parser.add_argument("--precomp", type=PrecompSpec, help="write precompensation") parser.add_argument("file", help="input filename") parser.description = description parser.prog += ' ' + argv[1] args = parser.parse_args(argv[2:]) try: image_class = util.get_image_class(args.file) if not args.format and hasattr(image_class, 'default_format'): args.format = image_class.default_format def_tracks, args.fmt_cls = None, None if args.format: try: args.fmt_cls = formats.formats[args.format]() except KeyError as ex: raise error.Fatal("""\ Unknown format '%s' Known formats:\n%s""" % (args.format, formats.print_formats())) def_tracks = args.fmt_cls.default_tracks if def_tracks is None: def_tracks = util.TrackSet('c=0-81:h=0-1') if args.tracks is not None: def_tracks.update_from_trackspec(args.tracks.trackspec) args.tracks = def_tracks usb = util.usb_open(args.device) image = open_image(args, image_class) print("Writing " + str(args.tracks)) if args.precomp is not None: print(args.precomp) if args.format: print("Format " + args.format) util.with_drive_selected(write_from_image, usb, args, image) except USB.CmdError as err: print("Command Failed: %s" % err)
def __init__(self, name, fmt): self.to_track = dict() error.check( fmt is not None and fmt.img_compatible, """\ Sector image requires compatible format conversion Compatible formats:\n%s""" % formats.print_formats(lambda k, v: v.img_compatible)) self.filename = name self.fmt = fmt
def main(argv): epilog = (util.drive_desc + "\n" + util.speed_desc + "\n" + util.tspec_desc + "\nFORMAT options:\n" + formats.print_formats()) parser = util.ArgumentParser(usage='%(prog)s [options] file', epilog=epilog) parser.add_argument("--device", help="device name (COM/serial port)") parser.add_argument("--drive", type=util.drive_letter, default='A', help="drive to read") parser.add_argument("--format", help="disk format (output is converted unless --raw)") parser.add_argument("--revs", type=int, metavar="N", help="number of revolutions to read per track") parser.add_argument("--tracks", type=util.TrackSet, metavar="TSPEC", help="which tracks to read") parser.add_argument("--raw", action="store_true", help="output raw stream (--format verifies only)") parser.add_argument("--fake-index", type=util.period, metavar="SPEED", help="fake index pulses at SPEED") parser.add_argument("--adjust-speed", type=util.period, metavar="SPEED", help="scale track data to effective drive SPEED") parser.add_argument("--retries", type=int, default=3, metavar="N", help="number of retries per seek-retry") parser.add_argument("--seek-retries", type=int, default=3, metavar="N", help="number of seek retries") parser.add_argument("-n", "--no-clobber", action="store_true", help="do not overwrite an existing file") parser.add_argument("file", help="output filename") parser.description = description parser.prog += ' ' + argv[1] args = parser.parse_args(argv[2:]) args.file, args.file_opts = util.split_opts(args.file) try: usb = util.usb_open(args.device) image_class = util.get_image_class(args.file) if not args.format and hasattr(image_class, 'default_format'): args.format = image_class.default_format decoder, def_tracks, args.fmt_cls = None, None, None if args.format: try: args.fmt_cls = formats.formats[args.format]() except KeyError as ex: raise error.Fatal("""\ Unknown format '%s' Known formats:\n%s""" % (args.format, formats.print_formats())) decoder = args.fmt_cls.decode_track def_tracks = args.fmt_cls.default_tracks if args.revs is None: args.revs = args.fmt_cls.default_revs if def_tracks is None: def_tracks = util.TrackSet('c=0-81:h=0-1') if args.revs is None: args.revs = 3 if args.tracks is not None: def_tracks.update_from_trackspec(args.tracks.trackspec) args.tracks = def_tracks print(("Reading %s revs=" % args.tracks) + str(args.revs)) if args.format: print("Format " + args.format) with open_image(args, image_class) as image: util.with_drive_selected(read_to_image, usb, args, image, decoder=decoder) except USB.CmdError as err: print("Command Failed: %s" % err)
def main(argv): epilog = (util.speed_desc + "\n" + util.tspec_desc + "\nFORMAT options:\n" + formats.print_formats()) parser = util.ArgumentParser(usage='%(prog)s [options] in_file out_file', epilog=epilog) parser.add_argument("--format", help="disk format") parser.add_argument("--tracks", type=util.TrackSet, help="which tracks to read & convert from input", metavar="TSPEC") parser.add_argument("--out-tracks", type=util.TrackSet, help="which tracks to output (default: --tracks)", metavar="TSPEC") parser.add_argument("--adjust-speed", type=util.period, metavar="SPEED", help="scale track data to effective drive SPEED") parser.add_argument("-n", "--no-clobber", action="store_true", help="do not overwrite an existing file") parser.add_argument("in_file", help="input filename") parser.add_argument("out_file", help="output filename") parser.description = description parser.prog += ' ' + argv[1] args = parser.parse_args(argv[2:]) args.out_file, args.out_file_opts = util.split_opts(args.out_file) in_image_class = util.get_image_class(args.in_file) if not args.format and hasattr(in_image_class, 'default_format'): args.format = in_image_class.default_format out_image_class = util.get_image_class(args.out_file) if not args.format and hasattr(out_image_class, 'default_format'): args.format = out_image_class.default_format decoder, def_tracks, args.fmt_cls = None, None, None if args.format: try: args.fmt_cls = formats.formats[args.format]() except KeyError as ex: raise error.Fatal("""\ Unknown format '%s' Known formats:\n%s""" % (args.format, formats.print_formats())) decoder = args.fmt_cls.decode_track def_tracks = copy.copy(args.fmt_cls.default_tracks) if def_tracks is None: def_tracks = util.TrackSet('c=0-81:h=0-1') out_def_tracks = copy.copy(def_tracks) if args.tracks is not None: def_tracks.update_from_trackspec(args.tracks.trackspec) out_def_tracks.cyls = copy.copy(def_tracks.cyls) out_def_tracks.heads = copy.copy(def_tracks.heads) args.tracks = def_tracks if args.out_tracks is not None: out_def_tracks.update_from_trackspec(args.out_tracks.trackspec) args.out_tracks = out_def_tracks print("Converting %s -> %s" % (args.tracks, args.out_tracks)) if args.format: print("Format " + args.format) in_image = open_input_image(args, in_image_class) with open_output_image(args, out_image_class) as out_image: convert(args, in_image, out_image, decoder=decoder)