Commits

Mikhail Korobov  committed fcc52fe Merge

merge. See #30.

  • Participants
  • Parent commits 11ce1b0, d47c7aa

Comments (0)

Files changed (4)

File fab_deploy/django_commands.py

File contents unchanged.

File fab_deploy/system.py

 
     username = username or env.conf.USER
 
-    @utils.run_as(username)
-    def setup_pip_conf():
-        from fab_deploy import virtualenv
-        virtualenv.pip_setup_conf()
-
     with (settings(warn_only=True)):
         sudo('adduser %s --disabled-password --gecos ""' % username)
 
-    with cd(env.conf.HOME_DIR):
+    home_dir = utils.get_home_dir(username)
+    with cd(home_dir):
         sudo('mkdir -p .ssh')
         files.append('.ssh/authorized_keys', ssh_key, use_sudo=True)
         sudo('chown -R %s:%s .ssh' % (username, username))
-    setup_pip_conf()
+
+    from fab_deploy import virtualenv
+    virtualenv.pip_setup_conf(username=username)
 
 @utils.run_as('root')
 def create_sudo_linux_account(pub_key_file, username=None):

File fab_deploy/utils.py

     """ Prints env values. Useful for debugging. """
     puts(pprint.pformat(env))
 
+def get_home_dir(username):
+    if username == 'root':
+        return '/root/'
+    return '/home/%s/' % username
+
 def _data_path(fname):
     """Return the path to a data file of ours."""
     return os.path.join(os.path.split(__file__)[0], fname)

File fab_deploy/virtualenv.py

     if restart:
         apache.touch()
 
-def pip_setup_conf():
+def pip_setup_conf(username=None):
     """ Sets up pip.conf file """
-    run('mkdir -p .pip')
-    utils.upload_config_template('pip.conf',
-        env.conf.HOME_DIR + '/.pip/pip.conf', skip_unexistent=True)
+    username = username or env.conf.USER
+    home_dir = utils.get_home_dir(username)
+
+    @utils.run_as(username)
+    def do_setup_conf():
+        run('mkdir --parents %s.pip' % home_dir)
+        utils.upload_config_template('pip.conf',
+            home_dir + '.pip/pip.conf', skip_unexistent=True)
+
+    do_setup_conf()
 
 def virtualenv_create():
     run('mkdir -p envs')