/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome

« back to all changes in this revision

Viewing changes to lib/stdhome/command/init.py

  • Committer: Tim Marston
  • Date: 2014-04-18 15:00:34 UTC
  • Revision ID: tim@ed.am-20140418150034-l94wfs6ururhi9t5
fixed error in walker.py (from last checkin)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# command_init.py
 
1
# init.py
2
2
#
3
3
# Copyright (C) 2013 Tim Marston <tim@edm.am>
4
4
#
20
20
 
21
21
 
22
22
import sys, os, re, getopt, shutil, subprocess
23
 
import the
24
 
from deployment import Deployment
25
 
from subprocess import Popen
26
 
 
27
 
 
28
 
class CommandInit:
29
 
 
30
 
 
31
 
        def __init__( self ):
32
 
                self.repo = None
 
23
from command import Command
 
24
import stdhome.the as the
 
25
from stdhome.deployment import Deployment
 
26
from stdhome.subprocess import Popen
 
27
 
 
28
 
 
29
class InitCommand( Command ):
33
30
 
34
31
 
35
32
        def print_help( self ):
60
57
                                if not re.match( '^[-a-zA-z0-9.]+$', optarg ):
61
58
                                        raise the.program.FatalError(
62
59
                                                'invalid repository name: ' + optarg )
63
 
                                self.repo = optarg
 
60
                                the.repo = optarg
64
61
                        elif opt in [ '--verbose', '-v' ]:
65
 
                                the.verbose = True
 
62
                                the.verbose += 1
66
63
                        elif opt == "--help":
67
64
                                self.print_help()
68
65
                
72
69
                # URL argument
73
70
                self.url = args[ 0 ].strip() if len( args ) else None
74
71
 
75
 
                # remaining arguments
 
72
                # check remaining arguments
76
73
                if len( args ) > 1:
77
74
                        raise the.program.UsageError( 'too many arguments' )
78
75
 
80
77
        def run( self ):
81
78
 
82
79
                # set up repo and check it *doesn't* already exists
83
 
                the.set_repo( self.repo )
84
80
                the.repo.check_dir_exists( False )
85
81
 
86
82
                # ensure our top-level directory exists
100
96
                        deployment.copy_in()
101
97
 
102
98
                        # perform bzr checkout
103
 
                        if the.verbose: print "checking out %s" % the.repo.dir
 
99
                        if the.verbose >= 1: print "checking out %s" % the.repo.dir
104
100
                        try:
105
101
                                the.repo.vcs.checkout( self.url )
106
102
                        except Exception as e:
122
118
                else:
123
119
 
124
120
                        # perform bzr init
125
 
                        if the.verbose: print 'initialising %s' % the.repo.dir
 
121
                        if the.verbose >= 1: print 'initialising %s' % the.repo.dir
126
122
                        try:
127
123
                                the.repo.vcs.init()
128
124
                        except Exception as e: