I have a Django site that is up and running.  I need to add a feature to call wget in response to a user action.  How should I do this from the Django application?
            Asked
            
        
        
            Active
            
        
            Viewed 364 times
        
    3 Answers
5
            
            
        Since Django is written in Python you can use Python's subprocess module to call wget in one of your views. However, if you merely want to download a file with wget (and not use one of its advanced features), you can emulate its behavior more easily with urllib2.
 
    
    
        Uku Loskit
        
- 40,868
- 9
- 92
- 93
- 
                    Also, if this operation is expensive, you must consider running the operation outside the request cycle, by using Celery, for example. – Armando Pérez Marqués Apr 09 '12 at 03:09
2
            
            
        Is there a reason why you're resorting to a unix command, rather than using something like urllib2?
If there is, you can always use this within your view:
from subprocess import call
call(["wget", "http://myurl.com"])
Here's a pretty comprehensive thread on the matter:
 
    
    
        Community
        
- 1
- 1
 
    
    
        user1309663
        
- 105
- 7
 
    