【发布时间】:2015-08-10 13:05:37
【问题描述】:
代码:
#!/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文件代码:-
#!/bin/sh
. test/bin/activate
基本上不用shell脚本来创建virtualenv,激活它,运行几个步骤我想用python脚本。
我错过了什么?这是正确的用例吗?
【问题讨论】:
-
写一个shell脚本创建并激活virtualenv然后为你运行脚本不是更容易吗?
标签: python virtualenv