예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
 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
예제 #4
0
 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