Exemplo n.º 1
0
    def show_python_lib_info(self, plibs, header=1, verb=2):
        if header: print UTIL.section_divider('python libs', hchar='-')
        for lib in plibs:
            MT.test_import(lib, verb=verb)
        # explicitly note whether we have PyQt4
        if not MT.test_import('PyQt4', verb=0):
            self.have_pyqt4 = 1

            # check for partial install
            cmd = 'from PyQt4 import QtCore, QtGui'
            try:
                exec cmd
            except:
                print '\n** have PyQt4, but cannot load QtCore, QtGui; error is:' \
                      '\n\n'                                                      \
                      '   **************************************************'
                os.system('python -c "%s"' % cmd)
                print '   **************************************************\n'
                self.comments.append('check for partial install of PyQt4')
        print

        pdirs = glob.glob('/sw/bin/python*')
        if len(pdirs) > 0:
            pdirs = [dd for dd in pdirs if dd.find('config') < 0]
        if len(pdirs) > 0:
            print 'python binaries under /sw/bin:'
            for pdir in pdirs:
                if os.path.islink(pdir):
                    rstr = ' (sym link to %s)' % os.path.realpath(pdir)
                else:
                    rstr = ''
                print '    %-20s%s' % (pdir, rstr)
            print
Exemplo n.º 2
0
 def show_comments(self):
    print UTIL.section_divider('summary comments', hchar='=')
    for cc in self.comments: 
       if len(cc) == 0: print ''
       else:
          if cc[0] == ' ': print '  %s' % cc
          else:            print '*  %s' % cc
Exemplo n.º 3
0
 def show_comments(self):
     print UTIL.section_divider('summary comments', hchar='=')
     for cc in self.comments:
         if len(cc) == 0: print ''
         else:
             if cc[0] == ' ': print '  %s' % cc
             else: print '*  %s' % cc
Exemplo n.º 4
0
 def show_path_vars(self, header=1):
    print UTIL.section_divider('path vars', hchar='-')
    for evar in ['PATH', 'PYTHONPATH',
                 'LD_LIBRARY_PATH',
                 'DYLD_LIBRARY_PATH', 'DYLD_FALLBACK_LIBRARY_PATH']:
       if os.environ.has_key(evar): print "%s = %s\n" % (evar, os.environ[evar])
       else: print "%s = " % evar
Exemplo n.º 5
0
    def show_data_info(self, header=1):
        """checks that are specific to data
            - class data existence and tree root
               - assume $HOME if not found
            - disk space under data root
               - maybe check for mounted file system
            - atlases (maybe just @Find TT_N27+tlrc?)
      """

        if header: print UTIL.section_divider('data checks', hchar='-')

        # locate various data trees, and possibly show recent history
        rv = 0
        rv += self.show_data_dir_info('AFNI_data6', 'history.txt')
        rv += self.show_data_dir_info('suma_demo', 'README.archive_creation')
        rv += self.show_data_dir_info('FATCAT_DEMO', 'README.timestamp')
        rv += self.show_data_dir_info('afni_handouts')

        if rv: self.comments.append('insufficient data for AFNI bootcamp')

        evar = 'AFNI_ATLAS_DIR'
        tryenv = 0  # might suggest setting evar
        haveenv = os.environ.has_key(evar)
        if haveenv: edir = os.environ[evar]
        else: edir = ''

        # look for atlases in multiple directories
        atlas = 'TT_N27+tlrc'
        if os.path.isfile('%s/%s.HEAD' % (edir, atlas)): glist = [edir]
        else: glist = []

        cmd = '@FindAfniDsetPath %s' % atlas
        s, so, se = UTIL.limited_shell_exec(cmd, nlines=1)
        if s: tryenv = 1  # failed
        elif len(so) > 0: glist.append(so[0])

        for ddir in ['/usr/share/afni/atlases', '/usr/local/afni/atlases']:
            if os.path.isfile('%s/%s.HEAD' % (ddir, atlas)):
                glist.append(ddir)
                if tryenv:
                    self.comments.append('consider setting %s to %s' %
                                         (evar, ddir))

        # fix to work with found after the fact
        glist = UTIL.get_unique_sublist(glist)

        if len(glist) == 0:
            print 'atlas    : did not find %s' % atlas
            self.comments.append('possibly missing atlases')
        else:
            for ddir in glist:
                print 'atlas    : found %-12s under %s' % (atlas, ddir)

        if haveenv: print "\natlas var: %s = %s" % (evar, edir)

        print
