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

  • Committer: Tim Marston
  • Date: 2014-02-12 21:51:49 UTC
  • Revision ID: tim@ed.am-20140212215149-msaxl7vo98il5i4a
added more commands

Show diffs side-by-side

added added

removed removed

1
 
# status.py
 
1
# command_status.py
2
2
#
3
3
# Copyright (C) 2014 Tim Marston <tim@edm.am>
4
4
#
20
20
 
21
21
 
22
22
import sys, re, getopt
23
 
from command import Command
24
 
import stdhome.the as the
25
 
from stdhome.deployment import Deployment
26
 
from stdhome.walker.status import StatusWalker
27
 
 
28
 
 
29
 
class StatusCommand( Command ):
 
23
import the
 
24
from deployment import Deployment
 
25
 
 
26
 
 
27
class CommandStatus:
30
28
 
31
29
 
32
30
        def __init__( self ):
66
64
                                                'invalid repository name: ' + optarg )
67
65
                                self.repo = optarg
68
66
                        elif opt in [ '--verbose', '-v' ]:
69
 
                                the.verbose += 1
 
67
                                the.verbose = True
70
68
                        elif opt == "--help":
71
69
                                self.print_help()
72
70
                
84
82
                the.set_repo( self.repo )
85
83
                the.repo.check_dir_exists()
86
84
 
 
85
                deployment = Deployment()
87
86
                message = ''
88
87
 
89
 
                # initialise deployment and check if it's ongoing
90
 
                deployment = Deployment()
 
88
                # check for differing files
 
89
                files = deployment.get_diffs()
 
90
                if files:
 
91
                        message += 'Modified files in %s\n  %s\n' % \
 
92
                                           ( the.fsdir, '\n  '.join( files ) )
 
93
 
 
94
                # check for conflicts
 
95
                files = the.repo.vcs.get_conflicts()
 
96
                if files:
 
97
                        message += 'Conflicts in %s:\n  %s\n' % \
 
98
                                           ( the.repo.dir, '\n  '.join( files ) )
91
99
                if deployment.is_ongoing():
92
 
 
93
 
                        # check for conflicts in repo
94
 
                        files = the.repo.vcs.get_conflicts()
 
100
                        files = deployment.get_conflicts()
95
101
                        if files:
96
 
                                message += 'Conflicts in %s:\n  %s\n' % \
97
 
                                                   ( the.repo.name, '\n  '.join( files ) )
98
 
 
99
 
                        # get deployment conflicts
100
 
                        conflicts = deployment.get_conflicts()
101
 
                        if conflicts:
102
102
                                message += 'Deployment conflicts:\n  %s\n' % \
103
 
                                                   '\n  '.join( conflicts )
104
 
 
105
 
                else:
106
 
 
107
 
                        # check status
108
 
                        walker = StatusWalker()
109
 
                        walker.walk()
110
 
                        if walker.modified:
111
 
                                message += 'Modified:\n  %s\n' % \
112
 
                                                   '\n  '.join( walker.modified )
113
 
                        if walker.missing:
114
 
                                message += 'Missing:\n  %s\n' % \
115
 
                                                   '\n  '.join( walker.missing )
116
 
                        if walker.changed:
117
 
                                message += 'Type changed:\n  %s\n' % \
118
 
                                                   '\n  '.join( walker.changed )
 
103
                                                   '\n  '.join( files )
119
104
 
120
105
                # show status
121
106
                if message: print message.rstrip()