-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
32 lines (22 loc) · 777 Bytes
/
utils.py
File metadata and controls
32 lines (22 loc) · 777 Bytes
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
import subprocess
import sys
from typing import List
import click
import secrets
import string
def run_command(command: List[str], cwd=None, env=None):
print_bold(f'Running command {command}')
p = subprocess.run(command, cwd=cwd, env=env)
if p.returncode != 0:
print_error(f'Command {command} failed!')
sys.exit(1)
def print_error(message: str):
click.secho(message, fg='red', err=True)
def print_success(message: str):
click.secho(message, fg='green', err=True)
def print_bold(message: str):
click.secho(message, bold=True, err=True)
def generate_password(length: int = 20) -> str:
alphabet = string.ascii_letters + string.digits
password = ''.join(secrets.choice(alphabet) for i in range(length))
return password