annotate python/install_config.py @ 14:ac34d580c6d7

make symbolic links when necessary (should generalize)
author k0s <k0scist@gmail.com>
date Tue, 19 Jan 2010 16:22:21 -0500
parents c38d875a3b78
children 57298ea7a7f1
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
7
c38d875a3b78 updates to config
k0s <k0scist@gmail.com>
parents: 6
diff changeset
5 curl http://k0s.org/hg/config/raw/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
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
17 commands = [ ['hg', 'init'],
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
18 ['hg', 'pull', SRC],
14
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
19 ['hg', 'update', '-C'],
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
20
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
21 # site-specific files
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
22 ['rm', '.subversion/config'],
ac34d580c6d7 make symbolic links when necessary (should generalize)
k0s <k0scist@gmail.com>
parents: 7
diff changeset
23 ['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
24 ]
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
25
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
26 for command in commands:
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
27 code = subprocess.call(command)
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
28 if code:
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
29 sys.exit(code)
1
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
30
f58e8e81e16b adding program to install config
k0s <k0scist@gmail.com>
parents:
diff changeset
31
6
524f9e7fa224 be backwards compatible
k0s <k0scist@gmail.com>
parents: 1
diff changeset
32