Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
rexzhang committed Nov 21, 2023
1 parent 0ee0499 commit 2d52705
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python_project/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python


from .core import PyPIPackageProject # noqa: F401

__name__ = "PyPIPackageProjectTemplate"
__version__ = "0.x.0"
22 changes: 22 additions & 0 deletions python_project/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python


"""
The main entry point. Invoke as `python_module_project' or
`python -m python_module_project'.
"""

import sys


def main():
try:
from .cli import main as cli_main

sys.exit(cli_main())
except KeyboardInterrupt:
sys.exit(1)


if __name__ == "__main__":
main()
57 changes: 57 additions & 0 deletions python_project/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import os
import sys
from logging import getLogger

import click
import uvicorn

logger = getLogger(__name__)


@click.group()
def cli(**cli_kwargs):
# do something
return


@cli.command("runserver")
@click.option(
"-H",
"--host",
default="127.0.0.1",
help="Bind socket to this host. [default: 127.0.0.1]",
)
@click.option(
"-P", "--port", default=8000, help="Bind socket to this port. [default: 8000]"
)
def runserver(**cli_kwargs):
kwargs = {
"app": "ddns_clienter.asgi:application",
# "host": host,
# "port": port,
"lifespan": "off",
"log_level": "info",
"access_log": False,
}
kwargs.update(cli_kwargs)

return uvicorn.run(**kwargs)


@cli.command("check_and_push")
@click.option("-C", "--config", required=True, type=str, help="config.toml")
def check_and_push(**cli_kwargs):
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ddns_clienter.settings")
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


def main():
cli()
5 changes: 5 additions & 0 deletions python_project/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python


class PyPIPackageProject:
pass

0 comments on commit 2d52705

Please sign in to comment.