Skip to content

Instantly share code, notes, and snippets.

@lizrice
Created August 7, 2014 10:00
Show Gist options
  • Save lizrice/26c0cffdc229c561d612 to your computer and use it in GitHub Desktop.
Save lizrice/26c0cffdc229c561d612 to your computer and use it in GitHub Desktop.
Fab file for connecting and disconnecting to Raspberry PI
from __future__ import with_statement
from fabric.api import local, lcd
# Usage:
# fab connect - mounts /home/pi/<pi_dir> so it's available locally at <workspace><remote>
# fab disconnect - unmount
#
# Note this is Mac specific - Linux distributions use fusermount -u instead of umount
# Requires OSXFUSE and SSHFS from http://osxfuse.github.io/
workspace = "~/Documents/workspace/RPi"
local_dir = "remote"
pi_ip = "10.0.1.17"
pi_dir = "lizmacremote"
def connect():
with lcd(workspace):
cmd = "sshfs -o idmap=user pi@" + pi_ip + ":/home/pi/" + pi_dir + " ./" + local_dir
local(cmd)
def disconnect():
with lcd(workspace):
cmd = "umount ./" + local_dir
local(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment