1
0
mirror of https://github.com/gryf/uc1541.git synced 2026-03-01 14:15:52 +01:00

Clean up the code.

There was an issue regarding c1541 in old version - during removal of
the file from the image, as a success message 'ERRORCODE 1' was placed
on the stdout. If there was an issue with the file different message was
placed also on stdout. Luckily, that weird behaviour was fixed in 3.x
series of the Vice. So now we can remove unnecessary code.

Also, fixed two bugs for pyton3, introduced during new formats
development.
This commit is contained in:
2019-09-20 18:09:09 +02:00
parent 76daa17640
commit ad6ee3879a

25
uc1541
View File

@@ -102,7 +102,7 @@ def _get_implementation(disk):
196608: D64, # 40 track, no errors
197376: D64} # 40 track, 768 error bytes
if disk[:32].startswith('C64'):
if disk[:32].startswith(b'C64'):
return # T64
return len_map.get(len(disk))(disk)
@@ -434,14 +434,6 @@ class Uc1541(object):
if not self._call_command('delete', dst=dst):
return self._show_error()
# During removing, a message containing ERRORCODE is sent to stdout
# instead of stderr. Everything other than 'ERRORCODE 1' (which means:
# 'everything fine') is actually a failure. In case of verbose error
# output it is needed to copy self.out to self.err.
if '\nERRORCODE 1\n' not in self.out:
self.err = self.out
return self._show_error()
return 0
def copyin(self, dst, src):
@@ -594,14 +586,19 @@ class Uc1541(object):
command.append(dst)
LOG.debug('executing command: %s', ' '.join(command))
# For some reason using write command and reading output confuses
# Python3 beneath MC and as a consequence MC report an error...
# therefore for write command let's not use universal_newlines...
# For some reason using write and delete commands and reading output
# confuses Python3 beneath MC and as a consequence MC report an
# error...therefore for those commands let's not use
# universal_newlines...
universal_newlines = True
if cmd in ['delete', 'write']:
universal_newlines = False
self.out, self.err = Popen(command,
universal_newlines=(cmd != 'write'),
universal_newlines=universal_newlines,
stdout=PIPE, stderr=PIPE).communicate()
LOG.debug('an err: %s', self.err)
if self.err:
LOG.debug('an err: %s', self.err)
return not self.err