import logging
import os
import pytz
+import re
import six
import sys
import subprocess
"""
pass
+ class ActiveTask(Exception):
+ """
+ Raised when the operation cannot be performed on the active task.
+ """
+ pass
+
class InactiveTask(Exception):
"""
Raised when the operation cannot be performed on an inactive task.
raise Task.CompletedTask("Cannot start a completed task")
elif self.deleted:
raise Task.DeletedTask("Deleted task cannot be started")
+ elif self.active:
+ raise Task.ActiveTask("Task is already active")
self.warrior.execute_command([self['uuid'], 'start'])
elif self.deleted:
raise Task.DeletedTask("Deleted task cannot be completed")
+ # Older versions of TW do not stop active task at completion
+ if self.warrior.version < VERSION_2_4_0 and self.active:
+ self.stop()
+
self.warrior.execute_command([self['uuid'], 'done'])
# Refresh the status again, so that we have updated info stored
stdout, stderr = [x.decode('utf-8') for x in p.communicate()]
return stdout.strip('\n')
+ def get_config(self):
+ raw_output = self.execute_command(
+ ['show'],
+ config_override={'verbose': 'nothing'}
+ )
+
+ config = dict()
+ config_regex = re.compile(r'^(?P<key>[^\s]+)\s+(?P<value>[^\s].+$)')
+
+ for line in raw_output:
+ match = config_regex.match(line)
+ if match:
+ config[match.group('key')] = match.group('value').strip()
+
+ return config
+
def execute_command(self, args, config_override={}, allow_failure=True,
return_all=False):
command_args = self._get_command_args(