You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by ma...@apache.org on 2014/12/12 01:41:05 UTC

incubator-aurora git commit: Make abstract decorators effective in CommandHook class

Repository: incubator-aurora
Updated Branches:
  refs/heads/master 07bc3ab25 -> cbe9c0546


Make abstract decorators effective in CommandHook class

Reviewed at https://reviews.apache.org/r/28879/


Project: http://git-wip-us.apache.org/repos/asf/incubator-aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-aurora/commit/cbe9c054
Tree: http://git-wip-us.apache.org/repos/asf/incubator-aurora/tree/cbe9c054
Diff: http://git-wip-us.apache.org/repos/asf/incubator-aurora/diff/cbe9c054

Branch: refs/heads/master
Commit: cbe9c05463d9dc664b5a4984ce92dcde24c098cc
Parents: 07bc3ab
Author: Zameer Manji <zm...@twopensource.com>
Authored: Thu Dec 11 16:40:44 2014 -0800
Committer: -l <ma...@apache.org>
Committed: Thu Dec 11 16:40:44 2014 -0800

----------------------------------------------------------------------
 src/main/python/apache/aurora/client/cli/command_hooks.py | 10 +++++-----
 src/test/python/apache/aurora/client/cli/AuroraHooks      |  3 +++
 .../client/cli/hook_test_data/exec_error/AuroraHooks      |  3 +++
 3 files changed, 11 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/cbe9c054/src/main/python/apache/aurora/client/cli/command_hooks.py
----------------------------------------------------------------------
diff --git a/src/main/python/apache/aurora/client/cli/command_hooks.py b/src/main/python/apache/aurora/client/cli/command_hooks.py
index 122042c..26ee85e 100644
--- a/src/main/python/apache/aurora/client/cli/command_hooks.py
+++ b/src/main/python/apache/aurora/client/cli/command_hooks.py
@@ -21,11 +21,11 @@ import getpass
 import logging
 import os
 import sys
-from abc import abstractmethod
+from abc import abstractmethod, abstractproperty
 from fnmatch import fnmatch
 
 import requests
-from twitter.common.lang import Compatibility
+from twitter.common.lang import AbstractClass, Compatibility
 
 from apache.aurora.client.cli.options import CommandOption
 
@@ -278,7 +278,7 @@ class GlobalCommandHookRegistry(object):
       return c.code
 
 
-class CommandHook(object):
+class CommandHook(AbstractClass):
   """A hook which contains code that should be run before certain commands."""
   class Error(Exception):
     def __init__(self, code, msg):
@@ -286,9 +286,9 @@ class CommandHook(object):
       self.code = code
       self.msg = msg
 
-  @property
+  @abstractproperty
   def name(self):
-    return None
+    "The name of the hook."
 
   @abstractmethod
   def get_nouns(self):

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/cbe9c054/src/test/python/apache/aurora/client/cli/AuroraHooks
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/AuroraHooks b/src/test/python/apache/aurora/client/cli/AuroraHooks
index e27fcc8..73a7644 100644
--- a/src/test/python/apache/aurora/client/cli/AuroraHooks
+++ b/src/test/python/apache/aurora/client/cli/AuroraHooks
@@ -21,6 +21,9 @@ class DynamicHook(CommandHook):
     self.ran_pre = False
     self.ran_post = False
 
+  def name(self):
+    return "dynamic-hook"
+
   def get_nouns(self):
     return ['job']
 

http://git-wip-us.apache.org/repos/asf/incubator-aurora/blob/cbe9c054/src/test/python/apache/aurora/client/cli/hook_test_data/exec_error/AuroraHooks
----------------------------------------------------------------------
diff --git a/src/test/python/apache/aurora/client/cli/hook_test_data/exec_error/AuroraHooks b/src/test/python/apache/aurora/client/cli/hook_test_data/exec_error/AuroraHooks
index 5dc5907..72f97bd 100644
--- a/src/test/python/apache/aurora/client/cli/hook_test_data/exec_error/AuroraHooks
+++ b/src/test/python/apache/aurora/client/cli/hook_test_data/exec_error/AuroraHooks
@@ -21,6 +21,9 @@ class DynamicHook(CommandHook):
     self.ran_pre = False
     self.ran_post = False
 
+  def name(self):
+    return "dynamic-hook"
+
   def get_nouns(self):
     return ['job']