Exemplo n.º 6
0
   def show_data_info(self, header=1):
      """checks that are specific to data
            - class data existence and tree root
               - assume $HOME if not found
            - disk space under data root
               - maybe check for mounted file system
            - atlases (maybe just @Find TT_N27+tlrc?)
      """

      if header: print UTIL.section_divider('data checks', hchar='-')

      # locate various data trees, and possibly show recent history
      rv = 0
      rv += self.show_data_dir_info('AFNI_data6', 'history.txt')
      rv += self.show_data_dir_info('suma_demo', 'README.archive_creation')
      rv += self.show_data_dir_info('FATCAT_DEMO', 'README.timestamp')
      rv += self.show_data_dir_info('afni_handouts')

      if rv: self.comments.append('insufficient data for AFNI bootcamp')

      evar = 'AFNI_ATLAS_DIR'
      tryenv = 0                        # might suggest setting evar
      haveenv = os.environ.has_key(evar)
      if haveenv: edir = os.environ[evar]
      else:       edir = ''

      # look for atlases in multiple directories
      atlas = 'TT_N27+tlrc'
      if os.path.isfile('%s/%s.HEAD'%(edir,atlas)): glist = [edir]
      else: glist = []

      cmd = '@FindAfniDsetPath %s' % atlas
      s, so, se = UTIL.limited_shell_exec(cmd, nlines=1)
      if s: tryenv = 1  # failed
      elif len(so) > 0: glist.append(so[0])

      for ddir in ['/usr/share/afni/atlases', '/usr/local/afni/atlases']:
         if os.path.isfile('%s/%s.HEAD'%(ddir,atlas)):
            glist.append(ddir)
            if tryenv:
               self.comments.append('consider setting %s to %s' % (evar,ddir))

      # fix to work with found after the fact
      glist = UTIL.get_unique_sublist(glist)

      if len(glist) == 0:
         print 'atlas    : did not find %s' % atlas
         self.comments.append('possibly missing atlases')
      else:
         for ddir in glist:
            print 'atlas    : found %-12s under %s' % (atlas, ddir)

      if haveenv: print "\natlas var: %s = %s" % (evar, edir)

      print
Exemplo n.º 7
0
   def show_os_specific(self, header=1):
      """checks that are specific to one OS or another"""

      if self.system not in ['Linux', 'Darwin']: return

      if header: print UTIL.section_divider('OS specific', hchar='-')

      if   self.system == 'Linux':  self.show_spec_linux()
      elif self.system == 'Darwin': self.show_spec_mac()

      print
Exemplo n.º 8
0
    def show_general_sys_info(self, header=1):
        if header: print UTIL.section_divider('general', hchar='-')

        def tostr(some_tuple):
            if type(some_tuple) == str: return some_tuple
            tlist = [t for t in list(some_tuple) if type(t) == str]
            return ' '.join(tlist)

        print 'architecture:         %s' % tostr(platform.architecture())
        print 'system:               %s' % platform.system()
        print 'release:              %s' % platform.release()
        print 'version:              %s' % platform.version()

        # check distributions by type
        checkdist = 0
        dstr = ''
        if self.system == 'Linux':
            try:
                dstr = tostr(platform.linux_distribution())
            except:
                checkdist = 1
        elif self.system == 'Darwin':
            try:
                dstr = tostr(platform.mac_ver())
            except:
                checkdist = 1
        else:
            checkdist = 1
        if checkdist: dstr = tostr(platform.dist())
        self.os_dist = dstr  # save result
        print 'distribution:         %s' % dstr

        print 'number of CPUs:       %s' % self.get_cpu_count()

        # note shell, and if we are not in login shell
        logshell = UTIL.get_login_shell()
        curshell = UTIL.get_current_shell()
        if logshell == curshell: note = ''
        else: note = '  (current shell is %s)' % curshell

        if logshell not in ['csh', 'tcsh']:
            self.comments.append("login shell '%s', trusting user to translate" \
                                 " from 'tcsh'" % logshell)

        print 'apparent login shell: %s%s' % (logshell, note)

        self.cur_shell = curshell
        self.login_shell = logshell

        self.set_shell_rc_file([logshell, curshell])
        if self.home_file_exists(self.rc_file): fstr = 'exists'
        else: fstr = 'does not exist'
        print 'shell RC file:        %s (%s)' % (self.rc_file, fstr)
        print
