1

我有一个运行 python 命令的 python 程序

WARNING:root:executing - echo ~/Downloads/dw/hadoop_out/hadoop_out.2012-07-20 > /tmp/hadoop_load_file.tmp
WARNING:root:hadoop output file path written to /tmp/hadoop_load_file.tmp
WARNING:root:executing - /usr/local/hadoop/bin/hadoop dfs -cat ~/Downloads/dw/proposalLoader_out/part-00000 > ~/Downloads/dw/hadoop_out/hadoop_out.2012-07-20
WARNING:root:hadoop path exists, removing - /usr/local/hadoop/bin/hadoop dfs -test -d ~/Downloads/dw/proposalLoader_in
Deleted hdfs://master:54310/home/hduser/Downloads/dw/Loader_in
test: File does not exist: /home/hduser/Downloads/dw/Loader_out
WARNING:root:executing - /usr/local/hadoop/bin/hadoop dfs -mkdir ~/Downloads/dw/proposalLoader_in
WARNING:root:executing - /usr/local/hadoop/bin/hadoop dfs -copyFromLocal ~/Downloads/dw/load_input.txt ~/Downloads/dw/Loader_in  

但是当我看到里面的东西时,我什么HDFS也得不到

$ hadoop dfs -ls ~/Downloads/dw/Loader_in
Found 1 items
-rw-r--r--   3 hduser supergroup          0 2012-07-20 06:49 /home/hduser/Downloads/dw/Loader_in/load_input.txt  

当我从 运行相同的命令时shell,它会执行并获取数据HDFS

$ /usr/local/hadoop/bin/hadoop dfs -copyFromLocal ~/Downloads/dw/load_input.txt ~/Downloads/dw/Loader_in

$ hadoop dfs -ls ~/Downloads/dw/Loader_in
Found 1 items
-rw-r--r--   3 hduser supergroup       2311 2012-07-20 06:50 /home/hduser/Downloads/dw/Loader_in

我不知道为什么我会看到这种行为,执行命令的代码如下

def execute(command):
    if not command:
        return (-1, 'command can not be empty or null')
    return subprocess.call(command, shell=True)
4

0 回答 0