File: install_py.py

package info (click to toggle)
lastz 1.04.52-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,604 kB
  • sloc: ansic: 39,808; python: 6,073; makefile: 843; sh: 53
file content (44 lines) | stat: -rwxr-xr-x 747 bytes parent folder | download | duplicates (2)
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))