
from ctypes import CDLL

with open('/usr/include/osreldate.h') as h:
    lines = h.readlines()
line = [ln for ln in lines if ln.startswith('#define')][0]
print('Compilation environment version:', line.split()[-1])

libc = CDLL("/lib/libc.so.7")
print('Execution environment version:', libc.getosreldate())

"""Print the __FreeBSD_version. This is also called OSVERSION in scripts."""

from ctypes import CDLL
import sys

if 'freebsd' not in sys.platform:
    print('This script only works on FreeBSD!')
    sys.exit(1)

with open('/usr/include/osreldate.h') as h:
    lines = h.readlines()
line = [ln for ln in lines if ln.startswith('#define')][0]
print('Compilation environment version:', line.split()[-1])

libc = CDLL("/lib/libc.so.7")
print('Execution environment version:', libc.getosreldate())

Print a warning and exit when not run on FreeBSD.
Print a warning and exit when not run on FreeBSD.

+ """Print the __FreeBSD_version. This is also called OSVERSION in scripts."""
  
  from ctypes import CDLL
+ import sys
+ 
+ if 'freebsd' not in sys.platform:
+     print('This script only works on FreeBSD!')
+     sys.exit(1)
  
  with open('/usr/include/osreldate.h') as h:
      lines = h.readlines()
  line = [ln for ln in lines if ln.startswith('#define')][0]
  print('Compilation environment version:', line.split()[-1])
  
  libc = CDLL("/lib/libc.so.7")
  print('Execution environment version:', libc.getosreldate())
  
Print a warning and exit when not run on FreeBSD.
## Code Before:

from ctypes import CDLL

with open('/usr/include/osreldate.h') as h:
    lines = h.readlines()
line = [ln for ln in lines if ln.startswith('#define')][0]
print('Compilation environment version:', line.split()[-1])

libc = CDLL("/lib/libc.so.7")
print('Execution environment version:', libc.getosreldate())

## Instruction:
Print a warning and exit when not run on FreeBSD.
## Code After:
"""Print the __FreeBSD_version. This is also called OSVERSION in scripts."""

from ctypes import CDLL
import sys

if 'freebsd' not in sys.platform:
    print('This script only works on FreeBSD!')
    sys.exit(1)

with open('/usr/include/osreldate.h') as h:
    lines = h.readlines()
line = [ln for ln in lines if ln.startswith('#define')][0]
print('Compilation environment version:', line.split()[-1])

libc = CDLL("/lib/libc.so.7")
print('Execution environment version:', libc.getosreldate())
