parameters: (schema, maddir_mod_py, module, sqlfile,
                             tmpfile, logfile, pre_sql)
return_statement: return retval
docstring: Run SQL file
              @param schema name of the target schema
              @param maddir_mod_py name of the module dir with Python code
              @param module  name of the module
              @param sqlfile name of the file to parse
              @param tmpfile name of the temp file to run
              @param logfile name of the log file (stdout)
              @param pre_sql optional SQL to run before executing the file
docstring_summary: Run SQL file
docstring_tokens: Run SQL file
function: def _run_install_check_sql(schema, maddir_mod_py, module, sqlfile,
                             tmpfile, logfile, pre_sql):
      """
          Run SQL file
              @param schema name of the target schema
              @param maddir_mod_py name of the module dir with Python code
              @param module  name of the module
              @param sqlfile name of the file to parse
              @param tmpfile name of the temp file to run
              @param logfile name of the log file (stdout)
              @param pre_sql optional SQL to run before executing the file
      """
      try:
          f = open(tmpfile, 'w')
          _run_m4_and_append(schema, maddir_mod_py, module, sqlfile, f, pre_sql)
          f.close()
      except:
          error_(this, "Failed to temp m4 processed file %s." % tmpfile, False)
          raise Exception
      # Only update function definition
      sub_module = ''
      # Run the SQL using DB command-line utility
      if portid in SUPPORTED_PORTS:
          sqlcmd = 'psql'
          # Test the DB cmd line utility
          std, err = subprocess.Popen(['which', sqlcmd], stdout=subprocess.PIPE,
                                      stderr=subprocess.PIPE).communicate()
          if not std:
              error_(this, "Command not found: %s" % sqlcmd, True)
  
          runcmd = [sqlcmd, '-a',
                    '-v', 'ON_ERROR_STOP=1',
                    '-h', con_args['host'].split(':')[0],
                    '-p', con_args['host'].split(':')[1],
                    '-d', con_args['database'],
                    '-U', con_args['user'],
                    '--no-password',
                    '-f', tmpfile]
          runenv = os.environ
          if 'password' in con_args:
              runenv["PGPASSWORD"] = con_args['password']
          runenv["PGOPTIONS"] = '-c client_min_messages=notice'
  
      # Open log file
      try:
          log = open(logfile, 'w')
      except:
          error_(this, "Cannot create log file: %s" % logfile, False)
          raise Exception
  
      # Run the SQL
      try:
          info_(this, "> ... executing " + tmpfile, verbose)
          retval = subprocess.call(runcmd, env=runenv, stdout=log, stderr=log)
      except:
          error_(this, "Failed executing %s" % tmpfile, False)
          raise Exception
      finally:
          log.close()
  
      return retval
function_tokens: def _run_install_check_sql ( schema , maddir_mod_py , module , sqlfile , tmpfile , logfile , pre_sql ) : try : f = open ( tmpfile , 'w' ) _run_m4_and_append ( schema , maddir_mod_py , module , sqlfile , f , pre_sql ) f . close ( ) except : error_ ( this , "Failed to temp m4 processed file %s." % tmpfile , False ) raise Exception # Only update function definition sub_module = '' # Run the SQL using DB command-line utility if portid in SUPPORTED_PORTS : sqlcmd = 'psql' # Test the DB cmd line utility std , err = subprocess . Popen ( [ 'which' , sqlcmd ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) . communicate ( ) if not std : error_ ( this , "Command not found: %s" % sqlcmd , True ) runcmd = [ sqlcmd , '-a' , '-v' , 'ON_ERROR_STOP=1' , '-h' , con_args [ 'host' ] . split ( ':' ) [ 0 ] , '-p' , con_args [ 'host' ] . split ( ':' ) [ 1 ] , '-d' , con_args [ 'database' ] , '-U' , con_args [ 'user' ] , '--no-password' , '-f' , tmpfile ] runenv = os . environ if 'password' in con_args : runenv [ "PGPASSWORD" ] = con_args [ 'password' ] runenv [ "PGOPTIONS" ] = '-c client_min_messages=notice' # Open log file try : log = open ( logfile , 'w' ) except : error_ ( this , "Cannot create log file: %s" % logfile , False ) raise Exception # Run the SQL try : info_ ( this , "> ... executing " + tmpfile , verbose ) retval = subprocess . call ( runcmd , env = runenv , stdout = log , stderr = log ) except : error_ ( this , "Failed executing %s" % tmpfile , False ) raise Exception finally : log . close ( ) return retval