Merge lp:~frankban/lpsetup/minor-fixes into lp:lpsetup

Proposed by Francesco Banconi
Status: Merged
Approved by: Francesco Banconi
Approved revision: 68
Merged at revision: 67
Proposed branch: lp:~frankban/lpsetup/minor-fixes
Merge into: lp:lpsetup
Diff against target: 69 lines (+9/-7)
2 files modified
lpsetup/subcommands/finish_inithost.py (+1/-1)
lpsetup/subcommands/update.py (+8/-6)
To merge this branch: bzr merge lp:~frankban/lpsetup/minor-fixes
Reviewer Review Type Date Requested Status
Francesco Banconi (community) Approve
Brad Crittenden (community) code Approve
Review via email: mp+117699@code.launchpad.net

Commit message

Fixed su/cd context managers order. Improved update subcommand output.

Description of the change

== Changes ==

Inverted the order of *su* and *cd* context managers to avoid permission denied errors, e.g.::

    being in /root as root, before:
        su user
            cd /home/user
                [real stuff]
            cd /root --> premission denied
    and now:
        cd /home/user
            su user
                [real stuff]
            su root
        cd /root

 s/run/call in update sub command to give the user some feedback on what's happening.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Nice changes and an easy fix to your problem.

review: Approve (code)
Revision history for this message
Launchpad QA Bot (lpqabot) wrote :

The attempt to merge lp:~frankban/lpsetup/minor-fixes into lp:lpsetup failed. Below is the output from the failed tests.

./lpsetup/subcommands/update.py
      52: E501 line too long (80 characters)

lp:~frankban/lpsetup/minor-fixes updated
68. By Francesco Banconi

Lint.

Revision history for this message
Francesco Banconi (frankban) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lpsetup/subcommands/finish_inithost.py'
2--- lpsetup/subcommands/finish_inithost.py 2012-07-30 10:05:19 +0000
3+++ lpsetup/subcommands/finish_inithost.py 2012-08-01 15:28:17 +0000
4@@ -40,7 +40,7 @@
5
6 # Launchpad database setup.
7 # nested is required for use by python 2.6.
8- with nested(su(user), cd(target_dir)):
9+ with nested(cd(target_dir), su(user)):
10 call('utilities/launchpad-database-setup', user)
11
12 # Make and install launchpad.
13
14=== modified file 'lpsetup/subcommands/update.py'
15--- lpsetup/subcommands/update.py 2012-07-30 10:05:19 +0000
16+++ lpsetup/subcommands/update.py 2012-08-01 15:28:17 +0000
17@@ -10,15 +10,16 @@
18 ]
19
20 import os.path
21+
22 from shelltoolbox import (
23 cd,
24 mkdirs,
25- run,
26 )
27
28 from lpsetup import argparser
29 from lpsetup import handlers
30 from lpsetup.settings import LP_SOURCE_DEPS
31+from lpsetup.utils import call
32
33
34 def initialize_directories(target_dir, external_path):
35@@ -41,20 +42,21 @@
36 abs_external_path = os.path.abspath(
37 os.path.join(target_dir, external_path))
38 source_path = os.path.join(abs_external_path, 'sourcecode')
39- run(cmd, use_http_param, source_path)
40+ call(cmd, use_http_param, source_path)
41
42 # Update the download cache.
43 download_cache = os.path.join(target_dir, 'download-cache')
44 if os.path.exists(download_cache):
45- run('bzr', 'up', download_cache)
46+ call('bzr', 'up', download_cache)
47 else:
48- run('bzr', 'co', '-v', '--lightweight', LP_SOURCE_DEPS, download_cache)
49+ call('bzr', 'co', '-v', '--lightweight',
50+ LP_SOURCE_DEPS, download_cache)
51
52 # Link to the external sourcecode.
53 if abs_external_path != target_dir:
54 cmd = os.path.join(
55 target_dir, 'utilities', 'link-external-sourcecode')
56- run(cmd,
57+ call(cmd,
58 '--target', target_dir,
59 '--parent', external_path)
60
61@@ -66,7 +68,7 @@
62 def update_tree(target_dir):
63 """Update the tree at target_dir with the latest LP code."""
64 with cd(target_dir):
65- run('bzr', 'pull')
66+ call('bzr', 'pull')
67
68 update_tree.description = """Update the tree at $target_dir with the \
69 latest LP code.

Subscribers

People subscribed via source and target branches

to all changes: