PLUTO
configure Namespace Reference

Functions

def check (pluto_dir, get_arch)
 
def CHECK_FOR (file)
 

Variables

tuple scrh = os.getenv('PATH')
 
tuple path = scrh.split(':')
 
string have_file = "NO"
 

Function Documentation

def configure.check (   pluto_dir,
  get_arch 
)

Definition at line 6 of file configure.py.

6 def check(pluto_dir, get_arch):
7 
8  work_dir = os.getcwd()
9  print ("\n>> Inspecting system configuration << \n")
10 
11  log_file = work_dir+'/sysconf.out'
12  python_dir = pluto_dir+'/Tools/Python'
13  param_file = pluto_dir+'/Src/pluto.h'
14 
15  os.chdir (python_dir)
16  log = []
17 
18  # ---------------------
19  # get user name
20  # ---------------------
21 
22  try:
23  user = os.getlogin()
24  except OSError:
25  user = 'unknown'
26 
27  # ---------------------
28  # get system spec.
29  # ---------------------
30 
31  PLATFORM = os.uname()
32 
33  # ---------------------
34  # find current
35  # version of PLUTO
36  # ---------------------
37 
38  pf = pfIO.PlutoFiles(param_file)
39  scrh = pf.LocateString("PLUTO_VERSION")
40  ipos = scrh[0][0]
41  vers = scrh[0][1].split()[-1]
42 
43 
44 
45  # ------------------------------
46  # print a short system summary
47  # ------------------------------
48 
49  print "User.......................",user
50  print "System name................",PLATFORM[0]
51  print "Node name..................",PLATFORM[1]
52  print "Release....................",PLATFORM[2]
53  print "Arch.......................",PLATFORM[4]
54  print "Byteorder..................",sys.byteorder
55  print "Version....................",PLATFORM[3]
56  print "Working_dir................",work_dir
57  print "PLUTO main dir.............",pluto_dir
58  print "PLUTO version..............",vers
59 
60 # --------------------------------------
61 # Check for gcc or another c compiler
62 # --------------------------------------
63 
64  compiler_list = ['gcc','cc','gcc2']
65  COMPILER_NAME = ''
66 
67  for x in compiler_list:
68  if (CHECK_FOR(x) == 'YES'):
69  print "C Compiler................. "+x
70  COMPILER_NAME = x
71  break
72 
73  if (COMPILER_NAME == ''):
74  print "! Can not find a C compiler !"
75 
76 # -----------------
77 # check for mpi
78 # -----------------
79 
80  mpi_compiler_list = ['mpicc','mpiCC','mpcc_r','hcc','mpcc']
81  MPI_COMPILER_NAME = ''
82 
83  for x in mpi_compiler_list:
84  if (CHECK_FOR(x) == 'YES'):
85  print "MPI Compiler .............. "+x
86  MPI_COMPILER_NAME = x
87  break
88 
89  if (MPI_COMPILER_NAME == ''):
90  print "MPI Compiler............... NOT FOUND"
91 
92 
93  if (get_arch):
94  print "\n"
95  print "Proposed makefile names: \n"
96  print "> "+PLATFORM[0]+"."+PLATFORM[4]+"."+COMPILER_NAME+".defs"
97  print "> "+PLATFORM[0]+"."+PLATFORM[4]+"."+MPI_COMPILER_NAME+".defs"
98 
99 
100 # ---------------------------------------------------
101 # Build log list, that will be compared to the
102 # sysconf.out file.
103 # ---------------------------------------------------
104 
105  log.append("USER = "+user+'\n')
106  log.append("WORKING_DIR = "+work_dir+"\n")
107  log.append("SYSTEM_NAME = "+PLATFORM[0]+"\n")
108  log.append("NODE_NAME = "+PLATFORM[1]+"\n")
109  log.append("RELEASE = "+PLATFORM[2]+"\n")
110  log.append("ARCH = "+PLATFORM[4]+"\n")
111  log.append("BYTE_ORDER = "+sys.byteorder+"\n")
112  log.append("VERSION = "+PLATFORM[3]+"\n")
113  log.append("PLUTO_DIR = "+pluto_dir+'\n')
114  log.append("PLUTO_VERSION = "+vers+'\n')
115  log.append("C_COMPILER = "+COMPILER_NAME+'\n')
116  log.append("MPI_C_COMPILER = "+MPI_COMPILER_NAME+'\n')
117 
118  # ----------------------------
119  # check for online updates
120  # ----------------------------
121 
122  print "\n> Checking for updates (canceled)...\n"
123 # try:
124 # urllib.urlretrieve("http://plutocode.ph.unito.it/updates.txt","updates.txt")
125 # scrh = file.word_find ("updates.txt","release")
126 # ipos = scrh[0]
127 # scrh = file.read_lines ("updates.txt", ipos, ipos + 1)
128 # rels = string.split(scrh[0])
129 # if (rels[1] != vers):
130 # print " ******************************************************* "
131 # print " A new version of PLUTO ("+rels[1]+") is available at"
132 # print " http://plutocode.oato.inaf.it"
133 # print " *******************************************************\n"
134 # scrh = raw_input("> Press enter to continue.")
135 # os.chdir(work_dir)
136 # except:
137 # print "! Connection not available\n"
138 
139 
140 # ------------------------------------------------
141 # Compare the list 'log' with the file log_file;
142 #
143 # - if they match, no update is necessary,
144 # ==> return to main menu
145 #
146 # - if they do not match or if log_file does not
147 # exists, create a new one
148 #
149 # ------------------------------------------------
150 
151  if (os.path.exists(log_file)):
152  pf = pfIO.PlutoFiles(log_file)
153  scrh = pf.ReadLines(0,128)
154  if (scrh[0:] == log[0:]):
155  os.chdir(work_dir)
156  return
157  else:
158  print "\n> System configuration file is not up to date. Updating..."
159  else:
160  print "\n> System configuration file not found, creating one..."
161  pf = pfIO.PlutoFiles(log_file)
162  pf.List2File(log)
163 
164 # ------------
165 # Make Tools
166 # ------------
167 
168 # print (" > Making binary tools in "+bintools_dir+"...")
169 # os.chdir(bintools_dir)
170 # os.system('make -s clean')
171 # os.system('make -s dbl2flt')
172 # os.system('make -s bin2ascii')
173 # if (HAVE_LIBPNG == 'YES'):
174 # os.system('make -s bin2png')
175 
176 
177 # ---------------------------
178 # Add important info here
179 # ---------------------------
180 
181 # scrh = raw_input(" > Press enter to continue.")
182  os.chdir(work_dir)
183  return
184 
185 
def CHECK_FOR(file)
Definition: configure.py:187
def check(pluto_dir, get_arch)
Definition: configure.py:6

Here is the call graph for this function:

def configure.CHECK_FOR (   file)

Definition at line 187 of file configure.py.

187 def CHECK_FOR (file):
188 
189 #
190 # find whether file can be found in
191 # the user's path
192 #
193 #
def CHECK_FOR(file)
Definition: configure.py:187

Here is the caller graph for this function:

Variable Documentation

string configure.have_file = "NO"

Definition at line 207 of file configure.py.

tuple configure.path = scrh.split(':')

Definition at line 201 of file configure.py.

tuple configure.scrh = os.getenv('PATH')

Definition at line 200 of file configure.py.