/usr/lib/petscdir/3.7.7/x86_64-linux-gnu-real-debug/bin/petscnagupgrade.py is in libpetsc3.7.7-dbg 3.7.7+dfsg1-2build5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #! /usr/bin/python
#!/bin/env python
#
# Nags the user to update to the latest version
#
import os
import os.path, time,sys
import re
from distutils.version import LooseVersion as Version
def naggedtoday(file):
if not os.path.exists(file): return 0
if time.time() - os.path.getmtime(file) > 60*60*24: return 0
return 1
def parse_version_h(pv):
major = int(re.compile(' PETSC_VERSION_MAJOR[ ]*([0-9]*)').search(pv).group(1))
minor = int(re.compile(' PETSC_VERSION_MINOR[ ]*([0-9]*)').search(pv).group(1))
subminor = int(re.compile(' PETSC_VERSION_SUBMINOR[ ]*([0-9]*)').search(pv).group(1))
patch = int(re.compile(' PETSC_VERSION_PATCH[ ]*([0-9]*)').search(pv).group(1))
if patch != 0: # Patch number was used prior to 3.4
return Version('%d.%d.%dp%d' % (major, minor, subminor, patch))
elif subminor != 0: # Maintenance releases are numbered x.y.z
return Version('%d.%d.%d' % (major, minor, subminor))
else: # Feature releases are x.y
return Version('%d.%d' % (major, minor))
def currentversion(petscdir):
try:
fd = open(os.path.join(petscdir, 'include', 'petscversion.h'))
pv = fd.read()
fd.close()
version = parse_version_h(pv)
except:
return
try:
import urllib2
fd = urllib2.urlopen("https://bitbucket.org/petsc/petsc/raw/maint/include/petscversion.h",timeout = 2)
#fd = urllib2.urlopen("http://www.mcs.anl.gov/petsc/petsc-current/include/petscversion.h",timeout = 2)
pv = fd.read()
fd.close()
aversion = parse_version_h(pv)
except:
return
if aversion > version:
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
print("The version of PETSc you are using is out-of-date, we recommend updating to the new release")
print(" Available Version: "+str(aversion)+" Installed Version: "+str(version))
print("http://www.mcs.anl.gov/petsc/download/index.html")
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
try:
fd = open(os.path.join(petscdir,'.nagged'),"w")
fd.close()
except:
return
return 0
#
#
if __name__ == '__main__':
if 'PETSC_DIR' in os.environ:
petscdir = os.environ['PETSC_DIR']
elif os.path.exists(os.path.join('.', 'include', 'petscversion.h')):
petscdir = '.'
else:
sys.exit(0)
file = os.path.join(petscdir,'.nagged')
if not naggedtoday(file):
currentversion(petscdir)
|