Exemplo n.º 9
0
    def show_os_specific(self, header=1):
        """checks that are specific to one OS or another"""

        if self.system not in ['Linux', 'Darwin']: return

        if header: print UTIL.section_divider('OS specific', hchar='-')

        if self.system == 'Linux': self.show_spec_linux()
        elif self.system == 'Darwin': self.show_spec_osx()

        print
Exemplo n.º 10
0
 def show_path_vars(self, header=1):
     print UTIL.section_divider('env vars', hchar='-')
     for evar in [
             'PATH', 'PYTHONPATH', 'R_LIBS', 'LD_LIBRARY_PATH',
             'DYLD_LIBRARY_PATH', 'DYLD_FALLBACK_LIBRARY_PATH'
     ]:
         if os.environ.has_key(evar):
             print "%s = %s\n" % (evar, os.environ[evar])
         else:
             print "%s = " % evar
     print
Exemplo n.º 11
0
 def show_general_afni_info(self, header=1):
    print UTIL.section_divider('AFNI and related program tests', hchar='-')
    for prog in ['afni', 'python', 'R', 'tcsh']:
       cmd = 'which %s' % prog
       s, so, se = BASE.simple_shell_exec(cmd, capture=1)
       if s: print '%-20s : %s' % (cmd, se)
       else:
          print '%-20s : %s' % (cmd, so.strip())
          s, v = self.get_prog_version(prog)
          if s:
              print '%-20s : %s' % ('%s version'%prog, v)
              if prog == 'afni': self.afni_ver = v # save result
Exemplo n.º 12
0
 def show_general_afni_info(self, header=1):
     print UTIL.section_divider('AFNI and related program tests', hchar='-')
     for prog in ['afni', 'python', 'R', 'tcsh']:
         cmd = 'which %s' % prog
         s, so, se = BASE.simple_shell_exec(cmd, capture=1)
         if s: print '%-20s : %s' % (cmd, se)
         else:
             print '%-20s : %s' % (cmd, so.strip())
             s, v = self.get_prog_version(prog)
             if s:
                 print '%-20s : %s' % ('%s version' % prog, v)
                 if prog == 'afni': self.afni_ver = v  # save result
Exemplo n.º 13
0
   def show_python_lib_info(self, plibs, header=1, verb=2):
      if header: print UTIL.section_divider('python libs', hchar='-')
      for lib in plibs: MT.test_import(lib, verb=verb)
      # explicitly note whether we have PyQt4
      if not MT.test_import('PyQt4', verb=0):
         self.have_pyqt4 = 1

         # check for partial install
         cmd = 'from PyQt4 import QtCore, QtGui'
         try: exec cmd
         except:
            print '\n** have PyQt4, but cannot load QtCore, QtGui; error is:' \
Exemplo n.º 14
0
    def show_comments(self):
        # check for a good result, first
        if len(self.comments) == 0:
            print UTIL.section_divider(' nothing to fix, yay! ', hchar='=')
            print
            return

        print UTIL.section_divider(' summary, please fix: ', hchar='=')
        for cc in self.comments:
            if len(cc) == 0: print ''
            else:
                if cc[0] == ' ': print '  %s' % cc
                else: print '*  %s' % cc
