8000 Instantiate IOError objects with meaningful values for errno / strerror. · Issue #83 · bwhite/hadoopy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Instantiate IOError objects with meaningful values for errno / strerror. #83
Open
@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
    33B9

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0