Skip to content

Commit

Permalink
import grp conditionally
Browse files Browse the repository at this point in the history
This commit only imports grp on *nix systems, since it isn't available on windows systems, and it will throw an error

 * #78 (comment)

  Traceback (most recent call last:):
   File "main .py", line 22 in <module>
    import platform, os, grp
  ModuleNotFoundError: No module named 'grp'
  • Loading branch information
maltfield committed Jun 10, 2024
1 parent 01b3e2a commit e98575b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
if CURRENT_PLATFORM.startswith( 'WIN' ):
os.environ['KIVY_GL_BACKEND'] = 'angle_sdl2'

# grp is only available on *nix systems
if CURRENT_PLATFORM.startswith( 'LINUX' ) or CURRENT_PLATFORM.startswith( 'DARWIN' ):
import grp

################################################################################
# IMPORTS #
################################################################################
Expand Down Expand Up @@ -68,7 +72,8 @@
logging.debug( 'os.environ|' +str(os.environ)+ '|' )
logging.debug( 'user|' +str(os.getlogin())+ '|' )
logging.debug( 'uid|' +str(os.getuid())+ '|' )
logging.debug( 'group|' +str(grp.getgrgid( os.getgid() ))+ '|' )
if grp:
logging.debug( 'group|' +str(grp.getgrgid( os.getgid() ))+ '|' )
logging.debug( 'gid|' +str(os.getgid())+ '|' )
logging.debug( 'sys.argv|' +str(sys.argv)+ '|' )
logging.debug( 'sys.builtin_modules_names|' +str(sys.builtin_module_names)+ '|' )
Expand Down

0 comments on commit e98575b

Please sign in to comment.