Exemplo n.º 15
0
 def show_path_vars(self, header=1):
     print UTIL.section_divider('env vars', hchar='-')
     for evar in [
             'PATH', 'PYTHONPATH', 'R_LIBS', 'LD_LIBRARY_PATH',
             'DYLD_LIBRARY_PATH', 'DYLD_FALLBACK_LIBRARY_PATH'
     ]:
         if os.environ.has_key(evar):
             print "%s = %s\n" % (evar, os.environ[evar])
         elif evar.startswith('DY') and self.get_osx_ver() >= 11:
             s, so = self.get_shell_value(self.cur_shell, evar)
             print "%s (sub-shell) = %s" % (evar, so)
         else:
             print "%s = " % evar
     print
Exemplo n.º 16
0
   def show_python_lib_info(self, plibs, header=1, verb=2):
      if header: print UTIL.section_divider('python libs', hchar='-')
      for lib in plibs: MT.test_import(lib, verb=verb)
      print

      pdirs = glob.glob('/sw/bin/python*')
      if len(pdirs) > 0: pdirs = [dd for dd in pdirs if dd.find('config')<0]
      if len(pdirs) > 0:
         print 'python binaries under /sw/bin:'
         for pdir in pdirs:
            if os.path.islink(pdir):
               rstr = ' (sym link to %s)' % os.path.realpath(pdir)
            else: rstr = ''
            print '    %-20s%s' % (pdir, rstr)
         print
Exemplo n.º 17
0
    def show_python_lib_info(self, header=1):

        # any extra libs to test beyone main ones
        extralibs = ['matplotlib.pyplot']
        verb = 3

        if header: print(UTIL.section_divider('python libs', hchar='-'))

        # itemize special libraries to test: PyQt4
        self.test_python_lib_pyqt4(verb=verb)
        print('')

        # then go after any others
        for plib in extralibs:
            self.test_python_lib(plib, verb=verb)
            print('')

        for rootdir in ['/sw/bin', '/usr/local/bin']:
            # hard to avoid related files, so search for expected names
            pdirs = glob.glob('%s/python' % rootdir)
            p1dirs = glob.glob('%s/python[0-9]' % rootdir)
            p2dirs = glob.glob('%s/python[0-9].[0-9]' % rootdir)
            pdirs.extend(p1dirs)
            pdirs.extend(p2dirs)
            if len(pdirs) > 0:
                print('-- python binaries under %s:' % rootdir)
                for pdir in pdirs:
                    if os.path.islink(pdir):
                        rstr = ' (sym link to %s)' % os.path.realpath(pdir)
                    else:
                        rstr = ''
                    print('    %-20s%s' % (pdir, rstr))
                print('')
Exemplo n.º 18
0
   def show_general_sys_info(self, header=1):
      if header: print UTIL.section_divider('general', hchar='-')

      def tostr(some_tuple):
         if type(some_tuple) == str: return some_tuple
         tlist = [t for t in list(some_tuple) if type(t) == str]
         return ' '.join(tlist)

      print 'architecture:         %s' % tostr(platform.architecture())
      print 'system:               %s' % platform.system()
      print 'release:              %s' % platform.release()
      print 'version:              %s' % platform.version()

      # check distributions by type
      checkdist = 0
      dstr = ''
      if   self.system == 'Linux':
         try:    dstr = tostr(platform.linux_distribution())
         except: checkdist = 1
      elif self.system == 'Darwin':
         try: dstr = tostr(platform.mac_ver())
         except: checkdist = 1
      else: checkdist = 1
      if checkdist: dstr = tostr(platform.dist())
      self.os_dist = dstr       # save result
      print 'distribution:         %s' % dstr
         
      print 'number of CPUs:       %s' % self.get_cpu_count()

      # note shell, and if we are not in login shell
      logshell = UTIL.get_login_shell()
      curshell = UTIL.get_current_shell()
      if logshell == curshell: note = ''
      else:                    note = '  (current shell is %s)' % curshell

      if logshell not in ['csh', 'tcsh']:
         self.comments.append("login shell '%s', trusting user to translate" \
                              " from 'tcsh'" % logshell)

      print 'apparent login shell: %s%s' % (logshell, note)

      self.set_shell_rc_file([logshell, curshell])
      if self.home_file_exists(self.rc_file): fstr = 'exists'
      else:                                   fstr = 'does not exist'
      print 'shell RC file:        %s (%s)' % (self.rc_file, fstr)
      print
