import gzip
from time import sleep
from ..command import Command
-from ..tools import process, ProcessInThread, downloadProcessHook
+from ..tools import process, ProcessInThread, downloadProcessHook, question
class BehatCommand(Command):
# Run cli
try:
+
+ # If Oracle, ask the user for a Behat prefix, if not set.
+ prefix = M.get('behat_prefix')
+ if M.get('dbtype') == 'oci' and (not prefix or len(prefix) > 2):
+ while not prefix or len(prefix) > 2:
+ prefix = question('What prefix would you like to use? (Oracle, max 2 chars)')
+ else:
+ prefix = None
+
logging.info('Initialising Behat, please be patient!')
- M.initBehat(switchcompletely=args.switchcompletely)
+ M.initBehat(switchcompletely=args.switchcompletely, prefix=prefix)
logging.info('Behat ready!')
# Preparing Behat command
else:
raise exception
- def initBehat(self, switchcompletely=False):
+ def initBehat(self, switchcompletely=False, prefix=None):
"""Initialise the Behat environment"""
if self.branch_compare(25, '<'):
self.updateConfig('behat_dataroot', behat_dataroot)
# Set Behat DB prefix
- behat_prefix = 'zbehat_'
- self.updateConfig('behat_prefix', behat_prefix)
+ currentPrefix = self.get('behat_prefix')
+ behat_prefix = prefix or 'zbehat_'
+
+ if not currentPrefix:
+ self.updateConfig('behat_prefix', behat_prefix)
+ elif currentPrefix != behat_prefix and self.get('dbtype') != 'oci':
+ # Warn that a prefix is already set and we did not change it.
+ # No warning for Oracle as we need to set it to something else.
+ logging.warning('Behat prefix not changed, already set to \'%s\', expected \'%s\'.' % (currentPrefix, behat_prefix))
# Switch completely?
if self.branch_compare(26, '<'):