<commit_before>'''Fabric script to deploy d1_service_status.py script to CNs

For an initial deployment::

  export CN=cn-dev-unm-1.test.dataone.org
  fab -I -H ${CN} deployToCN
  

To update an existing deployment::

  export CN=cn-dev-unm-1.test.dataone.org
  fab -H ${CN} updateDeployedScript

'''
import os
from fabric.api import run, sudo, put, quiet

'''
HOSTS="cn-dev-ucsb-1.test.dataone.org,cn-dev-unm-1.test.dataone.org,cn-dev-orc-1.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-dev-ucsb-2.test.dataone.org,cn-dev-unm-2.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-sandbox-ucsb-1.test.dataone.org,cn-sandbox-unm-1.test.dataone.org,cn-sandbox-orc-1.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-sandbox-ucsb-1.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-stage-ucsb-1.test.dataone.org,cn-stage-unm-1.test.dataone.org,cn-stage-orc-1.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-stage-unm-2.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-ucsb-1.dataone.org,cn-unm-1.dataone.org,cn-orc-1.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
'''

SCRIPT_FILE = "d1_service_status.py"
CROND_FILE = "d1_service_status_cron" 

def updateDeployedScript():
  '''
  Overwrite the deployed script with the current one.
  '''
  put(os.path.join('script/',SCRIPT_FILE), "/usr/local/bin", use_sudo=True, mode=0755)
  sudo("/usr/local/bin/d1_service_status -")


def deployToCN():
  '''Deploy the script, create a symlink, and add to cron
  '''
  put(os.path.join('script/',SCRIPT_FILE), "/usr/local/bin", use_sudo=True)
  run( "chmod a+x /usr/local/bin/" + SCRIPT_FILE )
  with quiet():
    sudo( "rm /usr/local/bin/d1_service_status")
    sudo( "ln -s /usr/local/bin/" + SCRIPT_FILE + " /usr/local/bin/d1_service_status" )
  #cron.d file must be owned by root and writable only by root.
  put(os.path.join('script/', CROND_FILE), "/etc/cron.d/", use_sudo=True, mode=0644)
  sudo( "chown root:root /etc/cron.d/" + CROND_FILE)
  run("/usr/local/bin/d1_service_status -")
<commit_msg>Updated comments.<commit_after>'''Fabric script to deploy d1_service_status.py script to CNs

For an initial deployment::

  export CN=cn-dev-unm-1.test.dataone.org
  fab -I -H ${CN} deployToCN
  

To update an existing deployment::

  export CN=cn-dev-unm-1.test.dataone.org
  fab -H ${CN} updateDeployedScript

'''
import os
from fabric.api import run, sudo, put, quiet

'''
HOSTS="cn-dev-ucsb-1.test.dataone.org,cn-dev-unm-1.test.dataone.org,cn-dev-orc-1.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-dev-ucsb-2.test.dataone.org,cn-dev-unm-2.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-sandbox-ucsb-1.test.dataone.org,cn-sandbox-unm-1.test.dataone.org,cn-sandbox-orc-1.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-sandbox-ucsb-2.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-stage-ucsb-1.test.dataone.org,cn-stage-unm-1.test.dataone.org,cn-stage-orc-1.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-stage-unm-2.test.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript
HOSTS="cn-ucsb-1.dataone.org,cn-unm-1.dataone.org,cn-orc-1.dataone.org"
fab -I -H ${HOSTS} updateDeployedScript

HOSTS="cn-dev-ucsb-1.test.dataone.org,cn-dev-unm-1.test.dataone.org,cn-dev-orc-1.test.dataone.org"
HOSTS="${HOSTS},cn-dev-ucsb-2.test.dataone.org,cn-dev-unm-2.test.dataone.org"
HOSTS="${HOSTS},cn-sandbox-ucsb-1.test.dataone.org,cn-sandbox-unm-1.test.dataone.org,cn-sandbox-orc-1.test.dataone.org"
HOSTS="${HOSTS},cn-sandbox-ucsb-2.test.dataone.org"
HOSTS="${HOSTS},cn-stage-ucsb-1.test.dataone.org,cn-stage-unm-1.test.dataone.org,cn-stage-orc-1.test.dataone.org"
HOSTS="${HOSTS},cn-stage-unm-2.test.dataone.org"
HOSTS="${HOSTS},cn-ucsb-1.dataone.org,cn-unm-1.dataone.org,cn-orc-1.dataone.org"

'''

SCRIPT_FILE = "d1_service_status.py"
CROND_FILE = "d1_service_status_cron" 

def updateDeployedScript():
  '''
  Overwrite the deployed script with the current one.
  '''
  put(os.path.join('script/',SCRIPT_FILE), "/usr/local/bin", use_sudo=True, mode=0755)
  sudo("/usr/local/bin/d1_service_status -")


def deployToCN():
  '''Deploy the script, create a symlink, and add to cron
  '''
  put(os.path.join('script/',SCRIPT_FILE), "/usr/local/bin", use_sudo=True)
  run( "chmod a+x /usr/local/bin/" + SCRIPT_FILE )
  with quiet():
    sudo( "rm /usr/local/bin/d1_service_status")
    sudo( "ln -s /usr/local/bin/" + SCRIPT_FILE + " /usr/local/bin/d1_service_status" )
  #cron.d file must be owned by root and writable only by root.
  put(os.path.join('script/', CROND_FILE), "/etc/cron.d/", use_sudo=True, mode=0644)
  sudo( "chown root:root /etc/cron.d/" + CROND_FILE)
  run("/usr/local/bin/d1_service_status -")

{'fraction_non_alphanumeric': 0.17866777339697032, 'fraction_numerical': 0.017015978418759077, 'mean_word_length': 4.2967032967032965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4753284', 'n_tokens_mistral': 2098, 'n_tokens_neox': 2033, 'n_words': 316}