Example #1
0
def command_init():
    """Initializes various systems ('all' if none specified)"""
    sub_systems = {
            'config' : False,
            'bank' : False,
            'paths' : False
        }

    if args.option in sub_systems:
        sub_systems[args.option] = True
    elif args.option is None:
        for k in sub_systems:
            sub_systems[k] = True
    else:
        print("Error! Invalid sub-system!")
        print("See help for 'init' to see valid sub-sustems!")
        sys.exit(1)

    print("Initializing vamp...\n")

    if sub_systems['config']:
        print("> Initializing configuration file...")
        c = Config()
        if args.force:
            print(">> Forcing default values for configuration file...")
            c.set_defaults()
            c.save()

    if sub_systems['paths']:
        print("> Initializing system paths...")
        c = Config()
        if 'paths' not in c.config:
            print("Error! Configuration file is missing 'paths' section!")
            print("Did you forget to init the config sub-system?")
            sys.exit(1)

        for p in c.config['paths']:
            print(">> Initializing '{0}'...".format(p))
            ensure_path(c.config['paths'][p])

    if sub_systems['bank']:
        print("> Initializing blood bank...")
        b = Bank()
        b.init_bank(bank=None, force=args.force)
Example #2
0
 def _get_installdir(self, package):
     """Given a package name, get the installation directory for it."""
     indir = "{0}/{1}".format(self.c.get('paths', 'install', True), package)
     self._working_dirs.add(indir)
     ensure_path(indir)
     return indir
Example #3
0
 def _get_workdir(self, package):
     """Given a package name, get a working directory for it."""
     wdir = tempfile.mkdtemp(prefix=package)
     self._working_dirs.add(wdir)
     ensure_path(wdir)
     return wdir