Skip to content

Commit

Permalink
钉钉报警优化
Browse files Browse the repository at this point in the history
  • Loading branch information
mengdg committed May 4, 2018
1 parent 551cef7 commit c188774
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 71 deletions.
58 changes: 0 additions & 58 deletions lib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,58 +0,0 @@
# encoding: utf-8
"""
__auth__: 孟德功
__require__: 所有事件二次封装
__version__: 无要求
"""


class Event:
def __init__(self, media=None):
self.media = media

def click(self, type, button_name):
self.media(type, button_name).click()

def set_text_name(self, local, text):
self.media(name=local).set_text(text)

def set_text_xpath(self, local, text):
self.media(xpath=local).set_text(text)

def wait(self, timeout=20.0):
import time
time.sleep(timeout)

def close(self):
self.media.close()

def deactivate(self, timeout=5.0):
self.media.deactivate(timeout)

def tap(self, x, y):
self.media.tap(x=x, y=y)

def double_tap(self, x, y):
self.media.double_tap(x, y)

def swipe(self, x1, y1, x2, y2, time=0.5):
self.media.swipe(x1, y1, x2, y2, time)

def swipe_left(self):
self.media.swipe_left()

def swipe_right(self):
self.media.swipe_right()

def swipe_up(self):
self.media.swipe_up()

def swipe_down(self):
self.media.swipe_down()

def tap_hold(self, x, y, time=1.0):
self.media.tap_hold(x=x, y=y, time=time)

# def

# self.media.wait(timeout)
Binary file modified lib/__init__.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/dingding.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def __init__(self, content=None):

self.data_text = dict()
self.data_text['msgtype'] = 'text'
self.data_text['text'] = {'content': self.content}
self.data_text['at'] = {'isAtall': True}
self.data_text['text'] = {'content': str(self.content).replace('"','').replace(',','')}
self.data_text['at'] = {'isAtall': False}

def main(self):
text_json = json.dumps(self.data_text)
Expand Down
Binary file modified lib/dingding.pyc
Binary file not shown.
17 changes: 9 additions & 8 deletions lib/running.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ def screening(self, case):
return False
except Exception:
self.flag_err = 1
raise ValueError('请检查 module:%s case:%s is_run:%s is_warning:%s'
print ('请检查 module:%s case:%s is_run:%s is_warning:%s'
% (self.module, self.case, self.is_run, self.is_warning))
pass

def case_event(self, case):
try:
Expand Down Expand Up @@ -478,15 +479,15 @@ def get_path(self):

def data(self, type, operate):
data = dict()
data['type'] = type
data['module'] = self.module
data['case'] = self.case
data['operate'] = operate
data['告警类型'] = type
data['监控模块'] = self.module
data['监控case'] = self.case
data['告警事件'] = operate
if self.flag_assert == 1 and self.flag_warn == 0:
data['err_info'] = str(self.assert_info)
data['告警信息'] = str(self.assert_info)
elif self.flag_assert == 0 and self.flag_warn == 1:
data['err_info'] = str(self.err_info)
data['alarm_time'] = time.strftime('%Y.%m.%d %H:%M:%S ')
data['告警信息'] = str(self.err_info)
data['告警时间'] = time.strftime('%Y.%m.%d %H:%M:%S ')
import json
return json.dumps(data, indent=1, sort_keys=False, ensure_ascii=False)

Expand Down
Binary file modified lib/running.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions lib/setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
"""
FILES = ['group', 'login'] # 选择所要执行/AT-wda/case中的文件名

BUNDLE_ID = 'com.blued.international' # App bundle id
BUNDLE_ID = 'com.*************' # App bundle id

PRINT = True # 打印case运行日志

DEVICE = 1 # 选择第一台(目前仅支持单台设备,若插入多个设备,可以自行选择其中一台执行)

ALERT = [u'不再提醒', 'OK', u'知道了', 'Allow', u'允许', u'稍后', u'好'] # 处理不知何时就会突然弹出的警告框,可以根据业务拓展

WDA_PATH = '/Users/degongmeng/Documents/Macaca/WebDriverAgent/WebDriverAgent.xcodeproj' # WebDriverAgent.xcodeproj 的绝对路径
WDA_PATH = '/Users/*******/Documents/Macaca/WebDriverAgent/WebDriverAgent.xcodeproj' # WebDriverAgent.xcodeproj 的绝对路径

DD_TOKEN = '*********************************************' # 钉钉的token(在钉钉pc版中可以获取机器人的token)
DD_TOKEN = '********************************************' # 钉钉的token(在钉钉pc版中可以获取机器人的token)

ELEM_TIMEOUT = 20 # 获取元素最大等待时长
Binary file modified lib/setting.pyc
Binary file not shown.

0 comments on commit c188774

Please sign in to comment.