Created
August 24, 2010 17:52
-
-
Save silverjam/547970 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./osstatus -108 | |
Error number: -108 / 0xffffff94 | |
Error string: memFullErr / iMemFullErr | |
Error description: Not enough room in heap zone / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Convert OSStatus to a human readable string. | |
""" | |
import sys | |
from ctypes import * | |
def die_with_usage(): | |
sys.stderr.write("Usage: %s <ERROR_CODE>\n" % sys.argv[0]) | |
sys.exit(1) | |
if len(sys.argv) < 2: | |
die_with_usage() | |
try: | |
err = int(sys.argv[1]) | |
except ValueError: | |
die_with_usage() | |
cs = CDLL( | |
"/System/Library/Frameworks/CoreServices.framework" | |
"/Versions/Current/CoreServices" | |
) | |
print('Error number:\t\t%d / 0x%x' % (err, c_uint32(err).value)) | |
cs.GetMacOSStatusErrorString.restype = c_char_p | |
errorString = cs.GetMacOSStatusErrorString(c_uint32(err)) | |
print('Error string:\t\t%s' % str(errorString)) | |
cs.GetMacOSStatusCommentString.restype = c_char_p | |
errorDesc = cs.GetMacOSStatusCommentString(c_uint32(err)) | |
print('Error description:\t%s' % errorDesc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use int(value, 0), then the script interprets hex easily as well.