~nick-moffitt/mojo/rename-manifest-to-run

« back to all changes in this revision

Viewing changes to mojo/__init__.py

[thedac,r=mthaddon] allow run and workspace-new to accept env variables, better cli exception and error messages, some lint fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
        if not self.is_initialized:
81
81
            return None
82
82
        self._manifest = Manifest(self, manifest_file=self.manifest_file,
83
 
            stage=self.stage)
 
83
                                  stage=self.stage)
84
84
        return self._manifest
85
85
 
86
86
    def _remove_duplicates(self, mylist):
133
133
 
134
134
        print "Manifest:", self.manifest_file
135
135
        print "remote branch", self.remote_branch.location
136
 
        raise ConfigNotFoundException("Config '{}' not found\n" \
137
 
              "Is the MOJO_STAGE environment variable or the --stage option " \
138
 
              "set?\nIs {} a spec branch?".format(base,
139
 
                                                  self.local_branch.location),
140
 
                                      config_names)
 
136
        raise ConfigNotFoundException(
 
137
            "Config '{}' not found.\n"
 
138
            "Is the MOJO_STAGE environment variable or the --stage option "
 
139
            "set?\nIs {} a spec branch?".format(base,
 
140
                                                self.local_branch.location),
 
141
            config_names)
141
142
 
142
143
    def get_config(self, base, stage=None):
143
144
        """Locate a stage-qualified configuration file.
184
185
        else:
185
186
            for _path in iterate_subpaths(parts[1]):
186
187
                yield _path
187
 
         
 
188
 
188
189
 
189
190
def parse_manifest(manifest_path):
190
191
    """Return a list of phases from the manifest file."""
249
250
 
250
251
    def run(self, project, workspace, series, stage=None):
251
252
        "Run all phases defined in this manifest"
252
 
        for phase in self.phases:
253
 
            phase.run(project, workspace, series, stage)
 
253
        for phase_name in self.phases:
 
254
            phase_name.run(project, workspace, series, stage)
254
255
 
255
256
 
256
257
#######################################
293
294
                            with open(digestpath) as digestfile:
294
295
                                for line in digestfile:
295
296
                                    previous_revno = line.split()[0]
296
 
                                    logging.debug("Read revno={} from {}: {}"
 
297
                                    logging.debug(
 
298
                                        "Read revno={} from {}: {}"
297
299
                                        "".format(previous_revno,
298
300
                                                  digestpath, line))
299
301
                        if not previous_revno == str(current_revno):
350
352
            # map my running uid to username
351
353
            self.owner = pwd.getpwuid(os.getuid()).pw_name
352
354
 
353
 
        ### Paths ###
 
355
        # ### Paths ###
354
356
        # /srv/mojo/<prj>
355
357
        self.root = Project.root_path(self.name)
356
358
        # /srv/mojo/<prj>/<series>
424
426
            logging.info("Not found, creating LXC container")
425
427
            # Can't use root location on precise's version of lxc
426
428
            # missing -B --dir option
427
 
            #self.container.create(self.container_root)
 
429
            # self.container.create(self.container_root)
428
430
            self.container.create()
429
431
 
430
432
        logging.info("Checking {} project LXC container setup ..."
482
484
                         manifest_file='manifest', clean_spec=True):
483
485
 
484
486
        # Validate the project exists
485
 
        if not self.name in self.list(True):
 
487
        if self.name not in self.list(True):
486
488
            print "Project, '{}', does not appear to exist.".format(self.name)
487
489
            print "Please run 'sudo mojo project-new --series {} {}' to " \
488
490
                  "create the project.".format(self.series, self.name)
506
508
        mkdirs(ws_path, self.owner)
507
509
        mksymlink(ws_path, self.ws_link(title))
508
510
        ws = Workspace(title, self.ws_link(title), stage=stage,
509
 
            manifest_file=manifest_file)
 
511
                       manifest_file=manifest_file)
510
512
        ws.prepare()
511
513
        spec = Spec(ws.spec_dir, spec_url, stage=stage, manifest_file=manifest_file)
512
514
        spec.initialize(clean_spec)
523
525
 
524
526
    def workspace_list(self):
525
527
        workspaces = [w for w in os.listdir(self.lxc_project_series) if w != 'LOCAL']
526
 
        workspace_output = ["Workspace: Spec URL", 
 
528
        workspace_output = ["Workspace: Spec URL",
527
529
                            "==================="]
528
530
        for workspace in workspaces:
529
531
            workspace_output.append("%s: %s" % (workspace,
564
566
            spec_repo = bzr.BzrBranch(self.spec_dir)
565
567
            if spec_repo.is_branch:
566
568
                return Spec(local_dir=self.spec_dir, stage=self.stage,
567
 
                    manifest_file=self.manifest_file)
 
569
                            manifest_file=self.manifest_file)
568
570
        return None
569
571
 
570
572
    @property