mirror of
https://github.com/robmcmullen/atrcopy.git
synced 2024-06-09 00:29:28 +00:00
Added some logging, version number to 2.6.0
This commit is contained in:
parent
a33e5aa6b2
commit
97394e0e89
|
@ -1,4 +1,6 @@
|
|||
__version__ = "2.5.1"
|
||||
__version__ = "2.6.0"
|
||||
|
||||
import logging
|
||||
|
||||
try:
|
||||
import numpy as np
|
||||
|
@ -58,6 +60,13 @@ def run():
|
|||
parser.add_argument("-s", "--segments", action="store_true", default=False, help="display segments")
|
||||
options, extra_args = parser.parse_known_args()
|
||||
|
||||
# Turn off debug messages by default
|
||||
log = logging.getLogger("atrcopy")
|
||||
if options.verbose:
|
||||
log.setLevel(logging.DEBUG)
|
||||
else:
|
||||
log.setLevel(logging.INFO)
|
||||
|
||||
for filename in options.files:
|
||||
with open(filename, "rb") as fh:
|
||||
rawdata = SegmentData(fh.read())
|
||||
|
|
|
@ -5,6 +5,9 @@ from diskimages import DiskImageBase
|
|||
from segments import EmptySegment, ObjSegment, RawSectorsSegment, DefaultSegment, SegmentSaver
|
||||
from utils import to_numpy
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AtariDosDirent(object):
|
||||
# ATR Dirent structure described at http://atari.kensclassics.org/dos.htm
|
||||
|
@ -156,12 +159,14 @@ class AtariDosFile(object):
|
|||
b = r.get_data()
|
||||
pos = 0
|
||||
first = True
|
||||
log.debug("Initial parsing: size=%d" % self.size)
|
||||
while pos < self.size:
|
||||
if pos + 1 < self.size:
|
||||
header, = b[pos:pos+2].view(dtype='<u2')
|
||||
else:
|
||||
self.segments.append(ObjSegment(r[pos:pos + 1], pos, pos + 1, 0, 1, "Incomplete Data"))
|
||||
break
|
||||
log.debug("header parsing: header=0x%x" % header)
|
||||
if header == 0xffff:
|
||||
# Apparently 0xffff header can appear in any segment, not just
|
||||
# the first. Regardless, it is ignored everywhere.
|
||||
|
@ -339,5 +344,5 @@ class AtariDosDiskImage(DiskImageBase):
|
|||
binary = AtariDosFile(segment.rawdata)
|
||||
segments_out.extend(binary.segments)
|
||||
except InvalidBinaryFile:
|
||||
pass
|
||||
log.debug("%s not a binary file; skipping segment generation" % str(segment))
|
||||
return segments_out
|
||||
|
|
|
@ -5,6 +5,9 @@ from ataridos import AtariDosDirent, XexSegment
|
|||
from diskimages import DiskImageBase
|
||||
from segments import DefaultSegment, EmptySegment, ObjSegment, RawSectorsSegment, SegmentSaver
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SpartaDosDirent(AtariDosDirent):
|
||||
format = np.dtype([
|
||||
|
@ -87,7 +90,7 @@ class SpartaDosDirent(AtariDosDirent):
|
|||
|
||||
def start_read(self, image):
|
||||
if not self.is_sane:
|
||||
print self.starting_sector
|
||||
log.debug("Invalid directory entry '%s', starting_sector=%s" % (str(self), self.starting_sector))
|
||||
raise InvalidDirent("Invalid directory entry '%s'" % str(self))
|
||||
self.sector_map = image.get_sector_map(self.starting_sector)
|
||||
self.sector_map_index = 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user