def isDirectory(self, path): cmd = "{hadoopHome}/bin/hadoop fs -test -d {path}".format( hadoopHome=config.HADOOP_HOME, path=path ) execute_shell = ExecuteShell() return_code = execute_shell.executeShell(cmd) if return_code == 0: return True return False
def createFile(self, path): return_code = -2 cmd = "{hadoopHome}/bin/hadoop fs -touchz {path}".format( hadoopHome=config.HADOOP_HOME, path=path ) if self.isFile(path): return_code = 0 else: execute_shell = ExecuteShell() return_code = execute_shell.executeShell(cmd) return return_code
def deleteFile(self, path): return_code = -2 cmd = "{hadoopHome}/bin/hadoop fs -rm {path}".format( hadoopHome=config.HADOOP_HOME, path=path ) if self.isDirectory(path): return_code = 0 else: execute_shell = ExecuteShell() return_code = execute_shell.executeShell(cmd) return return_code
def createDirectory(self, path): return_code = -2 cmd = "{hadoopHome}/bin/hadoop fs -mkdir {path}".format( hadoopHome=config.HADOOP_HOME, path=path ) if self.isDirectory(path): print "---directory is already exist---:{}".format(path) return_code = 0 else: execute_shell = ExecuteShell() return_code = execute_shell.executeShell(cmd) if return_code != 0: return_code = self.createDirectory_p(path) return return_code