Some lint goodness
This commit is contained in:
parent
ce09fce83e
commit
1050e25607
@ -22,7 +22,6 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from decouple import config
|
||||
import subprocess
|
||||
import click
|
||||
@ -31,6 +30,7 @@ from .util import include_exclude_check
|
||||
# TODO: find a place for this
|
||||
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--include', help="only build these containers")
|
||||
@click.option('--exclude', help="don\'t build these containers")
|
||||
@ -53,7 +53,7 @@ def command(ctx, include, exclude):
|
||||
print(f'Dev Root is: {dev_root_path}')
|
||||
|
||||
if not os.path.isdir(dev_root_path):
|
||||
print(f'Dev root directory doesn\'t exist, creating')
|
||||
print('Dev root directory doesn\'t exist, creating')
|
||||
|
||||
with open("container-image-list.txt") as container_list_file:
|
||||
containers = container_list_file.read().splitlines()
|
||||
|
@ -16,18 +16,18 @@
|
||||
# Deploys the system components using docker-compose
|
||||
|
||||
import os
|
||||
import argparse
|
||||
from decouple import config
|
||||
from python_on_whales import DockerClient
|
||||
import click
|
||||
from .util import include_exclude_check
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--include', help="only start these components")
|
||||
@click.option('--exclude', help="don\'t start these components")
|
||||
@click.option("--include", help="only start these components")
|
||||
@click.option("--exclude", help="don\'t start these components")
|
||||
@click.option("--score", help="read list of components from file")
|
||||
@click.argument('command') # help: command: up|down|ps
|
||||
@click.pass_context
|
||||
def command(ctx, include, exclude, command):
|
||||
def command(ctx, include, exclude, score, command):
|
||||
'''deploy a stack'''
|
||||
|
||||
# TODO: implement option exclusion and command value constraint lost with the move from argparse to click
|
||||
|
@ -18,12 +18,12 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
from decouple import config
|
||||
import git
|
||||
from tqdm import tqdm
|
||||
import click
|
||||
|
||||
|
||||
class GitProgress(git.RemoteProgress):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
@ -34,6 +34,7 @@ class GitProgress(git.RemoteProgress):
|
||||
self.pbar.n = cur_count
|
||||
self.pbar.refresh()
|
||||
|
||||
|
||||
def is_git_repo(path):
|
||||
try:
|
||||
_ = git.Repo(path).git_dir
|
||||
@ -46,6 +47,7 @@ def is_git_repo(path):
|
||||
# epilog="Config provided either in .env or settings.ini or env vars: CERC_REPO_BASE_DIR (defaults to ~/cerc)"
|
||||
# )
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--check-only', is_flag=True, default=False)
|
||||
@click.option('--pull', is_flag=True, default=False)
|
||||
@ -81,7 +83,7 @@ def command(ctx, check_only, pull, branches_file):
|
||||
|
||||
if not os.path.isdir(dev_root_path):
|
||||
if not quiet:
|
||||
print(f'Dev root directory doesn\'t exist, creating')
|
||||
print('Dev root directory doesn\'t exist, creating')
|
||||
os.makedirs(dev_root_path)
|
||||
|
||||
with open("repository-list.txt") as repository_list_file:
|
||||
@ -96,7 +98,8 @@ def command(ctx, check_only, pull, branches_file):
|
||||
full_filesystem_repo_path = os.path.join(dev_root_path, repoName)
|
||||
is_present = os.path.isdir(full_filesystem_repo_path)
|
||||
if not quiet:
|
||||
present_text = f'already exists active branch: {git.Repo(full_filesystem_repo_path).active_branch}' if is_present else 'Needs to be fetched'
|
||||
present_text = f'already exists active branch: {git.Repo(full_filesystem_repo_path).active_branch}' if is_present \
|
||||
else 'Needs to be fetched'
|
||||
print(f'Checking: {full_filesystem_repo_path}: {present_text}')
|
||||
# Quick check that it's actually a repo
|
||||
if is_present:
|
||||
@ -118,7 +121,8 @@ def command(ctx, check_only, pull, branches_file):
|
||||
if verbose:
|
||||
print(f'Running git clone for {full_github_repo_path} into {full_filesystem_repo_path}')
|
||||
if not dry_run:
|
||||
git.Repo.clone_from(full_github_repo_path, full_filesystem_repo_path,
|
||||
git.Repo.clone_from(full_github_repo_path,
|
||||
full_filesystem_repo_path,
|
||||
progress=None if quiet else GitProgress())
|
||||
else:
|
||||
print("(git clone skipped)")
|
||||
@ -135,7 +139,5 @@ def command(ctx, check_only, pull, branches_file):
|
||||
git_repo = git.Repo(full_filesystem_repo_path)
|
||||
git_repo.git.checkout(branch_to_checkout)
|
||||
|
||||
|
||||
|
||||
for repo in repos:
|
||||
process_repo(repo)
|
||||
|
@ -14,11 +14,11 @@
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
def include_exclude_check(s, include, exclude):
|
||||
if include == None and exclude == None:
|
||||
if include is None and exclude is None:
|
||||
return True
|
||||
if include != None:
|
||||
if include is not None:
|
||||
include_list = include.split(",")
|
||||
return s in include_list
|
||||
if exclude != None:
|
||||
if exclude is not None:
|
||||
exclude_list = exclude.split(",")
|
||||
return s not in exclude_list
|
||||
|
3
cli.py
3
cli.py
@ -21,6 +21,7 @@ from app import deploy_system
|
||||
|
||||
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
||||
|
||||
|
||||
class Options(object):
|
||||
def __init__(self, quiet, verbose, dry_run, local_stack):
|
||||
self.quiet = quiet
|
||||
@ -33,13 +34,13 @@ class Options(object):
|
||||
@click.option('--verbose', is_flag=True, default=False)
|
||||
@click.option('--dry-run', is_flag=True, default=False)
|
||||
@click.option('--local_stack', is_flag=True, default=False)
|
||||
|
||||
# See: https://click.palletsprojects.com/en/8.1.x/complex/#building-a-git-clone
|
||||
@click.pass_context
|
||||
def cli(ctx, quiet, verbose, dry_run, local_stack):
|
||||
"""Laconic Stack Orchestrator"""
|
||||
ctx.obj = Options(quiet, verbose, dry_run, local_stack)
|
||||
|
||||
|
||||
cli.add_command(setup_repositories.command, "setup-repositories")
|
||||
cli.add_command(build_containers.command, "build-containers")
|
||||
cli.add_command(deploy_system.command, "deploy-system")
|
||||
|
Loading…
Reference in New Issue
Block a user