예제 #1
0
 def cleanup(self):
     script = "grep -i '^DROP TABLE' '%s' | mysql --host='%s' --user='******' --password='******' %s" % (self.fullpath(),
                                              self.hostname, 
                                              self.username,
                                              self.password, 
                                              self.dbname)
     ShellScriptHelper.run(script)
예제 #2
0
    def build(self):
        mysql = "mysql -h %s -u%s" % (self.credentials.hostname,
                                      self.credentials.username)
        if self.credentials.password != None and len(
                self.credentials.password.strip()) > 0:
            mysql = mysql + " -p" + self.credentials.password

        # create data base
        create_db_cmd = "echo 'CREATE DATABASE IF NOT EXISTS %s;' | %s" % (
            self.dbname, mysql)
        try:
            ShellScriptHelper.run(create_db_cmd)
        except:
            return False
            #raise BaseException("Cannot create '%s' data base." % self.dbname)

        # grant permission
        create_db_cmd = "GRANT ALL ON %s.* TO '%s'@'%s'" % (
            self.dbname, self.username, self.hostname)
        if self.password != None and len(self.password.strip()) > 0:
            create_db_cmd = create_db_cmd + (" IDENTIFIED BY '%s'" %
                                             self.password)

        create_db_cmd = "echo \"%s;\" | %s" % (create_db_cmd, mysql)
        try:
            ShellScriptHelper.run(create_db_cmd)
        except:
            return False
            #raise BaseException("Cannot grant permission to '%s' data base." % self.dbname)

        return True
예제 #3
0
    def build(self):
        path = self.fullpath()
        if not os.path.exists(path):
            raise IOError("Script '%s' doesn't exist." % (path))

        script = "mysql --host='%s' --user='******' --password='******' %s < %s" % (
            self.hostname, self.username, self.password, self.dbname,
            self.fullpath())
        ShellScriptHelper.run(script)
예제 #4
0
 def build(self):
     path = self.fullpath()
     if not os.path.exists(path):
         raise IOError("Script '%s' doesn't exist." % (path))
     
     script = "mysql --host='%s' --user='******' --password='******' %s < %s" % (self.hostname, 
                                              self.username,
                                              self.password, 
                                              self.dbname,   
                                              self.fullpath())
     ShellScriptHelper.run(script)          
예제 #5
0
    def build(self):
        self.destination.build()
        zippath     = self.fullpath()
        destination = self.destination.fullpath()

        tmp  = tempfile.mkstemp(dir=Artifact.home_dir())
        null = open(tmp[1], "w")
        try: 
            ShellScriptHelper.run('unzip', " %s -d %s " % (zippath, destination), False, null)   
        finally: 
            null.close()
            os.remove(tmp[1])
예제 #6
0
    def build(self):            
        mysql = "mysql -h %s -u%s" % (self.credentials.hostname, self.credentials.username)
        if self.credentials.password != None and len(self.credentials.password.strip()) > 0: 
            mysql = mysql + " -p" + self.credentials.password 

        # create data base
        create_db_cmd = "echo 'CREATE DATABASE IF NOT EXISTS %s;' | %s" % (self.dbname, mysql)
        try: ShellScriptHelper.run(create_db_cmd)
        except: 
            return False
            #raise BaseException("Cannot create '%s' data base." % self.dbname)  
            
        # grant permission
        create_db_cmd = "GRANT ALL ON %s.* TO '%s'@'%s'" % (self.dbname, self.username, self.hostname)
        if self.password != None and len(self.password.strip()) > 0: 
            create_db_cmd = create_db_cmd + (" IDENTIFIED BY '%s'" % self.password)

        create_db_cmd = "echo \"%s;\" | %s"  % (create_db_cmd, mysql) 
        try: ShellScriptHelper.run(create_db_cmd) 
        except: 
            return False
            #raise BaseException("Cannot grant permission to '%s' data base." % self.dbname)
        
        return True
예제 #7
0
 def build(self):
     os.chdir(os.path.dirname(self.fullpath()))
     ShellScriptHelper.run("make", self.parameters, False)
예제 #8
0
 def build(self):
     ShellScriptHelper.run(self.fullpath(), self.parameters, True)
예제 #9
0
 def cleanup(self):
     script = "grep -i '^DROP TABLE' '%s' | mysql --host='%s' --user='******' --password='******' %s" % (
         self.fullpath(), self.hostname, self.username, self.password,
         self.dbname)
     ShellScriptHelper.run(script)