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 io
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import pwd
|
|
||||||
import json
|
import json
|
||||||
import getpass
|
import getpass
|
||||||
import platform
|
import platform
|
||||||
|
@ -49,6 +48,15 @@ from .config_stubs import (
|
||||||
ConfigDefaultDict,
|
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 ##################################
|
||||||
|
|
||||||
CONFIG_SCHEMA: Dict[str, ConfigDefaultDict] = {
|
CONFIG_SCHEMA: Dict[str, ConfigDefaultDict] = {
|
||||||
|
@ -313,7 +321,7 @@ ALLOWED_IN_OUTPUT_DIR = {
|
||||||
|
|
||||||
DYNAMIC_CONFIG_SCHEMA: ConfigDefaultDict = {
|
DYNAMIC_CONFIG_SCHEMA: ConfigDefaultDict = {
|
||||||
'TERM_WIDTH': {'default': lambda c: lambda: shutil.get_terminal_size((100, 10)).columns},
|
'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()}},
|
'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},
|
'PACKAGE_DIR': {'default': lambda c: Path(__file__).resolve().parent},
|
||||||
|
|
Loading…
Add table
Reference in a new issue