| 93 | |
| 94 | |
| 95 | class RecklessResult: |
| 96 | def __init__(self, process, returncode, stdout, stderr): |
| 97 | self.process = process |
| 98 | self.returncode = returncode |
| 99 | self.stdout = stdout |
| 100 | self.stderr = stderr |
| 101 | |
| 102 | def __repr__(self): |
| 103 | return f'self.returncode, self.stdout, self.stderr' |
| 104 | |
| 105 | def search_stdout(self, regex): |
| 106 | """return the matching regex line from reckless output.""" |
| 107 | ex = re.compile(regex) |
| 108 | matching = [] |
| 109 | for line in self.stdout: |
| 110 | if ex.search(line): |
| 111 | matching.append(line) |
| 112 | return matching |
| 113 | |
| 114 | def check_stderr(self): |
| 115 | def output_okay(out): |
| 116 | for warning in ['[notice]', 'WARNING:', 'npm WARN', |
| 117 | 'npm notice', 'DEPRECATION:', 'Creating virtualenv', |
| 118 | 'config file not found:', 'press [Y]']: |
| 119 | if out.startswith(warning): |
| 120 | return True |
| 121 | return False |
| 122 | for e in self.stderr: |
| 123 | if len(e) < 1: |
| 124 | continue |
| 125 | # Don't err on verbosity from pip, npm |
| 126 | if not output_okay(e): |
| 127 | raise Exception(f'reckless stderr contains `{e}`') |
| 128 | |
| 129 | |
| 130 | def reckless(cmds: list, dir: PosixPath = None, |