Skip to content

Instantly share code, notes, and snippets.

@eahrold
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eahrold/cbff74461bba8e8e4c0b to your computer and use it in GitHub Desktop.
Save eahrold/cbff74461bba8e8e4c0b to your computer and use it in GitHub Desktop.
Mount an AFP Share (JSSImporter test...)
#!/usr/bin/env python
import urllib
import subprocess, os
''' Set these '''
user = "your_username"
password = "your_password"
server = "your.server.com"
share_point = "CasperShare"
# make adjustments here to test...
safe_string = "~() *!.\'"
''' Done editing '''
mount_point = "/Volumes/%s" % share_point
if not os.path.isfile:
try:
os.mkdir(mount_point)
except:
pass
upass = unicode(password.encode('utf-8'))
encpass = urllib.quote(upass, safe=safe_string)
url = "afp://%s:%s@%s/%s" % (user, encpass, server, share_point)
args = ['mount', '-t', 'afp', url,mount_point]
try:
subprocess.check_call(args)
except Exception , e:
os.rmdir(mount_point)
print e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment