Skip to content

Instantly share code, notes, and snippets.

@hansen-m
Created July 6, 2016 18:53
Show Gist options
  • Save hansen-m/9c38409b90a8e6a995de52b0b3a916f6 to your computer and use it in GitHub Desktop.
Save hansen-m/9c38409b90a8e6a995de52b0b3a916f6 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# encoding: utf-8
#
import objc, CoreFoundation, Foundation
class attrdict(dict):
__getattr__ = dict.__getitem__
__setattr__ = dict.__setitem__
PrintCore = attrdict()
bundle = objc.initFrameworkWrapper('PrintCore',
frameworkIdentifier=None,
frameworkPath=objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework/Frameworks/PrintCore.framework'),
globals=PrintCore,
scan_classes=False)
del PrintCore["PMServerCreatePrinterList"]
objc.loadBundleFunctions(bundle, PrintCore, [("PMServerCreatePrinterList", b"i@o^@")])
kPMServerLocal = objc.NULL
OSStatus, printerList = PrintCore.PMServerCreatePrinterList(kPMServerLocal, None)
print type(printerList)
print len(printerList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment