@task
def install_crontab():
  """Install or remove crontab for given node type."""
  assert env.nodetype, 'no nodetype specified'
  assert env.host_string, 'no hosts specified'
  cron_file = '~/viewfinder/scripts/crontab.%s' % env.nodetype.lower()
  # Run 'crontab <filename>' if the remote file exists, otherwise run 'crontab -r'.
  # Warn only as 'crontab -r' fails if no crontab is installed.
  with settings(warn_only=True):
    run('if [ -e %s ]; then crontab %s; else crontab -r; fi' % (cron_file, cron_file))
dataset/ETHPy150Open viewfinderco/viewfinder/fabfile.py/install_crontab/original