lint: fix issues
This commit is contained in:
parent
22d8f87746
commit
2bd39b5fdc
|
@ -39,7 +39,11 @@ def teams_bot(ctx):
|
||||||
"--password", type=str, default=None, help="the password of the email account"
|
"--password", type=str, default=None, help="the password of the email account"
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--dbdir", type=str, default="teams_bot_data", help="path to the bot's database", envvar="TEAMS_DBDIR"
|
"--dbdir",
|
||||||
|
type=str,
|
||||||
|
default="teams_bot_data",
|
||||||
|
help="path to the bot's database",
|
||||||
|
envvar="TEAMS_DBDIR",
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-v", "--verbose", count=True, help="show low level delta chat ffi events"
|
"-v", "--verbose", count=True, help="show low level delta chat ffi events"
|
||||||
|
@ -121,7 +125,11 @@ def init(ctx, email: str, password: str, dbdir: str, verbose: int):
|
||||||
|
|
||||||
@teams_bot.command()
|
@teams_bot.command()
|
||||||
@click.option(
|
@click.option(
|
||||||
"--dbdir", type=str, default="teams_bot_data", help="path to the bot's database", envvar="TEAMS_DBDIR"
|
"--dbdir",
|
||||||
|
type=str,
|
||||||
|
default="teams_bot_data",
|
||||||
|
help="path to the bot's database",
|
||||||
|
envvar="TEAMS_DBDIR",
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"-v", "--verbose", count=True, help="show low level delta chat ffi events"
|
"-v", "--verbose", count=True, help="show low level delta chat ffi events"
|
||||||
|
|
|
@ -6,7 +6,9 @@ from pyinfra import host
|
||||||
from pyinfra.facts.systemd import SystemdStatus
|
from pyinfra.facts.systemd import SystemdStatus
|
||||||
|
|
||||||
|
|
||||||
def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str = None):
|
def deploy_teams_bot(
|
||||||
|
unix_user: str, bot_email: str, bot_passwd: str, dbdir: str = None
|
||||||
|
):
|
||||||
"""Deploy TeamsBot to a UNIX user, with specified credentials
|
"""Deploy TeamsBot to a UNIX user, with specified credentials
|
||||||
|
|
||||||
:param unix_user: the existing UNIX user of the bot
|
:param unix_user: the existing UNIX user of the bot
|
||||||
|
@ -26,7 +28,9 @@ def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str
|
||||||
if clone_xdcget.changed:
|
if clone_xdcget.changed:
|
||||||
server.script(
|
server.script(
|
||||||
name="Setup virtual environment for teams-bot",
|
name="Setup virtual environment for teams-bot",
|
||||||
src=importlib.resources.files(__package__) / "pyinfra_assets" / "setup-venv.sh",
|
src=importlib.resources.files(__package__)
|
||||||
|
/ "pyinfra_assets"
|
||||||
|
/ "setup-venv.sh",
|
||||||
_su_user=unix_user,
|
_su_user=unix_user,
|
||||||
_use_su_login=True,
|
_use_su_login=True,
|
||||||
)
|
)
|
||||||
|
@ -43,7 +47,7 @@ def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str
|
||||||
if not dbdir:
|
if not dbdir:
|
||||||
dbdir = f"/home/{unix_user}/.config/teams_bot/{bot_email}/"
|
dbdir = f"/home/{unix_user}/.config/teams_bot/{bot_email}/"
|
||||||
secrets = [
|
secrets = [
|
||||||
f'TEAMS_DBDIR={dbdir}',
|
f"TEAMS_DBDIR={dbdir}",
|
||||||
f"TEAMS_INIT_EMAIL={bot_email}",
|
f"TEAMS_INIT_EMAIL={bot_email}",
|
||||||
f"TEAMS_INIT_PASSWORD={bot_passwd}",
|
f"TEAMS_INIT_PASSWORD={bot_passwd}",
|
||||||
]
|
]
|
||||||
|
@ -66,7 +70,9 @@ def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str
|
||||||
|
|
||||||
files.template(
|
files.template(
|
||||||
name="upload teams-bot systemd unit",
|
name="upload teams-bot systemd unit",
|
||||||
src=importlib.resources.files(__package__) / "pyinfra_assets" / "teams-bot.service.j2",
|
src=importlib.resources.files(__package__)
|
||||||
|
/ "pyinfra_assets"
|
||||||
|
/ "teams-bot.service.j2",
|
||||||
dest=f"/home/{unix_user}/.config/systemd/user/teams-bot.service",
|
dest=f"/home/{unix_user}/.config/systemd/user/teams-bot.service",
|
||||||
user=unix_user,
|
user=unix_user,
|
||||||
unix_user=unix_user,
|
unix_user=unix_user,
|
||||||
|
@ -85,12 +91,18 @@ def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str
|
||||||
commands=[f"loginctl enable-linger {unix_user}"],
|
commands=[f"loginctl enable-linger {unix_user}"],
|
||||||
)
|
)
|
||||||
|
|
||||||
services = host.get_fact(SystemdStatus, user_mode=True, user_name=unix_user, _su_user=unix_user, _use_su_login=True)
|
services = host.get_fact(
|
||||||
|
SystemdStatus,
|
||||||
|
user_mode=True,
|
||||||
|
user_name=unix_user,
|
||||||
|
_su_user=unix_user,
|
||||||
|
_use_su_login=True,
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
if services['teams-bot.service']:
|
if services["teams-bot.service"]:
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name=f"{unix_user}: restart teams-bot systemd service",
|
name=f"{unix_user}: restart teams-bot systemd service",
|
||||||
service='teams-bot.service',
|
service="teams-bot.service",
|
||||||
running=True,
|
running=True,
|
||||||
restarted=True,
|
restarted=True,
|
||||||
user_mode=True,
|
user_mode=True,
|
||||||
|
|
Loading…
Reference in a new issue