Exemplo n.º 19
0
    def show_python_lib_info(self, plibs, header=1, verb=2):
        if header: print UTIL.section_divider('python libs', hchar='-')
        for lib in plibs:
            MT.test_import(lib, verb=verb)
        print

        pdirs = glob.glob('/sw/bin/python*')
        if len(pdirs) > 0:
            pdirs = [dd for dd in pdirs if dd.find('config') < 0]
        if len(pdirs) > 0:
            print 'python binaries under /sw/bin:'
            for pdir in pdirs:
                if os.path.islink(pdir):
                    rstr = ' (sym link to %s)' % os.path.realpath(pdir)
                else:
                    rstr = ''
                print '    %-20s%s' % (pdir, rstr)
            print
Exemplo n.º 20
0
    def check_dotfiles(self, show=0, pack=0):
        global g_dotfiles

        home = os.environ['HOME']

        # get list of existing files
        dfound = []
        for dfile in g_dotfiles:
            if os.path.isfile('%s/%s' % (home, dfile)):
                dfound.append(dfile)
                print 'found under $HOME : %s' % dfile

        if show:
            for dfile in dfound:
                print UTIL.section_divider(dfile, hchar='=')
                print '%s\n' % UTIL.read_text_file('%s/%s' % (home, dfile),
                                                   lines=0)

        if pack:
            import shutil
            package = self.dot_file_pack
            pgz = '%s.tgz' % package
            # maybe user included the extension
            ext = package.find('.tgz')
            if ext >= 0:
                pgz = package
                package = package[0:ext]
            if os.path.exists(package) or os.path.exists('%s.tgz' % package):
                print "** error: package dir '%s' or file '%s' already exists"\
                      % (package, pgz)
                return 1

            try:
                os.mkdir(package)
            except:
                print "** failed to make dot file package dir '%s'" % package
                return 1
            for dfile in dfound:
                shutil.copy2('%s/%s' % (home, dfile), package)
            os.system("tar cfz %s %s" % (pgz, package))
            shutil.rmtree(package)
            if os.path.exists(pgz): print '++ dot file package is in %s' % pgz
            else: print '** failed to make dot file packge %s' % pgz
Exemplo n.º 21
0
    def show_general_sys_info(self, header=1):
        if header: print UTIL.section_divider('general', hchar='-')

        def tostr(some_tuple):
            if type(some_tuple) == str: return some_tuple
            tlist = [t for t in list(some_tuple) if type(t) == str]
            return ' '.join(tlist)

        print 'architecture:         %s' % tostr(platform.architecture())
        print 'system:               %s' % platform.system()
        print 'release:              %s' % platform.release()
        print 'version:              %s' % platform.version()

        # check distributions by type
        checkdist = 0
        dstr = ''
        if self.system == 'Linux':
            try:
                dstr = tostr(platform.linux_distribution())
            except:
                checkdist = 1
        elif self.system == 'Darwin':
            try:
                dstr = tostr(platform.mac_ver())
            except:
                checkdist = 1
        else:
            checkdist = 1
        if checkdist: dstr = tostr(platform.dist())
        self.os_dist = dstr  # save result
        print 'distribution:         %s' % dstr

        print 'number of CPUs:       %s' % self.get_cpu_count()

        # note shell, and if we are not in login shell
        logshell = UTIL.get_login_shell()
        curshell = UTIL.get_current_shell()
        if logshell == curshell: note = ''
        else: note = '  (current shell is %s)' % curshell

        print 'apparent login shell: %s%s' % (logshell, note)
        print
