python
so�so
这个作者很懒,什么都没留下…
展开
-
服务器拨测报警
拨测程序:'''import sysimport oscurPath = os.path.abspath(os.path.dirname(__file__))print(curPath)rootPath = os.path.split(curPath)[0]print(rootPath)sys.path.append(rootPath)'''#index_page,myInfo_page,,relative_page#from src.common import gesture_m原创 2020-07-22 10:20:08 · 343 阅读 · 0 评论 -
网页响应速度
结合单元测试框架unittest,直接贴代码:# -*- coding: utf-8 -*-import unittestfrom selenium import webdriver#from object.DRIVER import getDriverimport time,queueimport login_page,BasePageclass UntitledTestCase(unittest.TestCase): def setUp(self): #Opt.原创 2020-07-22 10:14:02 · 257 阅读 · 0 评论 -
pyaudio实现边录边播功能
play:import pyaudioimport waveimport timefrom tqdm import tqdmdef play_audio(wave_path): ''' while True: print('play') time.sleep(1) ''' time.sleep(0.1) CHUNK = 1024 f = wa...原创 2020-03-31 15:05:39 · 1214 阅读 · 0 评论 -
压力测试中监听多个进程的CPU,MEM(多线程)
#!/usr/bin/pythonimport time, threadingimport randomimport structimport geventimport signalimport osfrom gevent import socketimport psutilimport systhread_num = 2 #open thread numis_exit...原创 2019-09-04 14:31:57 · 459 阅读 · 0 评论 -
Python中用Ctrl+C终止多线程程序的问题解决
用python为服务写了个压力测试。很简单,多线程向服务器发请求。但写完之后发现如果中途想停下来,按Ctrl+C达不到效果,自然想到要用信号处理函数捕捉信号,使线程都停下来,问题解决的方法请往下看:复制代码代码如下:#!/bin/env python# -*- coding: utf-8 -*-#filename: peartest.pyimport threading, ...原创 2019-09-05 09:07:35 · 1494 阅读 · 1 评论 -
压力测试中监听单个进程CPU,MEM
#coding=utf-8import psutilimport sysimport timeimport osdef listen(PID): f = open('listen_server.txt','w') i = 1 while i == 1 : p1 = psutil.Process(PID) cpu1 = p1.cpu...原创 2019-09-04 14:46:56 · 184 阅读 · 0 评论 -
获取元素文字
要获取到目标元素的text的值,需要定义一个目标元素element,然后通过element.text方法得到字符串error_mes = driver.find_element_by_xpath("//*[@id='TANGRAM__PSP_10__error']").texttime.sleep(5)print (error_mes)try: assert error_me...原创 2019-09-24 10:32:56 · 374 阅读 · 0 评论