Based on this link I created and activated a virtual environment in a Python script but what I want is after activating the virtualenv the rest of the code should run in the env, install few items and then process.
Code:
#!/usr/bin/python
import commands
import os
import time
import datetime
import sys
import json
import requests
out = commands.getoutput("wget <url>/s.sh")
new = commands.getoutput("chmod 755 s.sh")
env = "virtualenv " + "test"
#checking if env present if not create and activate it
try:
l=commands.getoutput('/bin/bash --rcfile s.sh')
except:
print env + " not present"
m = commands.getoutput(env)
print env + " not present so creating"
os.system('/bin/bash --rcfile s.sh')
v = commands.getoutput("which python")
print v + " python to be used"
v = commands.getoutput("pip install wget")
s.sh file code:-
#!/bin/sh
. test/bin/activate
Basically instead of a shell script to create virtualenv, activate it, and run a few steps I want to use python script.
What am I missing? Is it right use case?