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

  • Committer: Tim Marston
  • Date: 2014-04-12 13:03:11 UTC
  • Revision ID: tim@ed.am-20140412130311-kwednshmt07i1a26
remove ambiguous argument parsing (the first argument should be the command,
because we can't reliably parse-away options, which may have argument, e.g.,
"stdhome -r test status")

Show diffs side-by-side

added added

removed removed

19
19
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
20
 
21
21
 
22
 
import os, sys, getopt
 
22
import os, sys, getopt, ConfigParser
23
23
import the
24
 
from config import Config
25
24
from vcs.vcs import Vcs
26
25
 
27
26
 
147
146
                        pass
148
147
 
149
148
                # read program configuration
150
 
                the.config = Config()
 
149
                self.read_config()
151
150
 
152
151
                # the first argument should be the command
153
152
                the.command = sys.argv[ 1 ] if len( sys.argv ) > 1 else None
189
188
                        instance.run()
190
189
                except Vcs.VcsError as e:
191
190
                        message = e.msg.rstrip()
192
 
                        if the.verbose >= 1:
 
191
                        if the.verbose:
193
192
                                message += '\n\nOUTPUT:\n' + e.output.rstrip()
194
193
                        self.die( message )
195
194
                except self.FatalError as e:
196
195
                        self.die( e.msg )
197
196
 
198
197
 
 
198
        def read_config( self ):
 
199
                config = ConfigParser.SafeConfigParser( allow_no_value = True )
 
200
                config.read( the.config_file )
 
201
                if config.has_option( 'stdhome', 'home-dir' ):
 
202
                        the.home_dir = config.get( 'stdhome', 'home-dir' )
 
203
 
 
204
 
199
205
        class UsageError( Exception ):
200
206
 
201
207
                def __init__( self, error_message ):