(config: ConfigDict=CONFIG)
| 1204 | |
| 1205 | |
| 1206 | def check_system_config(config: ConfigDict=CONFIG) -> None: |
| 1207 | ### Check system environment |
| 1208 | if config['USER'] == 'root' or str(config['PUID']) == "0": |
| 1209 | stderr('[!] ArchiveBox should never be run as root!', color='red') |
| 1210 | stderr(' For more information, see the security overview documentation:') |
| 1211 | stderr(' https://github.com/ArchiveBox/ArchiveBox/wiki/Security-Overview#do-not-run-as-root') |
| 1212 | |
| 1213 | if config['IN_DOCKER']: |
| 1214 | attempted_command = ' '.join(sys.argv[:3]) |
| 1215 | stderr('') |
| 1216 | stderr(' {lightred}Hint{reset}: When using Docker, you must run commands with {green}docker run{reset} instead of {lightyellow}docker exec{reset}, e.g.:'.format(**config['ANSI'])) |
| 1217 | stderr(f' docker compose run archivebox {attempted_command}') |
| 1218 | stderr(f' docker run -it -v $PWD/data:/data archivebox/archivebox {attempted_command}') |
| 1219 | stderr(' or:') |
| 1220 | stderr(f' docker compose exec --user=archivebox archivebox /bin/bash -c "archivebox {attempted_command}"') |
| 1221 | stderr(f' docker exec -it --user=archivebox <container id> /bin/bash -c "archivebox {attempted_command}"') |
| 1222 | |
| 1223 | raise SystemExit(2) |
| 1224 | |
| 1225 | ### Check Python environment |
| 1226 | if sys.version_info[:3] < (3, 7, 0): |
| 1227 | stderr(f'[X] Python version is not new enough: {config["PYTHON_VERSION"]} (>3.6 is required)', color='red') |
| 1228 | stderr(' See https://github.com/ArchiveBox/ArchiveBox/wiki/Troubleshooting#python for help upgrading your Python installation.') |
| 1229 | raise SystemExit(2) |
| 1230 | |
| 1231 | if int(CONFIG['DJANGO_VERSION'].split('.')[0]) < 3: |
| 1232 | stderr(f'[X] Django version is not new enough: {config["DJANGO_VERSION"]} (>3.0 is required)', color='red') |
| 1233 | stderr(' Upgrade django using pip or your system package manager: pip3 install --upgrade django') |
| 1234 | raise SystemExit(2) |
| 1235 | |
| 1236 | if config['PYTHON_ENCODING'] not in ('UTF-8', 'UTF8'): |
| 1237 | stderr(f'[X] Your system is running python3 scripts with a bad locale setting: {config["PYTHON_ENCODING"]} (it should be UTF-8).', color='red') |
| 1238 | stderr(' To fix it, add the line "export PYTHONIOENCODING=UTF-8" to your ~/.bashrc file (without quotes)') |
| 1239 | stderr(' Or if you\'re using ubuntu/debian, run "dpkg-reconfigure locales"') |
| 1240 | stderr('') |
| 1241 | stderr(' Confirm that it\'s fixed by opening a new shell and running:') |
| 1242 | stderr(' python3 -c "import sys; print(sys.stdout.encoding)" # should output UTF-8') |
| 1243 | raise SystemExit(2) |
| 1244 | |
| 1245 | # stderr('[i] Using Chrome binary: {}'.format(shutil.which(CHROME_BINARY) or CHROME_BINARY)) |
| 1246 | # stderr('[i] Using Chrome data dir: {}'.format(os.path.abspath(CHROME_USER_DATA_DIR))) |
| 1247 | if config['CHROME_USER_DATA_DIR'] is not None: |
| 1248 | if not (Path(config['CHROME_USER_DATA_DIR']) / 'Default').exists(): |
| 1249 | stderr('[X] Could not find profile "Default" in CHROME_USER_DATA_DIR.', color='red') |
| 1250 | stderr(f' {config["CHROME_USER_DATA_DIR"]}') |
| 1251 | stderr(' Make sure you set it to a Chrome user data directory containing a Default profile folder.') |
| 1252 | stderr(' For more info see:') |
| 1253 | stderr(' https://github.com/ArchiveBox/ArchiveBox/wiki/Configuration#CHROME_USER_DATA_DIR') |
| 1254 | if '/Default' in str(config['CHROME_USER_DATA_DIR']): |
| 1255 | stderr() |
| 1256 | stderr(' Try removing /Default from the end e.g.:') |
| 1257 | stderr(' CHROME_USER_DATA_DIR="{}"'.format(config['CHROME_USER_DATA_DIR'].split('/Default')[0])) |
| 1258 | raise SystemExit(2) |
| 1259 | |
| 1260 | |
| 1261 | def check_dependencies(config: ConfigDict=CONFIG, show_help: bool=True) -> None: |
no test coverage detected