Exemplo n.º 22
0
   def check_dotfiles(self, show=0, pack=0):
      global g_dotfiles

      home = os.environ['HOME']

      # get list of existing files
      dfound = []
      for dfile in g_dotfiles:
         if os.path.isfile('%s/%s' % (home, dfile)):
            dfound.append(dfile)
            print 'found under $HOME : %s' % dfile

      if show:
         for dfile in dfound:
            print UTIL.section_divider(dfile, hchar='=')
            print '%s\n' % UTIL.read_text_file('%s/%s' % (home, dfile), lines=0)

      if pack:
         import shutil
         package = self.dot_file_pack
         pgz = '%s.tgz' % package
         # maybe user included the extension
         ext = package.find('.tgz')
         if ext >= 0:
            pgz = package
            package = package[0:ext]
         if os.path.exists(package) or os.path.exists('%s.tgz'%package):
            print "** error: package dir '%s' or file '%s' already exists"\
                  % (package, pgz)
            return 1

         try: os.mkdir(package)
         except:
            print "** failed to make dot file package dir '%s'"  % package
            return 1
         for dfile in dfound:
            shutil.copy2('%s/%s' % (home, dfile), package)
         os.system("tar cfz %s %s" % (pgz, package))
         shutil.rmtree(package)
         if os.path.exists(pgz): print '++ dot file package is in %s' % pgz
         else: print '** failed to make dot file packge %s' % pgz
Exemplo n.º 23
0
   def show_general_sys_info(self, header=1):
      if header: print UTIL.section_divider('general', hchar='-')

      def tostr(some_tuple):
         if type(some_tuple) == str: return some_tuple
         tlist = [t for t in list(some_tuple) if type(t) == str]
         return ' '.join(tlist)

      print 'architecture:         %s' % tostr(platform.architecture())
      print 'system:               %s' % platform.system()
      print 'release:              %s' % platform.release()
      print 'version:              %s' % platform.version()

      # check distributions by type
      checkdist = 0
      dstr = ''
      if   self.system == 'Linux':
         try:    dstr = tostr(platform.linux_distribution())
         except: checkdist = 1
      elif self.system == 'Darwin':
         try: dstr = tostr(platform.mac_ver())
         except: checkdist = 1
      else: checkdist = 1
      if checkdist: dstr = tostr(platform.dist())
      self.os_dist = dstr       # save result
      print 'distribution:         %s' % dstr
         
      print 'number of CPUs:       %s' % self.get_cpu_count()

      # note shell, and if we are not in login shell
      logshell = UTIL.get_login_shell()
      curshell = UTIL.get_current_shell()
      if logshell == curshell: note = ''
      else:                    note = '  (current shell is %s)' % curshell

      print 'apparent login shell: %s%s' % (logshell, note)
      print
