Skip to content

Commit

Permalink
Prepare pip server file
Browse files Browse the repository at this point in the history
  • Loading branch information
Wh1isper committed Sep 12, 2023
1 parent 05d6e8c commit f361754
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
File renamed without changes.
20 changes: 20 additions & 0 deletions dev-tools/entrypoint-pip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

os.chdir(os.path.dirname(os.path.abspath(__file__)))
os.environ["DUETECTOR_LOG_LEVEL"] = "DEBUG"

import re
import sys
from pathlib import Path

from pkg_resources import load_entry_point

db_file = Path("./duetector-dbcollector.sqlite3")
config_file = Path("./config.toml")

if __name__ == "__main__":
db_file.unlink(missing_ok=True)
sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0])
sys.argv.append("start")
sys.argv.extend(["--config", config_file.resolve().as_posix()])
sys.exit(load_entry_point("duetector", "console_scripts", "duectl")())
18 changes: 18 additions & 0 deletions duetector/cli/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import click


@click.command()
def start():
click.echo("start")


@click.group()
def cli():
pass


cli.add_command(start)


if __name__ == "__main__":
cli(["start"])
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ docs = ["Sphinx<=7.2.4", "sphinx-rtd-theme", "sphinx-click", "autodoc_pydantic"]
[project.scripts]
duectl = "duetector.cli.main:cli"
duectl-daemon = "duetector.cli.daemon:cli"

duectl-server = "duetector.cli.server:cli"

[[project.authors]]
name = "hitsz-ids"
Expand Down

0 comments on commit f361754

Please sign in to comment.