Created
July 6, 2016 18:53
-
-
Save hansen-m/9c38409b90a8e6a995de52b0b3a916f6 to your computer and use it in GitHub Desktop.
This file contains 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/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