Exemplo n.º 24
0
    def show_general_afni_info(self, header=1):
        print(UTIL.section_divider('AFNI and related program tests',
                                   hchar='-'))

        self.afni_dir = self.get_afni_dir()
        check_list = [
            'afni', 'afni label', 'AFNI_version.txt', 'python', 'R', 'tcsh'
        ]
        nfound = self.check_for_progs(check_list, show_missing=1)
        if nfound < len(check_list):
            self.comments.append('failure under initial ' \
                                 '"AFNI and related program tests"')

        # make generic but pretty
        print("instances of various programs found in PATH:")
        proglist = ['afni', 'R', 'python', 'python2', 'python3']
        ml = UTIL.max_len_in_list(proglist)
        for prog in proglist:
            rv, files = UTIL.search_path_dirs(prog, mtype=1)
            if not rv:
                if len(files) > 1: fstr = '\n      ' + '\n      '.join(files)
                elif len(files) > 0: fstr = '  (%s)' % files[0]
                else: fstr = ''
                print('    %-*s : %d %s' % (ml, prog, len(files), fstr))

                if prog == 'afni':
                    if len(files) > 1:
                        self.comments.append(
                            "have multiple versions of AFNI in PATH")
                    if len(files) > 0:
                        if os.stat(files[0]).st_uid == 0:
                            self.comments.append(
                                "'afni' executable is owned by root")
        print('')

        # explicit python2 vs python3 check    7 Dec 2016
        n2 = UTIL.num_found_in_path('python2', mtype=1)
        n3 = UTIL.num_found_in_path('python3', mtype=1)
        if n3 > 0 and n2 <= 0:
            print("** have python3 but not python2")
        print('')

        # try select AFNI programs
        print('testing ability to start various programs...')
        ind = '%8s' % ' '
        indn = '\n%8s' % ' '
        proglist = [
            'afni', 'suma', '3dSkullStrip', 'uber_subject.py', '3dAllineate',
            '3dRSFC', 'SurfMesh', '3dClustSim'
        ]
        fcount = 0
        for prog in proglist:
            st, so, se = BASE.shell_exec2('%s -help' % prog, capture=1)
            if st:
                print('    %-20s : FAILURE' % prog)
                print(ind + indn.join(se))
                fcount += 1
            else:
                print('    %-20s : success' % prog)

                # no OpenMP problem
                if prog == '3dAllineate': self.ok_openmp = 1
        print('')
        pfailure = fcount == len(proglist)
        if fcount > 0:
            self.afni_fails = fcount
            self.comments.append('AFNI programs show FAILURE')

        # if complete failure, retry from exec dir
        ascdir = UTIL.executable_dir()
        if pfailure and self.afni_dir != ascdir:
            fcount = 0
            print('none working, testing programs under implied %s...' %
                  ascdir)
            for prog in proglist:
                st, so, se = BASE.shell_exec2('%s/%s -help' % (ascdir, prog),
                                              capture=1)
                if st:
                    print('    %-20s : FAILURE' % prog)
                    print(ind + indn.join(se))
                    fcount += 1
                else:
                    print('    %-20s : success' % prog)
            print('')
            if fcount < len(proglist):
                self.comments.append('consider adding %s to your PATH' %
                                     ascdir)
        # if afni_dir is not set, use ascdir
        if self.afni_dir == '': self.afni_dir = ascdir

        print('checking for R packages...')
        cmd = 'rPkgsInstall -pkgs ALL -check'
        st, so, se = BASE.shell_exec2(cmd, capture=1)
        if st or len(se) < 2: okay = 0
        else:
            if se[1].startswith('++ Note:'): se = se[2:]
            okay = 1
            # require every subsequent string to say verified
            for estr in se:
                if estr != '' and estr.find('has been verified') < 0:
                    okay = 0  # any failure is terminal
                    break
        if okay:
            print('    %-20s : success' % cmd)
        else:
            print('    %-20s : FAILURE' % cmd)
            print(ind + indn.join(se))
            self.comments.append('missing R packages (see rPkgsInstall)')
        print('')

        print('checking for $HOME files...')
        flist = ['.afnirc', '.sumarc', '.afni/help/all_progs.COMP']
        for ff in flist:
            if os.path.isfile('%s/%s' % (self.home_dir, ff)): fstr = 'found'
            else: fstr = 'missing'
            print('    %-25s : %s' % (ff, fstr))

        # add to comments
        if self.afni_dir:
            ccc = 'running: cp %s/AFNI.afnirc ~/.afnirc' % self.afni_dir
        else:
            ccc = 'copying AFNI.afnirc to ~/.afnirc'
        self.add_file_comment(None, '.afnirc', 'consider %s' % ccc)

        self.add_file_comment(
            None, '.sumarc', 'consider running "suma -update_env" for .sumarc')
        self.add_file_comment(
            None, '.afni/help/all_progs.COMP',
            'consider running: apsearch -update_all_afni_help')

        print('')
