def command(self, cmd):
dir = os.path.join(self.directory, os.path.relpath(os.getcwd(), self.directory))
- command('%s exec %s -i -t %s /bin/bash -c \'export %s; cd %s; %s\'' % (config.docker(), self._user_tag(), self.container, self.variables_string(), dir, cmd))
+ interactive_flag = '-i ' if sys.stdin.isatty() else ''
+ command('%s exec %s %s -t %s /bin/bash -c \'export %s; cd %s; %s\'' % (config.docker(), self._user_tag(), interactive_flag, self.container, self.variables_string(), dir, cmd))
def cleanup(self):
super(DockerTarget, self).cleanup()
def add_defaults(self, options):
"""Add the defaults from this into a dict options"""
if 'option_defaults' in self.cscript:
- for k, v in self.cscript['option_defaults']().items():
+ from_cscript = self.cscript['option_defaults']
+ if isinstance(from_cscript, dict):
+ defaults_dict = from_cscript
+ else:
+ log("Deprecated cscript option_defaults method; replace with a dict")
+ defaults_dict = from_cscript()
+ for k, v in defaults_dict.items():
if not k in options:
options[k] = v