Skip to content

Commit

Permalink
making 'pwd' module import conditional
Browse files Browse the repository at this point in the history
this commit makes the 'import pwd' only happen on *nix systems, since it's not available on windows

 * #78
  • Loading branch information
maltfield committed Jun 13, 2024
1 parent 391c807 commit 6f6e4fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/packages/buskill/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
################################################################################

import platform, multiprocessing, traceback, subprocess
import urllib.request, re, json, certifi, sys, os, pwd, math, shutil, tempfile, random, gnupg, configparser
import urllib.request, re, json, certifi, sys, os, math, shutil, tempfile, random, gnupg, configparser
import os.path
from buskill_version import BUSKILL_VERSION
from packaging.version import Version
Expand All @@ -31,7 +31,7 @@
# platform-specific modules
CURRENT_PLATFORM = platform.system().upper()
if CURRENT_PLATFORM.startswith( 'LINUX' ):
import usb1, grp
import usb1, grp, pwd
msg = "usb1.__version__:|" +str(usb1.__version__)+ "|"
print( msg ); logger.debug( msg )

Expand All @@ -40,7 +40,7 @@
from ctypes import *

if CURRENT_PLATFORM.startswith( 'DARWIN' ):
import usb1, ctypes, ctypes.util, grp
import usb1, ctypes, ctypes.util, grp, pwd
from ctypes import byref
msg = "usb1.__version__:|" +str(usb1.__version__)+ "|"
print( msg ); logger.debug( msg )
Expand Down Expand Up @@ -671,8 +671,9 @@ def spawn_root_child(self):
msg = "DEBUG: root_child uid owner:|" +str(owner)+ "|"
print( msg ); logger.debug( msg )

msg = "DEBUG: root_child user owner name:|" +str(pwd.getpwuid(owner))+ "|"
print( msg ); logger.debug( msg )
if pwd:
msg = "DEBUG: root_child user owner name:|" +str(pwd.getpwuid(owner))+ "|"
print( msg ); logger.debug( msg )

msg = "DEBUG: root_child gid owner:|" +str(group)+ "|"
print( msg ); logger.debug( msg )
Expand Down

0 comments on commit 6f6e4fe

Please sign in to comment.