Exemplo n.º 25
0
   def show_general_afni_info(self, header=1):
      print UTIL.section_divider('AFNI and related program tests', hchar='-')

      self.afni_dir = self.get_afni_dir()
      check_list = ['afni', 'AFNI_version.txt', 'python', 'R', 'tcsh']
      nfound = self.check_for_progs(check_list, show_missing=1)
      if nfound < len(check_list):
         self.comments.append('failure under initial "AFNI and related program tests"')

      # make generic but pretty
      print "instances of various programs found in PATH:"
      proglist = ['afni', 'R', 'python']
      ml = UTIL.max_len_in_list(proglist)
      for prog in proglist:
         rv, files = UTIL.search_path_dirs(prog, mtype=1)
         if not rv:
            if len(files) > 1:   fstr = '\n      '+'\n      '.join(files)
            elif len(files) > 0: fstr = '  (%s)' % files[0]
            else:                fstr = ''
            print '    %-*s : %d %s' % (ml, prog, len(files), fstr)

            if prog == 'afni':
               if len(files) > 1:
                  self.comments.append("have multiple versions of AFNI in PATH")
               if len(files) > 0:
                  if os.stat(files[0]).st_uid == 0:
                     self.comments.append("'afni' executable is owned by root")
      print

      # try select AFNI programs
      print 'testing ability to start various programs...'
      ind = '%8s' % ' '
      indn = '\n%8s' % ' '
      proglist = ['afni', 'suma', '3dSkullStrip', 'uber_subject.py',
                   '3dAllineate', '3dRSFC', 'SurfMesh']
      fcount = 0
      for prog in proglist:
         st, so, se = BASE.shell_exec2('%s -help'%prog, capture=1)
         if st:
            print '    %-20s : FAILURE' % prog
            print ind + indn.join(se)
            fcount += 1
         else:
            print '    %-20s : success' % prog

            # no OpenMP problem
            if prog == '3dAllineate': self.ok_openmp = 1
      print
      pfailure = fcount == len(proglist)
      if fcount > 0:
         self.afni_fails = fcount
         self.comments.append('AFNI programs show FAILURE')

      # if complete failure, retry from exec dir
      ascdir = UTIL.executable_dir()
      if pfailure and self.afni_dir != ascdir:
         fcount = 0
         print 'none working, testing programs under implied %s...' % ascdir
         for prog in proglist:
            st, so, se = BASE.shell_exec2('%s/%s -help'%(ascdir,prog),capture=1)
            if st:
               print '    %-20s : FAILURE' % prog
               print ind + indn.join(se)
               fcount += 1
            else: print '    %-20s : success' % prog
         print
         if fcount < len(proglist):
            self.comments.append('consider adding %s to your PATH' % ascdir)
      # if afni_dir is not set, use ascdir
      if self.afni_dir == '': self.afni_dir = ascdir

      print 'checking for R packages...'
      cmd = 'rPkgsInstall -pkgs ALL -check'
      st, so, se = BASE.shell_exec2(cmd, capture=1)
      if st or len(se) < 2: okay = 0
      else:
         if se[1].startswith('++ Note:'): se = se[2:]
         okay = 1
         # require every subsequent string to say verified
         for estr in se:
            if estr != '' and estr.find('has been verified') < 0:
               okay = 0   # any failure is terminal
               break
      if okay:
         print '    %-20s : success' % cmd
      else:
         print '    %-20s : FAILURE' % cmd
         print ind + indn.join(se)
         self.comments.append('missing R packages (see rPkgsInstall)')
      print

      print 'checking for $HOME files...'
      flist = ['.afnirc', '.sumarc', '.afni/help/all_progs.COMP']
      for ff in flist:
         if os.path.isfile('%s/%s'%(self.home_dir, ff)): fstr = 'found'
         else:                                           fstr = 'missing'
         print '    %-25s : %s' % (ff, fstr)

      # add to comments
      if self.afni_dir:
         ccc = 'running: cp %s/AFNI.afnirc ~/.afnirc' % self.afni_dir
      else:
         ccc = 'copying AFNI.afnirc to ~/.afnirc'
      self.add_file_comment(None, '.afnirc', 'consider %s' % ccc)

      self.add_file_comment(None, '.sumarc',
                            'consider running "suma -update_env" for .sumarc')
      self.add_file_comment(None, '.afni/help/all_progs.COMP',
                            'consider running: apsearch -update_all_afni_help')

      print
Exemplo n.º 26
0
 def show_comments(self):
     print UTIL.section_divider('general comments', hchar='-')
     for cc in self.comments:
         print '*  %s' % cc
     print ''
Exemplo n.º 27
0
 def show_comments(self):
    print UTIL.section_divider('general comments', hchar='-')
    for cc in self.comments: print '*  %s' % cc
    print ''