Commits (6)
# This file is a template, and might need editing before it works on your project.
# Official language image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/python/tags/
image: python:latest
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
stages:
- build
- test
- deploy
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
before_script:
- python -V # Print out python version for debugging
- pip install -U virtualenv
- virtualenv venv
- source venv/bin/activate
- pip install -U twine
- pip install -U pytest mypy
mypy:
stage: test
script:
- mypy yaqd_control
run:
stage: build
script:
- python setup.py sdist bdist_wheel
- pip install -U dist/*.whl
artifacts:
paths:
- dist/*
deploy_twine:
stage: deploy
script:
- twine upload dist/*
artifacts:
paths:
- dist/*
only:
- tags
repos:
- repo: https://github.com/python/black
rev: stable
- repo: https://github.com/psf/black
rev: master
hooks:
- id: black
language_version: python3.7
- id: black
name: black
language: system
entry: black
require_serial: true
types: [python]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.740
hooks:
- id: mypy
exclude: ^docs/conf.py
include LICENSE
include README.md
\ No newline at end of file
......@@ -5,7 +5,7 @@ import pathlib
import subprocess
import sys
import appdirs
import appdirs # type: ignore
import click
from ._cache import add_config, clear_cache, read_daemon_cache
from ._enablement import enable, disable, start, stop, reload, restart
......@@ -32,12 +32,6 @@ def _scan(host, start, stop):
scan(host=host, start=start, stop=stop)
@main.command(name="start")
@click.argument("directory", required=False, type=click.Path())
def _start(directory):
start(directory)
@main.command(name="edit-config")
@click.argument("kind", nargs=-1)
def edit_config(kind):
......
......@@ -2,7 +2,7 @@ __all__ = ["read_daemon_cache", "write_daemon_cache"]
import pathlib
import appdirs
import appdirs # type: ignore
import toml
from ._daemon_data import DaemonData
......@@ -66,6 +66,10 @@ def add_config(filepath):
if k in ("entry", "enable", "shared-settings"):
continue
dd = DaemonData(
kind=kind, host="127.0.0.1", port=v["port"], name=k, config_filepath=str(filepath)
kind=kind,
host="127.0.0.1",
port=v["port"],
name=k,
config_filepath=str(filepath),
)
write_to_daemon_cache(dd)
......@@ -6,7 +6,7 @@ import subprocess
import sys
import tempfile
import appdirs
import appdirs # type: ignore
from ._cache import add_config, read_daemon_cache
......
__all__ = [list]
__all__ = ["list"]
from ._cache import read_daemon_cache
import prettytable
import prettytable # type: ignore
def list():
......
......@@ -3,7 +3,7 @@ import pathlib
import subprocess
import sys
import appdirs
import appdirs # type: ignore
import toml
......@@ -31,5 +31,7 @@ def start(config_dir=None):
cmd = [cd["entry"], "--config", str(fp)]
print(fp)
proc = subprocess.Popen(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
proc = subprocess.Popen(
cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL
)
print(f"PID: {proc.pid} - {' '.join(cmd)}")
......@@ -3,8 +3,8 @@ __all__ = ["status"]
import json
import socket
import prettytable
import colorama
import prettytable # type: ignore
import colorama # type: ignore
from colorama import Fore
from ._cache import read_daemon_cache
......@@ -25,10 +25,19 @@ def status():
s.sendall(b'{"jsonrpc":"2.0", "method": "busy", "id":"status"}')
ident = json.loads(s.recv(1024))
out.add_row(
[daemon.host, daemon.port, daemon.kind, daemon.name, "online", ident["result"]]
[
daemon.host,
daemon.port,
daemon.kind,
daemon.name,
"online",
ident["result"],
]
)
except Exception as e:
out.add_row([daemon.host, daemon.port, daemon.kind, daemon.name, "offline", "?"])
out.add_row(
[daemon.host, daemon.port, daemon.kind, daemon.name, "offline", "?"]
)
out = out.get_string()
out = colorify(out, "online", Fore.GREEN)
out = colorify(out, "offline", Fore.RED)
......