Is it possible to run ubuntu terminal commands using DJango

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?

Answers


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"])

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)?


Need Your Help

Autoresize Listview Columns on content update

c# wpf listview mvvm

I'm trying to get gridviewcolumns in a listview to auto-size to content on when the Binding source is updated (an observablecollection on a viewmodel).

javascript canvas image flickers with mousemove call

javascript canvas javascript-events mouseevent mousemove

Hello I'm trying to call an image(redraw) whenever I move my mouse,