calling hive -e from a python script -


i run simple hive command within python script. trying use hive -e, getting error

def hive():     cmd = "hive -e \"msck repair table dashboard_report\""     print(cmd)     check_call(cmd) 

this error getting

hive -e "msck repair table dashboard_report" traceback (most recent call last): file "/home/yosi/work/source/slg/tiger/src/main/resources/python/tiger.py", line 59, in <module> hive() file  "/home/yosi/work/source/slg/tiger/src/main/resources/python/tiger.py", line 57, in hive check_call(cmd) file "/usr/lib/python2.7/subprocess.py", line 535, in check_call retcode = call(*popenargs, **kwargs) file "/usr/lib/python2.7/subprocess.py", line 522, in call return popen(*popenargs, **kwargs).wait() file "/usr/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) file "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child raise child_exception oserror: [errno 2] no such file or directory 

your check_call function calling subprocess.popen. if want pass arguments function have pass them in list.

probably:

cmd = ["hive", "-e", "\"msck repair table dashboard_report\""] check_call(cmd) 

will work. maybe refactoring needed down call stack accept list instead of string.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -