| import os, subprocess | |
| def read_text(path): | |
| with open(path,'r',encoding='utf-8',errors='ignore') as f: return f.read() | |
| def write_text(path,text): | |
| os.makedirs(os.path.dirname(path) or '.',exist_ok=True) | |
| with open(path,'w',encoding='utf-8') as f: f.write(text) | |
| def run_cmd(cmd,cwd=None): | |
| p=subprocess.Popen(cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE,cwd=cwd) | |
| o,e=p.communicate();return p.returncode,o.decode(),e.decode() | |