Safer subprocess helper for commands that do not need shell expansion.
(command, cwd=None, capture=True, check=False)
| 1157 | |
| 1158 | def update_dedsec(repo_url=REPO_URL_SOURCE_1, repo_api_url=REPO_API_URL_SOURCE_1): |
| 1159 | repo_size = get_github_repo_size(repo_api_url) |
| 1160 | print(f"[+] {_('GitHub repository size')}: {repo_size}") |
| 1161 | existing_dedsec_path = find_dedsec() |
| 1162 | update_changed = False |
| 1163 | update_error = None |
| 1164 | try: |
| 1165 | if existing_dedsec_path: |
| 1166 | branch = git_remote_default_branch(repo_url, cwd=existing_dedsec_path) |
| 1167 | subprocess.run( |
| 1168 | [shutil.which("git") or "git", "remote", "set-url", "origin", repo_url], |
| 1169 | cwd=existing_dedsec_path, check=False, |
| 1170 | ) |
| 1171 | fetch = subprocess.run( |
| 1172 | [shutil.which("git") or "git", "fetch", "--prune", "origin", branch], |
| 1173 | cwd=existing_dedsec_path, capture_output=True, text=True, check=False, |
| 1174 | ) |
| 1175 | if fetch.returncode != 0: |
no test coverage detected