mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-10 14:44:18 +00:00
shield pwd import for windows
This commit is contained in:
parent
3db77fd1a2
commit
79e19ecd47
1 changed files with 10 additions and 2 deletions
|
@ -25,7 +25,6 @@ import os
|
|||
import io
|
||||
import re
|
||||
import sys
|
||||
import pwd
|
||||
import json
|
||||
import getpass
|
||||
import platform
|
||||
|
@ -49,6 +48,15 @@ from .config_stubs import (
|
|||
ConfigDefaultDict,
|
||||
)
|
||||
|
||||
SYSTEM_USER = getpass.getuser() or os.getlogin()
|
||||
|
||||
try:
|
||||
import pwd
|
||||
SYSTEM_USER = pwd.getpwuid(os.geteuid()).pw_name or SYSTEM_USER
|
||||
except ModuleNotFoundError:
|
||||
# pwd is only needed for some linux systems, doesn't exist on windows
|
||||
pass
|
||||
|
||||
############################### Config Schema ##################################
|
||||
|
||||
CONFIG_SCHEMA: Dict[str, ConfigDefaultDict] = {
|
||||
|
@ -313,7 +321,7 @@ ALLOWED_IN_OUTPUT_DIR = {
|
|||
|
||||
DYNAMIC_CONFIG_SCHEMA: ConfigDefaultDict = {
|
||||
'TERM_WIDTH': {'default': lambda c: lambda: shutil.get_terminal_size((100, 10)).columns},
|
||||
'USER': {'default': lambda c: pwd.getpwuid(os.geteuid()).pw_name or getpass.getuser() or os.getlogin()},
|
||||
'USER': {'default': lambda c: SYSTEM_USER},
|
||||
'ANSI': {'default': lambda c: DEFAULT_CLI_COLORS if c['USE_COLOR'] else {k: '' for k in DEFAULT_CLI_COLORS.keys()}},
|
||||
|
||||
'PACKAGE_DIR': {'default': lambda c: Path(__file__).resolve().parent},
|
||||
|
|
Loading…
Reference in a new issue