Skip to content

Instantiate IOError objects with meaningful values for errno / strerror. #83

@lyda

Description

@lyda

You can check the action IO error by using the errno module and the IOError's errno member variable. It would be nice if that worked for IOErrors when working with HDFS. I don't know hadoop well enough, but it might even be possible to get this from the exit code of the process.

Essentially I wanted to write:

try:
  hadoopy.put('/root/.bashrc', '/bashrc')
  print 'Added /bashrc'
except IOError as e:
  if e.errno == errno.EEXIST:
    print 'Removing /bashrc'
    hadoopy.rmr('/bashrc')
  else:
    raise e

But instead had to write:

try:
  hadoopy.put('/root/.bashrc', '/bashrc')
  print 'Added /bashrc'
except IOError as e:
  if e.message.strip().endswith('File exists'):
    print 'Removing /bashrc'
    hadoopy.rmr('/bashrc')
  else:
    raise e

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions