import sys
import os

try:
    try:
       import ccp4mg
    except:
       pass
    import opengl
    import pygl_coord
    import cprim
    import surface
    import image_info
    import ffmpeg_wrapper
except ImportError:
    exc_type, exc_value,exc_tb = sys.exc_info()[:3]
    if str(exc_value).find('cannot restore segment prot after reloc')>-1:
        print "SELINUX problem"
        if os.environ.has_key("CCP4MG"):
	  fixperms = os.path.join(os.path.normpath(os.environ["CCP4MG"]),"bin","fix-selinux-perms")
          print fixperms
        sys.exit(1)
    else:
    	print >> sys.stderr, "Failed to import some ccp4mg libraries (in checkPerms)", "There was a problem with some of the program libraries. Please report this as a bug to ccp4mg@ysbl.york.ac.uk."
        sys.exit(2)


