Beispiel #1
0
 def __init__(self,
              out_file,
              ans_file,
              gp_ignore=True,
              ignore_header=True,
              ignore_plans=False,
              match_sub=[]):
     cmd_str = 'gpdiff.pl -w -B -I NOTICE:'
     if ignore_header:
         cmd_str += ' -I GP_IGNORE -gpd_ignore_headers'
     elif gp_ignore:
         cmd_str += ' -I GP_IGNORE'
     cmd_str += ' -gpd_init %s/global_init_file' % (os.path.abspath(
         os.path.dirname(__file__)))
     if ignore_plans:
         cmd_str += ' -gpd_ignore_plans'
     if match_sub:
         cmd_str += ' -gpd_init '
         cmd_str += ' -gpd_init '.join(match_sub)
     cmd_str += ' %s %s' % (out_file, ans_file)
     Command.__init__(self, 'run gpdiff', cmd_str)
Beispiel #2
0
    def __init__(self, sql_file = None, sql_cmd = None, out_file = None, output_to_file = True, 
                 dbname = None,host = None, port = None, username = None, password = None,
                 PGOPTIONS = None, flags = '-a', isODBC = None,
                 timeout = 900, background = False):

        PSQL.propagate_env_map = {}

        if not dbname:
            dbname_option = ""
        else:
            dbname_option = "-d %s" % (dbname)

        if not username:
            username_option = ""
        else:
            username_option = "-U %s" % (username)

        if password:
            PSQL.propagate_env_map = {'PGPASSWORD': password}

        if not PGOPTIONS:
            PGOPTIONS = ""
        else:
            PGOPTIONS = "PGOPTIONS='%s'" % PGOPTIONS

        if not host:
            hostname_option = ""
        else:
            hostname_option = "-h %s" % (host)

        if not port:
            port_option = ""
        else:
            port_option = "-p %s" % (port)

        if sql_file:
            if not os.path.exists(sql_file):
                raise PSQLException('SQL file %s does not exist. ' %sql_file)

            cmd_str = '%s psql %s %s %s %s %s --no-psqlrc -f %s' \
                % (PGOPTIONS, dbname_option, username_option, hostname_option, port_option,
                   flags, sql_file)

            if not out_file:
                out_file = sql_file.replace('.sql', '.out')
        
            if output_to_file:
                cmd_str = "%s &> %s 2>&1" % (cmd_str, out_file)
        else:
            assert sql_cmd is not None
            cmd_str = "%s psql %s %s %s %s %s -c \"%s\"" \
                      % (PGOPTIONS,dbname_option,username_option,hostname_option,
                         port_option, flags, sql_cmd)

            if output_to_file and out_file:
                cmd_str = "%s &> %s 2>&1" % (cmd_str, out_file)
                
        if background:
            cmd_str = "%s &" %cmd_str

        Command.__init__(self, 'run sql', cmd_str)
Beispiel #3
0
 def __init__(self,name,filename, directory,ctxt=LOCAL,remoteHost=None):
     gphome = os.getenv("GPHOME", None)
     if not gphome:
         raise Exception('GPHOME environment variable not set.')
     cmdStr = "%s -d %s %s" % (os.path.normpath(gphome + '/lib/python/figleaf/figleaf2html'), directory, filename)        
     Command.__init__(self,name,cmdStr,ctxt,remoteHost)