Skip to content

Commit

Permalink
fix CI error
Browse files Browse the repository at this point in the history
  • Loading branch information
wjo1212 committed Nov 19, 2018
1 parent 2bf2aa7 commit 5199dcf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
9 changes: 4 additions & 5 deletions aliyun/log/etl_core/transform/condition_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import logging
import re
import six
from collections import OrderedDict
import typing
from collections import OrderedDict, Callable
from ..exceptions import SettingError

logger = logging.getLogger(__name__)
Expand All @@ -29,14 +28,14 @@
def get_check(c):
if isinstance(c, bool):
return lambda e: c
elif isinstance(c, typing.Callable):
elif isinstance(c, Callable):
return c
elif isinstance(c, (dict, OrderedDict)):
def check(event):
for k, v in six.iteritems(c):
if k in event:
if (isinstance(v, bool) and v) \
or (isinstance(v, typing.Callable) and v(event[k])) \
or (isinstance(v, Callable) and v(event[k])) \
or (isinstance(v, (six.text_type, six.binary_type))
and re.match(v, event[k])):
continue
Expand Down Expand Up @@ -106,7 +105,7 @@ def call_processor(self, fn, evt, *args, **kwargs):
def __call__(self, entity):
if isinstance(entity, (dict, OrderedDict)):
return any(c(entity) for c in self.check_list)
elif isinstance(entity, typing.Callable):
elif isinstance(entity, Callable):
fn = entity

@functools.wraps(fn)
Expand Down
9 changes: 4 additions & 5 deletions aliyun/log/etl_core/transform/transform_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@
"""

import logging
import typing
from collections import OrderedDict
from collections import OrderedDict, Callable

import six
from ..trans_comp import REGEX
Expand All @@ -105,13 +104,13 @@ def __init__(self, trans):

self.transform_list = []
for tr in self.trans:
if isinstance(tr, typing.Callable):
if isinstance(tr, Callable):
self.transform_list.append(tr)
elif isinstance(tr, (dict, OrderedDict)):
def real_transform(event):
result = {}
for k, v in six.iteritems(tr):
if isinstance(v, typing.Callable):
if isinstance(v, Callable):
v = v(event)

if isinstance(v, (six.text_type, six.binary_type)):
Expand All @@ -133,7 +132,7 @@ def real_transform(event):
inpt, config = tr[0], tr[1]
if isinstance(config, (six.text_type, six.binary_type)):
self.transform_list.append(lambda e: REGEX(*tr[1:])(e, inpt))
elif isinstance(config, typing.Callable):
elif isinstance(config, Callable):
self.transform_list.append(lambda e: config(e, inpt))
else:
logger.warning("unknown transform config setting: {0}".format(config))
Expand Down
7 changes: 5 additions & 2 deletions tests/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,11 @@ def sample_cleanup(client, project, logstore, delete_project=False):
print("ignore error when cleaning up: ", ex)

if delete_project:
time.sleep(30)
client.delete_project(project)
time.sleep(60)
try:
client.delete_project(project)
except Exception as ex:
print("fail to delete project, error: {0}".format(ex))


def sample_crud_consumer_group(client, project, logstore, consumer_group):
Expand Down

0 comments on commit 5199dcf

Please sign in to comment.