summaryrefslogtreecommitdiffstats
path: root/src/nbblib/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/nbblib/commands.py')
-rw-r--r--src/nbblib/commands.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/nbblib/commands.py b/src/nbblib/commands.py
index bf8c6b5..c250cb1 100644
--- a/src/nbblib/commands.py
+++ b/src/nbblib/commands.py
@@ -317,8 +317,15 @@ class GeneralRunCommand(SourceClassCommand):
'builddir': self.bs_sourcetree.config.builddir,
'installdir': self.bs_sourcetree.config.installdir,
}[self.run_in]
+ def chdir(self):
+ rundir = self.get_run_in_dir()
+ if os.path.exists(rundir):
+ os.chdir(rundir)
+ else:
+ raise RuntimeError("The %s directory %s does not exist"
+ % (self.run_in, repr(rundir)))
def run(self):
- os.chdir(self.get_run_in_dir())
+ self.chdir()
progutils.prog_run(list(self.args), self.context)
@@ -348,7 +355,7 @@ class GeneralShellCommand(GeneralRunCommand):
% (self.context.prog, self.vcs_sourcetree.branch_name,
self.context.prog, self.name, self.get_run_in_dir(), )
def run(self):
- os.chdir(self.get_run_in_dir())
+ self.chdir()
# FIXME: Allow using $SHELL or similar.
progutils.prog_run(['sh'] + list(self.args), self.context,
env_update = {'PS1': self.get_shell_prompt()})