Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lyda opened this issue Jul 18, 2014 · 0 comments
Open

Comments

@lyda
Copy link

lyda commented Jul 18, 2014

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant