[Tutor] 2.7.3 'CalledProcessError' error....why?

Ray Jones crawlzone at gmail.com
Sat Aug 25 00:36:23 CEST 2012


My code:

  try:
    subprocess.check_call(['ping', '-w1', ip])
  except CalledProcessError:
    print 'System', ip, 'is not responding. Exiting....'
    sys.exit(4)
  else: return None

The result:

Traceback (most recent call last):
  File "./testing.py", line 222, in <module>
    main()
  File "./testing.py", line 170, in main
    ip, port, endTime = parse_command_line(args)
  File "./testing.py", line 111, in parse_command_line
    ip = do_ip(args)
  File "./testing.py", line 85, in do_ip
    ping_ip(ip)
  File "./testing.py", line 44, in ping_ip
    except CalledProcessError:
NameError: global name 'CalledProcessError' is not defined

I didn't think Python return errors needed to be defined. I'll work
around it with call_output, but what the heck is going on here? What do
I not understand?


More information about the Tutor mailing list