def deviceTask(self, deviceid, port, zport): self.taskid = dbapi.GetDeviceTask(deviceid) from uiautomator import Device from zservice import ZDevice if self.taskid: self.task = dbapi.GetTask(self.taskid) if (self.task and self.task.get("status") and self.task["status"] == "running"): self.z = ZDevice(deviceid, zport) self.d = Device(deviceid, port) try: self.d.dump(compressed=False) except Exception: logger.error(traceback.format_exc()) while True: steps = dbapi.GetTaskSteps(self.taskid) # 设置zime输入法 self.d.server.adb.cmd( "shell", "ime set com.zunyun.zime/.ZImeService").communicate() self.d.server.adb.cmd( "shell", "am broadcast -a com.zunyun.zime.unlock").communicate( ) for step in steps: try: self.z.heartbeat() signal.signal(signal.SIGALRM, self.handler) signal.alarm(60) self.runStep(self.d, step) signal.alarm(0) except AssertionError: print "ERROR::::%s Moudle execute timeout for 120 seconds" % step[ "name"] except Exception: logger.error(step) logger.error(traceback.format_exc()) time.sleep(3) # 检查设备对应的任务状态 new_taskid = dbapi.GetDeviceTask(deviceid) if new_taskid is None or new_taskid == "": # 任务中删除了该设备 os._exit(0) if (new_taskid != self.taskid): # 设备对应的taskid发生了变化 os._exit(0) task = dbapi.GetTask(new_taskid) if task.get("status") != "running": # 任务状态已停止 os._exit(0) else: os._exit(0) else: os._exit(0)
def CommandListen(): import redis pool = redis.ConnectionPool(host=const.REDIS_SERVER, port=6379, db=0) r = redis.StrictRedis(connection_pool=pool) p = r.pubsub() p.subscribe('TASK_COMMAND') for item in p.listen(): try: print item if item['type'] == 'message': data = item['data'] data = json.loads(data) if data["COMMAND"] == "START_TASK": #//DO NOTHINGr.set('s', 32) a = 1 elif data["COMMAND"] == "STOP_TASK": taskId = data["TASK_ID"] devices = dbapi.GetDevicesByTask(taskId) for device in devices: serial = device["serial"] if processDict.has_key(serial): logger.war("%s收到任务停止指令,移除进程" % serial) processDict[serial].terminate() stopProcess(serial) del processDict[serial] elif data["COMMAND"] == "ADB": serial = data["serial"] cmd = data["cmd"] z = ZDevice(serial, 0) xx = z.server.adb.cmd("shell", cmd).communicate() print xx finally: h = 1
def installApk(deviceid): device_port = portDict[deviceid] zport = device_port["zport"] z = ZDevice(deviceid, zport) z.server.adb.cmd("shell", "su -c 'rm -f /sdcard/NanoHTTPD-*'").communicate() z.server.adb.cmd("shell", "su -c 'rm -f /sdcard/share_*'").communicate() # 规避解决微信卡死问题 pkginfo = z.server.adb.package_info("com.tencent.mm") if pkginfo is not None: z.server.adb.cmd( "shell", "su -c 'rm -rf /data/data/com.tencent.mm/tinker/*'").communicate() z.server.adb.cmd("shell", "su -c 'mkdir -p /data/data/com.tencent.mm/tinker/'" ).communicate() z.server.adb.cmd( "shell", "su -c 'chmod 000 /data/data/com.tencent.mm/tinker/'").communicate( ) z.server.install()
now = datetime.datetime.now() nowtime = now.strftime( '%Y-%m-%d %H:%M:%S') # 将日期转化为字符串 datetime => string z.setModuleLastRun(self.mid) z.toast('模块结束,保存的时间是%s' % nowtime) def getPluginClass(): return WXAutoReplyMsg if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT4A1SK02114") z = ZDevice("HT4A1SK02114") z.server.install() d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_material_id": "207", "msg_count": "1", "reply_count": "3", "run_time": "1" } #cate_id是仓库号,length是数量 o.action(d, z, args)
def getPluginClass(): return QQAdressAddfriends2 if __name__ == "__main__": # global args import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("cc0e9474") z = ZDevice("cc0e9474") args = { "repo_cate_id": "106", 'number_count': '20', "random_name": "否", "clear": "是", "time_delay": "3", "repo_material_id": "355", "EndIndex": "2" } #cate_id是仓库号,length是数量 o.action(d, z, args)
z.sleep(3) d(descriptionContains='清除').click() continue elif d(text='发消息').exists: d(descriptionContains='返回').click() z.sleep(3) d(descriptionContains='清除').click() continue def getPluginClass(): return WXAssignSearchAddFriends if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT54VSK01061") z = ZDevice("HT54VSK01061") z.server.install() d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_number_id": "131", "get_number": "10" } #cate_id是仓库号,length是数量 o.action(d, z, args)
if d(textContains='显示更多').exists: d(textContains='显示更多').click() d.swipe(width / 2, height * 4 / 5, width / 2, height / 5) z.sleep(2) i = 1 continue if (args["time_delay"]): z.sleep( int( args["time_delay"] ) ) def getPluginClass(): return MobilqqConcernII if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT4A6SK01638") z = ZDevice("HT4A6SK01638") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = {"add_count":"1000","time_delay":"3"} #cate_id是仓库号,length是数量 o.action(d,z, args)
continue now = datetime.datetime.now( ) nowtime = now.strftime( '%Y-%m-%d %H:%M:%S' ) # 将日期转化为字符串 datetime => string z.setModuleLastRun( self.mid ) z.toast( '模块结束,保存的时间是%s' % nowtime ) return def getPluginClass(): return MMCQQCardParise2 if __name__ == "__main__": # global args import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("d99e4b99") z = ZDevice("d99e4b99") args = {"time_delay":"3","set_timeStart":"0","set_timeEnd":"0","startTime":"0","endTime":"8", "repo_number_cate_id":"244","count":"5","click_count":"2","switch":"跳过"} #cate_id是仓库号,length是数量 o.action( d, z, args )
d.click(width / 2, height * 456.5 / 888) time.sleep(4) if d(text='绑定手机', className='android.widget.TextView').exists: break def getPluginClass(): return AQYLogin if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("HT52ESK00321") z = ZDevice("HT52ESK00321") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() # d.server.adb.cmd("shell", "am start -a android.intent.action.MAIN -n com.android.settings/.Settings").communicate() #打开android设置页面 args = { "material_id": "40", "number_id": "137", "time_delay": "1" } o.action(d, z, args) # o.scrollCell(d,args)
n = n + 1 z.toast("模块完成") if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return TIMGroupChatCheckGroupFriends if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("0d12dd17") z = ZDevice("0d12dd17") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = {"repo_info_id":"253","repo_group_id":"256","totalNumber":"5","time_delay":"3",} #cate_id是仓库号,length是数量 # o.action(d, z,args) # if len( totalList ) == 0: # z.toast( "%s仓库%s账号可数据为空" % (repo_group_id, myAccount) ) # address = totalList[0]["x02"][1:] # address = address.encode( 'utf-8' ) # print( address ) # # d.server.adb.cmd( "shell", "am start -a android.intent.action.VIEW -d 'http://url.cn/58E2Yuz#flyticket'" ) # z.sleep(1) # print("am start -a android.intent.action.VIEW -d '%s'" %address) # d.server.adb.cmd( "shell", "am start -a android.intent.action.VIEW -d 'http://url.cn/5Br4GP2#flyticket'" ) # z.sleep( 1 ) # para = {"phoneNumber": "www.baidu.com", 'x_01': "444455552", 'x_02': "MX", 'x_03': "0",
print password data = {"QQNumber": qqNumber, "QQPassword": password, 'PhoneNumber': None, 'cate_id': cate_id, 'status': 'normal', 'IMEI': None, "cardslot": None} path = "/repo_api/register/numberInfo" headers = {"Content-Type": "application/x-www-form-urlencoded", "Connection": "Keep-Alive"} url = self.domain + path response = requests.post( url, data, headers=headers ) def getPluginClass(): return QQEmailSendTextAllUnifiedAccountCate if __name__ == "__main__": clazz = getPluginClass() o = clazz() d = Device("37f7b82f") z = ZDevice("37f7b82f") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = {"repo_mail_cateId": "411", "repo_material_cateId": "412", "time_delay": "5","sendCount":"6","size":"实际大小","repo_material_cateId2":"409","selectContent":"主题内容都发", "failCount":"7","nuberLoop":"循环","addToText":"添加",'train_cate_id':"411",'random_code':"不乱码", 'domain':"http://192.168.1.102:8888","repo_account_A": "413","repo_account_B": "414"} # obj = d(description='待发送').child(resourceId="com.tencent.androidqqmail:id/t4") # if obj.exists: # print obj.info['text'] # if d( text='加载更多' ).exists: # d( text='加载更多' ).click( ) # time.sleep( 3 ) o.action(d, z, args)
if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return AlipayLogin if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT4AVSK01106") z = ZDevice("HT4AVSK01106") z.server.install(); d.server.adb.cmd("shell", "ime set com.zunyun.zime/.ZImeService").wait() while not d(resourceId='com.ali.user.mobile.security.ui:id/loginButton').exists: z.toast("等待登录按钮出现") z.sleep(2) d(resourceId='com.ali.user.mobile.security.ui:id/loginButton').click() d(resourceId="com.ali.user.mobile.security.ui:id/content").set_text("13858528") d(resourceId="com.ali.user.mobile.security.ui:id/userPasswordInput").set_text("112233") d.server.adb.cmd("shell", "pm clear com.eg.android.AlipayGphone").communicate() # 清除缓存 # d.server.adb.cmd("shell", "am force-stop com.eg.android.AlipayGphone").wait() # 强制停止 d.server.adb.cmd("shell",
def getPluginClass(): return MMCYixinAddFriendsByAddressOld if __name__ == "__main__": # global args import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("INNZL7YDLFPBNFN7") z = ZDevice("INNZL7YDLFPBNFN7") args = { "repo_cate_id": "104", 'number_count': '30', "random_name": "否", "clear": "是", "time_delay": "3", "repo_material_cate_id": "255", "add_count": "30" } #cate_id是仓库号,length是数量 o.action(d, z, args)
d(text='发送').click() if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return MobilqqRouseAdd if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT4BLSK00255") z = ZDevice("HT4BLSK00255") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_number_cate_id": "119", "repo_material_cate_id": "39", "totalNumber": "4", "time_delay": "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
text='添加失败,请勿频繁操作').exists: # 操作过于频繁的情况 return if (args["time_delay"]): time.sleep(int(args["time_delay"])) def getPluginClass(): return TIMAddFriends06 if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("HT529SK00384") # material=u'有空聊聊吗' z = ZDevice("HT529SK00384") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").wait() args = { "repo_number_cate_id": "43", "repo_material_cate_id": "36", "add_count": "9", "time_delay": "3" } # cate_id是仓库号,length是数量 o.action(d, z, args)
else: d.swipe(width / 2, height * 4 / 5, width / 2, height / 5) d(text='删除').click() d(text='删除').click() else: break if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return WXDelAllFriends if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("8HVSMZKBEQFIBQUW") z = ZDevice("8HVSMZKBEQFIBQUW") z.server.install() d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = {'time_delay': "3"} #cate_id是仓库号,length是数量 o.action(d, z, args)
while 1: time.sleep(1) if d(index=3, className='android.widget.LinearLayout').child( index=0, className='android.widget.RelativeLayout').child( text='已启用', className='android.widget.TextView').exists: break if (args["time_delay"]): time.sleep(int(args["time_delay"])) def getPluginClass(): return TIMAddressMatchSwitch if __name__ == "__main__": clazz = getPluginClass() o = clazz() d = Device("HT52DSK00474") z = ZDevice("HT52DSK00474") # print(d.dump(compressed=False)) d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_numberCateId_id": "108", "time_delay": "3" } # cate_id是仓库号,length是数量 o.action(d, z, args)
d(text='确定').click() if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return WeiXinNearByNotify if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("5959d2f3") z = ZDevice("5959d2f3") z.server.install() z.wx_action('opennearui') d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_material_id": "39", 'EndIndex': '64', 'gender': "女", "time_delay": "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
break if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): import sys reload(sys) sys.setdefaultencoding('utf8') return MobilqqPraise if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("9ddbd665") z = ZDevice("9ddbd665") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_number_cate_id": "119", "add_count": "16", "time_delay": "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
) > 180: #进程心跳时间超过3分种,重启进程 pid = processDict[deviceid].pid logger.war("%s进程无心跳,准备结束重新拉起" % pid) processDict[deviceid].terminate() os.subprocess.call( ["kill -9 %s" % pid], shell=True) startProcess(deviceid) else: if processDict.has_key( deviceid ): # and processDict.get(deviceid).is_alive(): logger.war("%s任务已经停止,移除进程" % deviceid) processDict[deviceid].terminate() del processDict[deviceid] from zservice import ZDevice z = ZDevice(deviceid, 1000) z.cmd( "shell", "am broadcast -a com.zunyun.zime.action --es ac \"Task\" --es sac \"stop\"" ) #检查运行中的进程是否有手机被拔出电脑 ''' for device in processDict: if device not in devicelist: # dbapi.log_warn(device , "设备被拔出,运行中任务被强制停止") if processDict.has_key(deviceid): logger.war("%s设备被拔出,移除进程" % deviceid) processDict[device].terminate() del processDict[deviceid] ''' except Exception:
time.sleep(int(args["time_delay"])) def getPluginClass(): return TIMAddfriendsByNumber if __name__ == "__main__": # global args import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("HT536SK03609") z = ZDevice("HT536SK03609") args = { "time_delay": "3", "repo_number_cate_id": "119", "repo_material_cate_id": "52", 'gender': "男", "add_count": "1", "switch_card": "N" } #cate_id是仓库号,length是数量 o.action(d, z, args)
z.sleep(3) i = 1 if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return NewMobilqqPraiseII if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT49RSK01046") z = ZDevice("HT49RSK01046") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "concernnum": "20", 'gender': "男", "time_delay": "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
nowtime = now.strftime( '%Y-%m-%d %H:%M:%S') # 将日期转化为字符串 datetime => string z.setModuleLastRun(self.mid) z.toast('模块结束,保存的时间是%s' % nowtime) def getPluginClass(): return WXHelloNearPeople if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT4AVSK00885") z = ZDevice("HT4AVSK00885") z.server.install() d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_material_id": "40", "repo_number_id": "205", "hello_count": "3", 'gender': '女', 'run_time': "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
z.sleep(6) d(description='结束QQ电话').click() z.sleep(2) d(text='返回').click() i = i + 1 t = t + 1 z.heartbeat() if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return MobilqqPhone if __name__ == "__main__": clazz = getPluginClass() o = clazz() d = Device("HT4A4SK00901") z = ZDevice("HT4A4SK00901") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { 'gender': "不限", 'EndIndex': '20', "time_delay": "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return MobilqqFilterPraiseGreet if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("HT524SK00685") z = ZDevice("HT524SK00685") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "prisenum": "4", "concernnum": "4", "textnum": "74", "repo_material_id": "40", 'gender': "男", "time_delay": "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
def getPluginClass(): return GoogleKeyWord_1 if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("920121a870e384dd") z = ZDevice("920121a870e384dd") #z.server.install() d.server.adb.cmd("shell", "ime set com.zunyun.zime/.ZImeService").communicate() args = {'start_time': '16', 'stop_time': '16:10', "repo_information_id": "204", "material_KeyWords_id": "207", "KeyWords_interval": "0", "run_count": "3", "slippage_count": "20", "if_slippage": "是", "time_delay": "3"}; o.action(d, z, args) # obj = d( className='android.widget.Button' ) # if obj.exists: # obj = d( className='android.widget.Button' ).info["bounds"] # left = obj["left"] # bottom = obj["bottom"] # top = obj["top"] # d.click(left-88,bottom - (bottom - top)/2) # if obj.exists: # d( className='android.widget.Button' ).left( className="android.widget.EditText" ).click()
'%s_%s_%s' % (d.server.adb.device_serial(), self.type, slotnum)) # 仓库号,使用中,QQ号,设备号_卡槽号 if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return MobilqqLogin2 if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("25424f9") z = ZDevice("25424f9") args = { "repo_cate_id": "331", "time_limit": "120", "time_limit1": "120", "time_delay": "3" } #cate_id是仓库号,length是数量 o.action(d, z, args)
"shell", "settings put global airplane_mode_on 0").communicate() d.server.adb.cmd( "shell", "am broadcast -a android.intent.action.AIRPLANE_MODE --ez state false" ).communicate() if (args["time_delay"]): z.sleep(int(args["time_delay"])) def getPluginClass(): return Ping if __name__ == "__main__": # global args import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("HT4AYSK00041") z = ZDevice("HT4AYSK00041") args = {"time_delay": "3"} #cate_id是仓库号,length是数量 o.action(d, z, args)
# self.slot.backup(QQnumber, QQnumber) # 设备信息,卡槽号,QQ号 def getPluginClass(): return QQSafetyCenter if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding("utf-8") clazz = getPluginClass() o = clazz() d = Device("465b4e4b") z = ZDevice("465b4e4b") d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() # d.server.adb.cmd("shell", "am start -a android.intent.action.MAIN -n com.android.settings/.Settings").communicate() #打开android设置页面 args = { "repo_cate_id": "335", "time_limit": "120", "sms_url": "http://192.168.1.107:5555/send?callee=phoneNumber&sms=smsContent" } o.action(d, z, args) # repo = Repo() # cate_id = args["repo_cate_id"] # time_limit = args['time_limit']
'%Y-%m-%d %H:%M:%S') # 将日期转化为字符串 datetime => string z.setModuleLastRun(self.mid) z.toast('模块结束,保存的时间是%s' % nowtime) def getPluginClass(): return WXSearchAddFriendsByV1 if __name__ == "__main__": import sys reload(sys) sys.setdefaultencoding('utf8') clazz = getPluginClass() o = clazz() d = Device("545048da") z = ZDevice("545048da") z.server.install() d.server.adb.cmd("shell", "ime set com.zunyun.qk/.ZImeService").communicate() args = { "repo_number_id": "202", "repo_information_id": "204", "repo_material_id": "39", "add_count": "3", 'run_time': '0', "add_friend_way": "随机", "time_delay": "5" } #cate_id是仓库号,length是数量 o.action(d, z, args)