annotate python/install_config.py @ 30:6c43389ce405

adding the smartopen.ini file to version control
author Jeff Hammel <k0scist@gmail.com>
date Wed, 10 Mar 2010 18:52:35 -0500
parents 8344c7a9847c
children 4f07325e727a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
2 """
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
3 installs config to a user's home directory
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
4 this can be done with
16
57298ea7a7f1 fix string for how to install
k0s <k0scist@gmail.com>
parents: 14
diff changeset
5 curl http://k0s.org/hg/config/raw-file/tip/python/install_config.py | python
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
6 """
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
7
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
8 SRC='http://k0s.org/hg/config'
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
9 import os
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
10 import sys
14
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
11 HOME=os.environ['HOME']
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
12 os.chdir(HOME)
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
13
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
14 # make the current directory a repository
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
15 import subprocess
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
16
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
17
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
18
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
19 commands = [ ['hg', 'init'],
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
20 ['hg', 'pull', SRC],
14
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
21 ['hg', 'update', '-C'],
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
22 ['hg', 'clone', 'http://bitbucket.org/ianb/virtualenv'],
14
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
23
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
24 # site-specific files
22
8da594377f18 updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents: 16
diff changeset
25 ['mkdir', '-p', '.subversion'],
8da594377f18 updates so installation wont break if no .subversion directory
k0s <k0scist@gmail.com>
parents: 16
diff changeset
26 ['rm', '-f', '.subversion/config'],
14
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
27 ['ln', '-s', os.path.join(HOME, '.subversion_config/config'), os.path.join(HOME, '.subversion/config')],
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
28 ]
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
29
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
30 def execute(*commands):
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
31 for command in commands:
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
32 print ' '.join(command)
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
33 code = subprocess.call(command)
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
34 if code:
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
35 sys.exit(code)
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
36
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
37 execute(*commands)
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
38
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
39 def install_develop(package):
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
40 src = 'http://k0s.org/hg/%s' % package
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
41 commands = [ ['virtualenv/virtualenv.py', package],
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
42 ['mkdir', '%s/src'],
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
43 ['hg', 'clone', src, '%s/src/%s' % (package, package)],
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
44 ['%s/bin/python', '%s/src/%s/setup.py', 'develop'] ]
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
45 execute(*commands)
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
46
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
47 # install some python
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
48 install_develop('smartopen')
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
49
29
8344c7a9847c install smartopen by default and some other cleanup (untested)
Jeff Hammel <k0scist@gmail.com>
parents: 22
diff changeset
50 postinstall_commands = [ ['ln', '-s', os.path.join(HOME, 'smartopen', 'bin', 'smartopen'), os.path.join(HOME, 'bin', 'smartopen')]