remove most rdp refs
This commit is contained in:
parent
49f8cb54a1
commit
c15e6cb082
@ -1,5 +1,3 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
|
45
flupdt/common.py
Normal file
45
flupdt/common.py
Normal file
@ -0,0 +1,45 @@
|
||||
"""common."""
|
||||
|
||||
import itertools
|
||||
import logging
|
||||
import sys
|
||||
|
||||
|
||||
def configure_logger(level: str = "INFO") -> None:
|
||||
"""Configure the logger.
|
||||
|
||||
Args:
|
||||
level (str, optional): The logging level. Defaults to "INFO".
|
||||
"""
|
||||
logging.basicConfig(
|
||||
level=level,
|
||||
datefmt="%Y-%m-%dT%H:%M:%S%z",
|
||||
format="%(asctime)s %(levelname)s %(filename)s:%(lineno)d - %(message)s",
|
||||
handlers=[logging.StreamHandler(sys.stdout)],
|
||||
)
|
||||
|
||||
def partition(predicate, iterable):
|
||||
"""Partition entries into false entries and true entries.
|
||||
|
||||
If *predicate* is slow, consider wrapping it with functools.lru_cache().
|
||||
"""
|
||||
# partition(is_odd, range(10)) → 0 2 4 6 8 and 1 3 5 7 9
|
||||
t1, t2 = itertools.tee(iterable)
|
||||
return itertools.filterfalse(predicate, t1), filter(predicate, t2)
|
||||
|
||||
def bash_wrapper(command: str, path: str = ".") -> tuple[str, str, int]:
|
||||
"""Execute a bash command and capture the output.
|
||||
|
||||
Args:
|
||||
command (str): The bash command to be executed.
|
||||
path (str): The current working directory, '.' by default
|
||||
|
||||
Returns:
|
||||
Tuple[str, int]: A tuple containing the output of the command (stdout) as a string,
|
||||
the error output (stderr) as a string (optional), and the return code as an integer.
|
||||
"""
|
||||
# This is a acceptable risk
|
||||
process = Popen(command.split(), stdout=PIPE, stderr=PIPE, cwd=path) # noqa: S603
|
||||
output, error = process.communicate()
|
||||
|
||||
return output.decode(), error.decode(), process.returncode
|
@ -1,8 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import logging
|
||||
from typing import Optional
|
||||
from rad_development_python import bash_wrapper
|
||||
from flupdt.common import bash_wrapper
|
||||
import re
|
||||
|
||||
drv_re = re.compile(r".*(/nix/store/.*\.drv).*")
|
||||
|
@ -6,7 +6,7 @@ import re
|
||||
import shutil
|
||||
import typing
|
||||
|
||||
from rad_development_python import bash_wrapper
|
||||
from flupdt.common import bash_wrapper
|
||||
|
||||
output_regexes = [
|
||||
re.compile(r"checking derivation (.*)..."),
|
||||
|
@ -4,7 +4,6 @@ from flupdt.flake_show import get_derivations
|
||||
from flupdt.cli import parse_inputs
|
||||
from flupdt.flake_eval import evaluate_output
|
||||
import logging
|
||||
import rad_development_python as rd
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user