parse arguments

This commit is contained in:
Daniel Langbein 2022-04-06 14:55:46 +02:00
parent 3444639000
commit 82bb71a35a
2 changed files with 17 additions and 2 deletions

View File

@ -2,8 +2,12 @@
## Usage ## Usage
usage: `./main.py <docker-container-name> [<ssh-hostname>]`
Example:
```bash ```bash
(venv-310) [user@linux snoflake-stats]$ ./main.py (venv-310) [user@linux snoflake-stats]$ ./main.py snowflake-proxy root_at_my_server
``` ```
## Example output ## Example output

13
main.py
View File

@ -2,12 +2,23 @@
from __future__ import annotations from __future__ import annotations
from typing import List from typing import List
from datetime import datetime from datetime import datetime
import sys
import exec import exec
def main(): def main():
log: str = docker_logs(container_name='snowflake-proxy', ssh_host='rootnas') if len(sys.argv) < 2:
print(f'usage: {sys.argv[0]} <docker-container-name> [<ssh-hostname>]', file=sys.stderr)
exit(1)
container_name = sys.argv[1]
ssh_hostname = None
if len(sys.argv) > 2:
ssh_hostname = sys.argv[2]
log: str = docker_logs(container_name, ssh_hostname)
filtered: List[str] = [line for line in log.splitlines() filtered: List[str] = [line for line in log.splitlines()
if Throughput.PATTERN in line] if Throughput.PATTERN in line]
# filtered = filtered_example() # filtered = filtered_example()