Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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