コード例 #1
0
ファイル: build.py プロジェクト: gmoro/jurt
    def build_user_home(self, username):
        from jurtlib.template import template_expand

        env = {"username": username}
        value = template_expand(self.builderhome, env)
        path = os.path.abspath(value)
        return path
コード例 #2
0
ファイル: rootcommand.py プロジェクト: AlexandreProenca/jurt
 def cmd_interactiveprepare(self):
     from jurtlib.template import template_expand
     if not self.args:
         raise CliError, "username is mandatory in args"
     user = self.args[0]
     allowedcmds = self.target.packagemanager.allowed_pm_commands()
     cmdsline = ",".join(allowedcmds)
     rawline = self.config.root.sudo_pm_allow_format
     env = {"user": user, "commands": cmdsline}
     sudoline = template_expand(rawline, env)
     sudoerspath = os.path.abspath(self.opts.root+ "/" +
             self.config.root.sudoers)
     f = open(sudoerspath, "a")
     f.write(sudoline + "\n")
     f.close()
コード例 #3
0
ファイル: rootcommand.py プロジェクト: AlexandreProenca/jurt
 def cmd_interactiveshell(self):
     from jurtlib.template import template_expand
     if not self.args:
         raise CliError, "username is mandatory in args"
     if not self.target.rootmanager.allows_interactive_shell():
         raise CliError, "interactive configuration not allowed "\
                 "for this target"
     args = self.target.rootmanager.sudo_interactive_shell_command()
     args.extend(("-u", self.args[0]))
     rawcmd = self.target.rootmanager.interactive_shell_command()
     env = {"target": self.target.name, "root": self.opts.root}
     cmdline = template_expand(rawcmd, env)
     args.extend(shlex.split(cmdline))
     if not self.opts.dry_run:
         try:
             self._exec(args, error=False, exit=False, interactive=True)
         except CommandError, e:
             if e.returncode == 127:
                 raise
コード例 #4
0
 def setup_repositories(self, root, repos, logstore, spool=None):
     if spool:
         rootspool = root.make_spool_reachable(spool)
     outputlogger = logstore.get_output_handler("addmedia")
     try:
         try:
             if spool is not None and spool.package_count():
                 vars = {"path": rootspool.in_root_path()}
                 args = [template_expand(arg, vars)
                         for arg in self.spoolchannel]
                 root.su().run_package_manager("smart.addchannel", args,
                         outputlogger=outputlogger)
         finally:
             outputlogger.close()
             if spool:
                 rootspool.destroy()
     except su.CommandError, e:
         raise PackageManagerError, ("failed to setup repositories, "
                 "see the logs at %s" % (outputlogger.location))
コード例 #5
0
 def update_repository_metadata(self, path):
     vars = {"path": path}
     args = [template_expand(arg, vars) for arg in self.spoolupdatecmd[:]]
     cmd.run(args)