Mercurial > hg > config
comparison python/install_config.py @ 590:e93b81d8a586
STUB: python/install_config.py
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Fri, 24 Jan 2014 17:53:23 -0800 |
| parents | ed99a36df540 |
| children | 542d329835ec |
comparison
equal
deleted
inserted
replaced
| 589:680071699d35 | 590:e93b81d8a586 |
|---|---|
| 18 import os | 18 import os |
| 19 import subprocess | 19 import subprocess |
| 20 import sys | 20 import sys |
| 21 | 21 |
| 22 # globals | 22 # globals |
| 23 SRC='http://k0s.org/hg/config' # config repository | 23 SRC = 'http://k0s.org/hg/config' # config repository |
| 24 HOME=os.environ['HOME'] | 24 HOME = os.environ['HOME'] # home directory |
| 25 | 25 |
| 26 ### standalone functions | 26 ### standalone functions |
| 27 | 27 |
| 28 def execute(*commands): | 28 def execute(*commands, **kwargs): |
| 29 """execute a series of commands""" | 29 """execute a series of commands""" |
| 30 for command in commands: | 30 for command in commands: |
| 31 print ' '.join(command) | 31 print (subprocess.list2cmdline(' '.join(command)) |
| 32 code = subprocess.call(command) | 32 code = subprocess.call(command, **kwargs) |
| 33 if code: | |
| 34 sys.exit(code) | |
| 35 | 33 |
| 36 def install_develop(package): | 34 def install_develop(package): |
| 37 """install k0s.ware for development""" | 35 """install k0s.ware for development""" |
| 38 | 36 |
| 39 src = 'http://k0s.org/hg/%s' % package | 37 src = 'http://k0s.org/hg/%s' % package |
| 40 directory = '%s/src/%s' % (package, package) | 38 directory = '%s/src/%s' % (package, package) |
| 41 commands = [ ['virtualenv/virtualenv.py', package], | 39 commands = [['virtualenv/virtualenv.py', package], |
| 42 ['mkdir', '-p', directory ], | 40 ['mkdir', '-p', directory ], |
| 43 ['hg', 'clone', src, directory] ] | 41 ['hg', 'clone', src, directory] ] |
| 44 execute(*commands) | 42 execute(*commands) |
| 45 old_directory = os.getcwd() | 43 old_directory = os.getcwd() |
| 46 os.chdir(directory) | 44 os.chdir(directory) |
| 47 command = ['../../bin/python', 'setup.py', 'develop'] | 45 command = ['../../bin/python', 'setup.py', 'develop'] |
| 48 execute(command) | 46 execute(command) |
| 49 os.chdir(old_directory) | 47 os.chdir(old_directory) |
| 50 | 48 |
| 51 ### generic step framework | 49 ### generic step framework |
| 50 | |
| 51 | |
| 52 | 52 |
| 53 class Step(object): | 53 class Step(object): |
| 54 @classmethod | 54 @classmethod |
| 55 def check(cls): | 55 def check(cls): |
| 56 """checks if the step may be run""" | 56 """checks if the step may be run""" |
| 90 # get the which command | 90 # get the which command |
| 91 sys.path.append(os.path.join(HOME, 'python')) | 91 sys.path.append(os.path.join(HOME, 'python')) |
| 92 from which import which | 92 from which import which |
| 93 | 93 |
| 94 #@requires(Command('git')) | 94 #@requires(Command('git')) |
| 95 class ConfigureGit(Step): | |
| 96 """configure git""" | |
| 97 commands = [['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')]] | |
| 98 | |
| 99 #@requires(Command('git')) | |
| 95 class InstallVirtualenv(Step): | 100 class InstallVirtualenv(Step): |
| 96 commands = [['git', 'clone', 'https://github.com/pypa/virtualenv.git'], | 101 commands = [['git', 'clone', 'https://github.com/pypa/virtualenv.git'], |
| 97 ['ln', '-s', | 102 ['ln', '-s', |
| 98 os.path.join(HOME, 'virtualenv/virtualenv.py'), | 103 os.path.join(HOME, 'virtualenv/virtualenv.py'), |
| 99 os.path.join(HOME, 'bin/')] | 104 os.path.join(HOME, 'bin', 'virtualenv.py')] |
| 100 ] | 105 ] |
| 106 | |
| 107 class InstallKWare(Step): | |
| 108 """install k0s.ware""" | |
| 101 | 109 |
| 102 class DebianPackages(Step): | 110 class DebianPackages(Step): |
| 103 """ubuntu packages to install""" | 111 """ubuntu packages to install""" |
| 104 # TODO: actually install packages | 112 # TODO: actually install packages |
| 105 | 113 |
| 117 "emacs", | 125 "emacs", |
| 118 "irssi"] | 126 "irssi"] |
| 119 def __call__(self): | 127 def __call__(self): |
| 120 print "Ensure the following packages are installed:" | 128 print "Ensure the following packages are installed:" |
| 121 print "sudo apt-get install %s" % ' '.join(self.PACKAGES) | 129 print "sudo apt-get install %s" % ' '.join(self.PACKAGES) |
| 122 | 130 |
| 123 | 131 |
| 124 ### legacy -v- | 132 ### legacy -v- |
| 125 | 133 |
| 126 def legacy(): | 134 def legacy(): |
| 127 """legacy : TO DEPRECATE!""" | 135 """legacy : TO DEPRECATE!""" |
| 128 | 136 |
| 129 # do git stuff | 137 # do git stuff |
| 130 git = which('git') | 138 git = which('git') |
| 131 if git: | 139 if git: |
| 132 | 140 |
| 133 # get virtual env | |
| 134 virtualenv_ | |
| 135 execute(*virtualenv_commands) | |
| 136 | |
| 137 # setup git's global ignore, since git is silly about this | 141 # setup git's global ignore, since git is silly about this |
| 138 # and doesn't look for the file in the right place | 142 # and doesn't look for the file in the right place |
| 139 execute(['git', 'config', '--global', 'core.excludesfile', os.path.join(HOME, '.gitignore')]) | |
| 140 | 143 |
| 141 # install some python | 144 # install some python |
| 142 install_develop('smartopen') | 145 install_develop('smartopen') |
| 143 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first | 146 install_develop('silvermirror') # XXX this won't actually work since python-dev isn't installed; install it first |
| 144 | 147 |
