moinsetup

Changeset

8:b6c4091689f5
2010-05-13 Paul Boddie raw files shortlog changelog graph Moved directory testing and creation into a separate method. Reorganised the main program structure somewhat.
moinsetup.py (file)
     1.1 --- a/moinsetup.py	Thu May 13 22:33:07 2010 +0200
     1.2 +++ b/moinsetup.py	Thu May 13 22:48:11 2010 +0200
     1.3 @@ -148,14 +148,19 @@
     1.4          finally:
     1.5              os.chdir(this_dir)
     1.6  
     1.7 -    def setup(self):
     1.8 +    def ensure_directories(self):
     1.9  
    1.10 -        "Set up the installation."
    1.11 +        "Make sure that all the directories are available."
    1.12  
    1.13          for d in (self.conf_dir, self.instance_dir, self.web_app_dir, self.web_site_dir):
    1.14              if not exists(d):
    1.15                  os.makedirs(d)
    1.16  
    1.17 +    def setup(self):
    1.18 +
    1.19 +        "Set up the installation."
    1.20 +
    1.21 +        self.ensure_directories()
    1.22          self.install_moin()
    1.23          self.install_data()
    1.24          self.configure_moin()
    1.25 @@ -352,21 +357,17 @@
    1.26      try:
    1.27          matches = syntax.get_args(sys.argv[1:])
    1.28          args = matches[0]
    1.29 -    except IndexError:
    1.30 -        print "Syntax:"
    1.31 -        print sys.argv[0], syntax_description
    1.32 -        print
    1.33 -        print "Arguments:"
    1.34 -        print Installation.__init__.__doc__
    1.35 -        sys.exit(1)
    1.36 +
    1.37 +        # Obtain as many arguments as needed for the configuration.
    1.38 +
    1.39 +        arguments = args["argument"]
    1.40  
    1.41 -    # Obtain as many arguments as needed for the configuration.
    1.42 -
    1.43 -    arguments = args["argument"]
    1.44 +        # Attempt to initialise the configuration.
    1.45  
    1.46 -    try:
    1.47          installation = Installation(*arguments)
    1.48 -    except TypeError:
    1.49 +
    1.50 +    except (IndexError, TypeError):
    1.51 +        print "Syntax:"
    1.52          print sys.argv[0], syntax_description
    1.53          print
    1.54          print "Arguments:"