-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathset-desired-host.py
executable file
·41 lines (30 loc) · 1.21 KB
/
set-desired-host.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
import click
from inbox.error_handling import maybe_enable_rollbar
from inbox.models.account import Account
from inbox.models.session import global_session_scope
@click.command()
@click.argument("account_id")
@click.option("--desired-host")
@click.option("--dry-run", is_flag=True)
@click.option("--toggle-sync", is_flag=True)
def main( # type: ignore[no-untyped-def]
account_id, desired_host, dry_run, toggle_sync
) -> None:
maybe_enable_rollbar()
with global_session_scope() as db_session:
account = db_session.query(Account).get(int(account_id))
print(f"Before sync host: {account.sync_host}")
print(f"Before desired sync host: {account.desired_sync_host}")
print(f"Before sync should run: {account.sync_should_run}")
if dry_run:
return
account.desired_sync_host = desired_host
if toggle_sync:
account.sync_should_run = not account.sync_should_run
print(f"After sync host: {account.sync_host}")
print(f"After desired sync host: {account.desired_sync_host}")
print(f"After sync should run: {account.sync_should_run}")
db_session.commit()
if __name__ == "__main__":
main()