Esempio n. 1
0
def api_state(data_dragon: DataDragon, remote_url: Optional[str]):
  data_dragon_path = Path(__file__).parent.parent if remote_url is None else Path(data_dragon.remote_data_dragon_path(remote_url=remote_url)).parent
  script = f'''
set -e
cd {process.escape_run_arg(run_arg=data_dragon_path)}
echo '––– Code state'
git remote update
git --no-pager diff
git --no-pager log -n 1
echo '––– Python state'
source python/environment/bin/activate
pip freeze
echo '––– Node state'
cat package-lock.json
echo '––– Status'
git status
'''
  run_args = process.script_command(script=script)
  _, out, error = data_dragon.run_remote_process(
    run_args=run_args,
    remote_url=remote_url or '',
    confirm=False,
    capture_output=True,
    shell=True
  )
  newline = '\n'
  state = f'{out.decode()}{f"{newline}Error output:{newline}{error.decode()}" if error else ""}'
  state_path = Path(__file__).parent.parent / 'output' / 'state' / f'api_state_{data_dragon.user.safe_file_name(name=remote_url if remote_url else "local")}_{data_dragon.user.date_file_name()}.txt'
  state_path.write_text(state)
  log.log(f'{state}\nAPI state written to {state_path}')
Esempio n. 2
0
def api_install(data_dragon: DataDragon, remote_url: Optional[str]):
  data_dragon_path = Path(__file__).parent.parent if remote_url is None else Path(data_dragon.remote_data_dragon_path(remote_url=remote_url)).parent
  script = f'''
set -e
cd {process.escape_run_arg(run_arg=data_dragon_path)}
./install.sh
'''
  run_args = process.script_command(script=script)
  data_dragon.run_remote_process(
    run_args=run_args,
    remote_url=remote_url or '',
    confirm=False,
    shell=True
  )
Esempio n. 3
0
def api_pull(data_dragon: DataDragon, pull_branch: str, remote_url: Optional[str]):
  data_dragon_path = Path(__file__).parent.parent if remote_url is None else Path(data_dragon.remote_data_dragon_path(remote_url=remote_url)).parent
  script = f'''
set -e
cd {process.escape_run_arg(run_arg=data_dragon_path)}
git remote update
git checkout {process.escape_run_arg(run_arg=pull_branch)}
git pull
git submodule update
git status
'''
  run_args = process.script_command(script=script)
  data_dragon.run_remote_process(
    run_args=run_args,
    remote_url=remote_url or '',
    confirm=False,
    shell=True
  )
Esempio n. 4
0
def ux_deploy(data_dragon: DataDragon, pull_branch: Optional[str], remote_url: str):
  url, _ = ResourceLocator.strip_locator_parameters(url=ResourceLocator.dealias_url(url=remote_url))
  parts = urllib.parse.urlparse(url)
  remote = urllib.parse.urlunparse((*parts[:5], ''))
  branch = parts.fragment
  datadragon_ux_path = Path(__file__).parent.parent / 'angular-datadragon'
  pull_commands = f'''
git checkout {process.escape_run_arg(pull_branch)}
git pull
git submodule update
''' if pull_branch else ''
  script = f'''
set -e
cd {process.escape_run_arg(datadragon_ux_path)}
{pull_commands}
git push {remote} HEAD:{branch}
git status
'''
  run_args = process.script_command(script=script)
  data_dragon.run_local_process(
    run_args=run_args,
    shell=True
  )
Esempio n. 5
0
def ux_state(data_dragon: DataDragon, remote_url: str):
  url, _ = ResourceLocator.strip_locator_parameters(url=ResourceLocator.dealias_url(url=remote_url))
  parts = urllib.parse.urlparse(url)
  remote = urllib.parse.urlunparse((*parts[:5], ''))
  branch = parts.fragment
  datadragon_ux_path = Path(__file__).parent.parent / 'angular-datadragon'
  script = f'''
set -e
cd {process.escape_run_arg(datadragon_ux_path)}
git fetch -f {remote} {branch}:_ux_state
git --no-pager log -n 1 _ux_state
'''
  run_args = process.script_command(script=script)
  _, out, error = data_dragon.run_local_process(
    run_args=run_args,
    confirm=False,
    capture_output=True,
    shell=True
  )
  newline = '\n'
  state = f'{out.decode()}{f"{newline}Error output:{newline}{error.decode()}" if error else ""}'
  state_path = Path(__file__).parent.parent / 'output' / 'state' / f'ux_state_{data_dragon.user.safe_file_name(name=remote_url)}_{data_dragon.user.date_file_name()}.txt'
  state_path.write_text(state)
  log.log(f'{state}\nUX state written to {state_path}')
Esempio n. 6
0
def api_stop(data_dragon: DataDragon):
  data_dragon.run_local_process(
    run_args=process.script_command(script=data_dragon.configuration['api_stop_command']),
    confirm=False,
    shell=True
  )