def _query_solr(base_path, connection, query, directory, start, end, interval): with cd(base_path): lrun('python local/solr_tasks.py -c {0} -q {1} -d {2} -i {3} -s {4} -e {5}'.format( connection, query, directory, interval, start, end ))
def deploy(tests='run'): """ Tests and ships itwêwina on to Sapir. """ if tests == 'run': integration_tests() # Fast-forward production's branch to development, and push! lrun('git fetch . development:sapir') lrun('git push origin sapir:sapir') ship_it()
def integration_tests(): """ Run Cypress integration tests. This starts a development server on http://localhost:5000, and shuts it down when the tests are done. Integrations can ONLY be run locally. """ from fabric.operations import local as lrun if env.hosts != ['localhost']: abort(red("** can only run integration tests on localhost")) with development_server(): lrun("npm run cypress:run")
def return_pipeline_counts(base_path, directories): counts = [] with cd(base_path): for d in directories.split(';'): counts.append((d, lrun('ls -l {0} | wc -l'.format(d)))) for d, c in counts: print(blue('{0} contains {1} files'.format(d, c)))
def provision(): """ Provisions (setup for the first time) itwêwina on Sapir. This means cloning the repository, setting up the virtualenv, and patching the Babel locales. """ require_sapir_or_staging() require_itwewina() # Clone the repo clone_url = lrun('git remote get-url origin', capture=True) with cd(env.clone_path): run('git clone %s itwewina --branch sapir' % clone_url) assert env.itwewina_path.startswith(env.clone_path),\ 'did not find itwewina within the clone path' # Setup the virtualenv with cd(env.itwewina_path): run('virtualenv %s' % env.virtualenv_path) with prefix('source %s/bin/activate' % env.virtualenv_path): run('pip install -r requirements.txt') # Create dummy locales for 'crk'. Python-Babel crashes if these files aren't # there, but it doesn't actually use them for anything important ¯\_(ツ)_/¯ locale_dir = os.path.join( env.virtualenv_path, 'lib', 'python2.7', 'site-packages', 'babel', 'locale-data' ) with cd(locale_dir): for locale in ('crk', 'crk_Macr', 'crk_Syll'): run('cp en_CA.dat %s.dat' % locale)
def _run_pipeline(base_path, workflow, local_config, local_directory, start, end, interval): with cd(base_path): lrun('python workflow_manager.py -w {0} -d {1} -c {2} -s {3} -e {4} -i {5}'.format( workflow, local_directory, local_config, start, end, interval))
def _clear_outputs(base_path, empties): # list of directory paths (pipes/cleaned/*) with cd(base_path): for empty in empties.split(';'): lrun('rm -rf %s' % empty)
def help(): '''Fabfile documentation''' lrun('python -c "import fabfile; help(fabfile)"')
def start_weblogic(duser, dpassword, dhostname, dport, cluster): '''Start weblogic VM''' lrun('''/home/oracle/start.sh -u {0} -p {1} -h {2}:{3} -c {4}'''.format( duser, dpassword, dhostname, dport, cluster))
def run_fabric(self, command): from fabric.api import local as lrun lrun(command)