/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/deployment.py

  • Committer: Tim Marston
  • Date: 2014-01-05 11:51:35 UTC
  • Revision ID: tim@ed.am-20140105115135-6ses87ggwyjrxzfj
added global objects (the.repo, the.program), deployment object and implemented
init command

Show diffs side-by-side

added added

removed removed

 
1
# deployment.py
 
2
#
 
3
# Copyright (C) 2013 Tim Marston <tim@edm.am>
 
4
#
 
5
# This file is part of stdhome (hereafter referred to as "this program").
 
6
# See http://ed.am/dev/stdhome for more information.
 
7
#
 
8
# This program is free software: you can redistribute it and/or modify
 
9
# it under the terms of the GNU General Public License as published by
 
10
# the Free Software Foundation, either version 3 of the License, or
 
11
# (at your option) any later version.
 
12
#
 
13
# This program is distributed in the hope that it will be useful,
 
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
# GNU General Public License for more details.
 
17
#
 
18
# You should have received a copy of the GNU General Public License
 
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
 
 
21
 
 
22
import os
 
23
import the
 
24
 
 
25
 
 
26
class Deployment:
 
27
 
 
28
 
 
29
        def __init__( self ):
 
30
 
 
31
                # initialise the file list
 
32
                self.file_list = None
 
33
                if not os.path.exists( the.repo.expanded_dir ):
 
34
                        self.file_list = []
 
35
                else:
 
36
                        self.load_file_list()
 
37
 
 
38
                assert False # not implemented
 
39
 
 
40
 
 
41
        def load_file_list( self ):
 
42
 
 
43
                # if no file list, don't load one
 
44
                if .....
 
45
                        return
 
46
 
 
47
                # load it
 
48
 
 
49
 
 
50
        def copy_in( self ):
 
51
 
 
52
                # check we don't already have a file list
 
53
                if self.file_list is not None:
 
54
                        raise the.FatalError( 'deployment in progress; ' + \
 
55
                                'see "%s resolve --help" for information' % the.program.name )
 
56
                        
 
57
                assert False # not implemented
 
58
 
 
59
 
 
60
        def copy_out( self ):
 
61
                if self.pre_copy_out_list is None:
 
62
                        return
 
63
 
 
64
                print "deploying files"
 
65
 
 
66
                # walk the repo
 
67
                for ( repodir, directories, files ) in os.walk( the.repo.expanded_dir ):
 
68
                        assert path[ : len( the.repo.expanded_dir ) ] == \
 
69
                                the.repo.expanded_dir
 
70
                        relative_path = path[ len( the.repo.expanded_dir ) : ]
 
71
                        fsdir = the.expanded_fsdir + relative_path
 
72
 
 
73
                        print relative_path
 
74
 
 
75
                        # check directories
 
76
                        for dir in directories:
 
77
                                if os.path.exists( fsdir + dir ) and \
 
78
                                   not os.path.isdir( fsdir + dir ):
 
79
 
 
80
                                        #
 
81
 
 
82
                        # if exists in repo as directory and also in fs as non-directory
 
83
                        if os.path.isdir( the.repo.expnaded_dir + relative_path +