1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
#!/usr/bin/env python
import sys
import string
try:
from subprocess import getoutput
except ImportError:
from commands import getoutput
def do (command):
print (command)
output = getoutput(command)
if (len(output) > 0): print (output)
binDir = "~/py/bin"
currentDir = getoutput("pwd").strip()
args = sys.argv[1:]
remove = False
if (args[0] == "--remove"):
remove = True
args.pop(0)
binDir = args.pop(0)
for f in args:
if f.endswith (".py"):
fPy = f
fNoPy = f[:-3]
else:
fPy = "%s.py" % f
fNoPy = f
fileHere = "%s/%s" % (currentDir, fPy)
fileInBin = "%s/%s" % (binDir, fNoPy)
if (remove):
do ("rm %s" % (fileInBin))
else:
do ("ln -s %s %s" % (fileHere,fileInBin))
do ("chmod +x %s" % (fileInBin))
|