Runs a command and grabs its output from standard output, without all the Fabric associated stuff and other crap (hopefully).
cmdString(str): Command to run
>>> run_and_get_stdout("ls")
["LICENSE", "README.md", "setup.py"]
Returns the home directory for the current user of a given server.
>>> get_home_dir()
"/home/ubuntu"
Downloads a file from a server to a tempfile.NamedTemporaryFile.
NOTE: This function calls the close method on the NamedTemporaryFile.
NOTE: The caller is reponsible for deleting the NamedTemporaryFile.
>>> downloadedFileName = download_remote_file_to_tempfile(
"/home/ubuntu/a/search.rb"
)
>>> with open(downloadedFileName, "r") as f:
# do some processing here...
>>> os.unlink(downloadedFileName) # delete the file
Copies a file to the server if it does not exist there.
localFileName(str): local path of the file to copy to the server
serverFileName(str): path on the server to copy to
>>> copy_file_to_server_if_not_exists("helpers.py",
os.path.join("my-repo", "helpers.py")
)
Checks if a given path on the server is a directory.
>>> is_dir("/home/ubuntu")
True
Updates the package list of the package manager (currently assumed to be apt-get)
>>> update_package_manage_package_lists()
Installs a list of software using the system’s package manager if they have not been installed. Currently this assumes apt-get to be the package manager.
>>> install_software_using_package_manager(
["vim", "openjdk-6-jdk", "unzip"]
)
Determines if a given software is installed on the system by its package manager (currently assumed to be apt-get).
>>> is_installed_using_package_manager("python")
True
Clones the Vundle vim plugin (https://github.com/gmarik/Vundle.vim) to the server (if it hasn’t been cloned), pulls updates, checkout v0.10.2, and installs vim plugins managed by Vundle.
>>> setup-vundle()
Initializes globals in this module. This function should be called before using any public functions defined in this module.
>>> initialize("fabric_git.yaml")
Determines if a directory on a server is under Git control.
>>> is_dir_under_git_control("/home/ubuntu/viki-fabric-helpers")
True
Fabric task that sets up the ssh keys and a wrapper script for GIT_SSH to allow cloning of private Github repositories.
For a Python Fabric script that imports the viki.fabric.git module using:
import viki.fabric.git
we can use this Fabric task from the command line, like so:
fab -H host1,host2,host3 viki.fabric.git.setup_server_for_git_clone
Alternatively, for a Python Fabric script that imports the viki.fabric.git module using:
import viki.fabric.git as fabric_git
we can use this Fabric task from the command like, like so:
fab -H host1,host2,host3 fabric_git.setup_server_for_git_clone
This function can also be called as a normal function (hopefully from within another Fabric task).
Determines if the setup_server_for_git_clone Fabric task has been run.
This task checks for the existence of some files on the server to determine whether the setup_server_for_git_clone task has been run.
>>> is_fabtask_setup_server_for_git_clone_run()
False # along with some other output before this return value
Returns the path to the git ssh script
>>> get_git_ssh_script_path()
"/home/ubuntu/git_ssh_wrap.sh"