Code Snippets

# Date format
import datetime
current_process_date = datetime.datetime.strptime('24-07-2010', "%d-%m-%Y").date()
current_process_date.strftime('We are the %d, %b %Y')
print("/%s/*" % current_process_date.strftime("%Y/%m/%d"))
# 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
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