-
-
Save pudquick/1362a8908be01e23041d to your computer and use it in GitHub Desktop.
Hidden Mount Sierra:
mount_options = { NetFS.kNetFSAllowSubMountsKey: True, NetFS.kNetFSMountFlagsKey: 0x00100000 }
Hidden Mount High Sierra:
mount_options = { ' AllowSubMounts': True, 'MountFlags': 0x00100000 }
Some changes need to be made to get this working with Python 3. Specifically the way the username and password is passed for the authenticated mounts - it needs to be sent as a "real" NSString
(thanks @pudquick for the pointer in Macadmins Slack).
Add:
from Foundation import NSString
Change:
objc.loadBundleFunctions(
NetFS_bundle, NetFS, [('NetFSMountURLSync', 'i@@@@@@o^@')])
to:
objc.loadBundleFunctions(
NetFS_bundle, NetFS, [('NetFSMountURLSync', b'i@@@@@@o^@')])
And wherever a user/pass string is passed in:
NSString.alloc().initWithString_('string_to_convert')
@pudquick just wondering if you've revisited this given some deprecations that are going to happen in PyObjC 9:
/usr/local/bin/redlands/mount_shares.py:24: DeprecationWarning: This function will be removed in PyObjC 9, switch to the modern metadata system
NetFS_bundle = objc.initFrameworkWrapper('NetFS', frameworkIdentifier=None, frameworkPath=objc.pathForFramework('NetFS.framework'), 1globals=NetFS, scan_classes=False)
Thanks @pudquick for the chat over Slack about the changes that will be upcoming to PyObjC 9.
For anyone else using this, you should be able to comment out these lines and simply replace it all with import NetFS
and have it work...
(tested against PyObjC
v7.3).
# class attrdict(dict):
# __getattr__ = dict.__getitem__
# __setattr__ = dict.__setitem__
#
#
# NetFS = attrdict()
# # Can cheat and provide 'None' for the identifier,
# # it'll just use frameworkPath instead
# # scan_classes=False means only add the contents of this Framework
# NetFS_bundle = objc.initFrameworkWrapper('NetFS',
# frameworkIdentifier=None,
# frameworkPath=objc.pathForFramework(
# 'NetFS.framework'),
# globals=NetFS,
# scan_classes=False)
# # NetFS_bundle = objc.ObjCLazyModule('NetFS', None, objc.pathForFramework('NetFS.framework'))
#
# # https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
# # Fix NetFSMountURLSync signature
# del NetFS['NetFSMountURLSync']
# objc.loadBundleFunctions(NetFS_bundle, NetFS, [('NetFSMountURLSync', b'i@@@@@@o^@')])
This seems to be broken when run in a recently released preview OS. It complains about open_options = {NetFS.kNAUIOptionKey: NetFS.kNAUIOptionNoUI}. KeyError: 'kNAUIOptionNoUI'