Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kb:code_snippets [2017/12/20 10:02]
yehuda created
kb:code_snippets [2017/12/20 10:03] (current)
yehuda
Line 8: Line 8:
 current_process_date.strftime('​We are the %d, %b %Y') current_process_date.strftime('​We are the %d, %b %Y')
 print("/​%s/​*"​ % current_process_date.strftime("​%Y/​%m/​%d"​)) print("/​%s/​*"​ % current_process_date.strftime("​%Y/​%m/​%d"​))
 +</​code>​
 +
 +<code python>
 +# Check is file exists on HDFS
 +import subprocess
 +
 +def run_cmd(args_list):​
 +    proc = subprocess.Popen(args_list,​ stdout=subprocess.PIPE,​ stderr=subprocess.PIPE)
 +    proc.communicate()
 +    return proc.returncode
 +
 +def check_is_file_exists_hdfs(filename):​
 +    cmd = ['​hdfs',​ '​dfs',​ '​-test',​ '​-f',​ filename]
 +    code = run_cmd(cmd)
 +    return code == 0
 </​code>​ </​code>​
kb/code_snippets.txt ยท Last modified: 2017/12/20 10:03 by yehuda
Back to top
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0