dotfiles/tasks/util.py

22 lines
514 B
Python
Raw Normal View History

2014-10-21 12:00:04 -06:00
import errno
import os
from invoke import run
REPO_DIRECTORY = os.path.dirname(os.path.dirname(__file__))
DOTFILES_DIRECTORY = os.path.join(REPO_DIRECTORY, 'dotfiles')
RESOURCES_DIRECTORY = os.path.join(REPO_DIRECTORY, 'resources')
def command_exists(command, run=run):
return run("hash {0}".format(command), warn=True, hide=True).exited == 0
2014-10-21 12:00:04 -06:00
def ensure_path_exists(path):
try:
os.makedirs(path)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise