4
votes

I am designing a simple website using DJango and my database is HBase. In some Part I need to save some files on HDFS, for example video file, and have it's URI. But my problem is I couldn't find any API for accessing HDFS through DJango so I decided to use ubuntu terminal command to upload and download data on HDFS. Now I want to know is there any way to run terminal command using Django or any other way to access HDFS API through Django?

2

2 Answers

0
votes

have django make a call to a subprocess like the one below. each string in the command should be a string in a list.

import subprocess
subprocess.call(["ls", "-l"])
0
votes

You don't need to search for Django implemented libraries, Django is written in python and python is providing libraries for it.

An alternative solution

import subprocess
subprocess.Popen(['python', 'manage.py', 'runserver'])

you can excecute shell commands using subprocess.Popen also. The difference between subprocess Popen and call and how to use them is described here What's the difference between subprocess Popen and call (how can I use them)?