class wps_caj_cad(unittest.TestCase): driver = webdriver.Chrome(DRIVER_PATH) logger=Log() @classmethod def setUpClass(cls): Login().user_login(cls.driver) pdf_word = cls.driver.find_element_by_xpath('/html/body/section[2]/ul[1]/li[1]/a') pdf_word.click() def public(self): time.sleep(3) convert_button = self.driver.find_element_by_xpath('//*[@id="uploader"]/div[2]/div[3]/a') convert_button.click() dwnbtn = self.driver.find_element_by_xpath('//*[@id="uploader"]/div[2]/div[3]/a[3]') dwnbtn_is_appeared = WebDriverWait(self.driver,80).until( lambda x: x.find_element_by_xpath('//*[@id="uploader"]/div[2]/div[3]/a[3]').is_displayed()) # 下载按钮 self.assertTrue(dwnbtn_is_appeared) dwnbtn.click() # @Screen(driver) # def test_a_wps_office(self): # wps_office=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[2]/dd[2]') # wps_office.click() # list_name = [] # type=['.doc','.docx','.wps','.et','.dps'] # b = random.sample(type, 4) # # file=listdir(fileDir, list_name,b)#文件名的列表 # # # for i in file: # self.driver.find_element_by_name('file').send_keys(i) # self.public() # log.info('wps转office每一页') # # @Screen(driver) # def test_b_wps_pdf(self): # wps_office=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[2]/dd[3]') # wps_office.click() # list_name = [] # type=['.doc','.docx','.wps','.et','.dps'] # b = random.sample(type, 4) # # file=listdir(fileDir, list_name,b)#文件名的列表 # # # for i in file: # self.driver.find_element_by_name('file').send_keys(i) # self.public() # # log.info('wps转pdf每一页') @Screen(driver) def test_c_caj_word(self): caj_word=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[3]/dd[2]') caj_word.click() list_name = [] file=listdir(fileDir, list_name,['.caj'])#文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('caj转word每一页') @Screen(driver) def test_d_caj_pdf(self): caj_pdf=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[3]/dd[3]') caj_pdf.click() list_name = [] file=listdir(fileDir, list_name,['.caj'])#文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('caj转pdf每一页') @Screen(driver) def test_e_cad_pdf(self): cad_pdf=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[4]/dd[2]') cad_pdf.click() list_name = [] file=listdir(fileDir, list_name,['.dwg','.dwt','.dxf'])#文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('cad转pdf每一页') @Screen(driver) def test_f_cad_jpg(self): cad_jpg=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[4]/dd[3]') cad_jpg.click() list_name = [] file=listdir(fileDir, list_name,['.dwg','.dwt','.dxf'])#文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('cad转jpg每一页') @Screen(driver) def test_g_pdf_cad(self): pdf_cad=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[4]/dd[4]') pdf_cad.click() list_name = [] file=listdir(fileDir, list_name,['.pdf'])#文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('pdf转cad每一页') @Screen(driver) def test_h_cad_cad(self): cad_cad = self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[4]/dd[5]') cad_cad.click() list_name = [] file = listdir(fileDir, list_name, ['.dwg','.dxf']) # 文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('cad转cad每一页') @classmethod def tearDownClass(cls): cls.driver.quit()
def start_bottle(self_port): _log = Log() ################################################################################################ # Enable cross domain scripting ################################################################################################ def enable_cors(response): response.headers['Access-Control-Allow-Origin'] = '*' response.headers['Access-Control-Allow-Methods'] = 'GET' return response ################################################################################################ # Get all service information ################################################################################################ @get(uri_configServices) def get_services(): try: # d = get_cfg_services() # if not bool(d): status = httpStatusFailure else: status = httpStatusSuccess # _log.new_entry(logCategoryClient, request['REMOTE_ADDR'], request.url, 'GET', status, level=logLevelInfo) # if isinstance(d, bool): return HTTPResponse(status=status) else: return HTTPResponse(body=str(d), status=status) # except Exception as e: status = httpStatusServererror _log.new_entry(logCategoryClient, request['REMOTE_ADDR'], request.url, 'GET', status, level=logLevelError) raise HTTPError(status) ################################################################################################ # Get single service information (from id) ################################################################################################ @get(uri_configService) def get_service(id): try: # d = get_cfg_service(id) # if not bool(d): status = httpStatusFailure else: status = httpStatusSuccess # _log.new_entry(logCategoryClient, request['REMOTE_ADDR'], request.url, 'GET', status, level=logLevelInfo) # if isinstance(d, bool): return HTTPResponse(status=status) else: return HTTPResponse(body=str(d), status=status) # except Exception as e: status = httpStatusServererror _log.new_entry(logCategoryClient, request['REMOTE_ADDR'], request.url, 'GET', status, level=logLevelError) raise HTTPError(status) ################################################################################################ # Update config for service (from id) ################################################################################################ @post(uri_configService) def post_service_details(service_id): try: # data_dict = request.json # if validate_service_details(data_dict): # r = set_cfg_service_microservice(service_id, data_dict['ipaddress'], data_dict['port']) # if r: status = httpStatusFailure else: status = httpStatusSuccess else: status = httpStatusBadrequest # _log.new_entry(logCategoryClient, request['REMOTE_ADDR'], request.url, 'POST', status, level=logLevelInfo) # return HTTPResponse(status=status) # except Exception as e: status = httpStatusServererror _log.new_entry(logCategoryClient, request['REMOTE_ADDR'], request.url, 'POST', status, level=logLevelError) raise HTTPError(status) ################################################################################################ host='0.0.0.0' _log.new_entry(logCategoryProcess, '-', 'Port listener', '{host}:{port}'.format(host=host, port=self_port), 'started') run(host=host, port=self_port, debug=True)
from time import sleep from login import Login import time import unittest from selenium.webdriver.support.wait import WebDriverWait from config.browser import DRIVER_PATH from log.log import Log from two_time_package import Yoyo from config.screen import Screen import os fileDir=r'C:\Users\Administrator\PycharmProjects\xunjie\file' abspath = os.path.abspath(fileDir) allfile = os.listdir(fileDir)# 文件名 import random log=Log() def listdir(path, list_name, filetype): for file in os.listdir(path): file_path = os.path.join(path, file) if os.path.isdir(file_path): # 子目录 listdir(file_path, list_name,filetype) elif os.path.splitext(file_path)[1] in filetype: list_name.append(file_path) if len(list_name)>4: list_name = random.sample(list_name, 4) return list_name class wps_caj_cad(unittest.TestCase):
def __init__(self, width, height, modelWay=None, seed=int(time()), nothing=1, voting_method=False): super().__init__(seed) #Init configurations and defines configuration.settings.init() configuration.defineOccupancy.init() configuration.defineMap.init() #Way of working if modelWay is None: self.modelWay = configuration.settings.model else: self.modelWay = modelWay #Mesa self.schedule = BaseScheduler(self) self.grid = MultiGrid(width, height, False) self.running = True #Control of time and energy self.energy = Energy() self.clock = Time() self.voting_method = voting_method self.sc = SocialChoice() #Log self.log = Log() if self.voting_method: self.log = Logsc() self.roomsSchedule = [] self.agentSatisfationByStep = [] self.fangerSatisfationByStep = [] self.agentsActivityByTime = [] self.averageSatisfationByTime = [] self.totalSatisfationByTime = [] self.occupantsValues = False if self.modelWay != 0 and os.path.isfile('../log/tmp/occupants.txt'): self.occupantsValues = self.log.getOccupantsValues() #Vars of control self.complete = False self.num_occupants = 0 self.day = self.clock.day self.NStep = 0 self.timeToSampling = 'init' # Temperature ThermalLoads self.placeByStateByTypeAgent = {} self.lightsOn = [] #Create the map self.createRooms() self.createThermalzones() self.setMap(width, height) self.createDoors() self.createWindows() self.createWalls() #Create agents self.setAgents()
-Отправляет принимает сообщения ''' import sys from socket import socket, AF_INET, SOCK_STREAM import select import logging import log.log_config as log_config from log.log import Log from jim.config import * from jim.protocol import JimMessage, JimResponse logger = logging.getLogger('server') log = Log(logger) class Server: def __init__(self, addr, port): self.addr = addr self.port = port self.socket = self.launch() self.clients = [] def launch(self): sock = socket(AF_INET, SOCK_STREAM) sock.bind((self.addr, self.port)) sock.listen(30) sock.settimeout(0.2) return sock
import sys from multiprocessing import Process from discovery.broadcast import broadcast_service from portlistener import start_bottle from resources.global_resources.variables import * from log.log import Log _log = Log() try: ################################ # Receive sys arguments # Argument 1: Port application listens on try: self_port = sys.argv[1] except: raise Exception('self_port not available') # Argument 2: Port of self exposed on host try: host_port = sys.argv[2] except: raise Exception('host_port not available') _log.new_entry(logCategoryProcess, '-', 'Starting micro service', '-', 'starting') ################################ # Receive sys arguments
class pdf_convert(unittest.TestCase): driver = webdriver.Chrome(DRIVER_PATH) logger=Log() @classmethod def setUpClass(cls): Login().user_login(cls.driver) pdf_hebin=cls.driver.find_element_by_xpath('/html/body/section[2]/ul[5]/li[1]/a') pdf_hebin.click() def public(self): time.sleep(3) convert_button = self.driver.find_element_by_xpath('//*[@id="uploader"]/div[2]/div[3]/a') convert_button.click() time.sleep(30) dwnbtn = self.driver.find_element_by_xpath('//*[@id="uploader"]/div[2]/div[3]/a[3]') dwnbtn_is_appeared = WebDriverWait(self.driver,60).until( lambda x: x.find_element_by_xpath('//*[@id="uploader"]/div[2]/div[3]/a[3]').is_displayed()) # 下载按钮 self.assertTrue(dwnbtn_is_appeared) dwnbtn.click() @Screen(driver) def test_a_pdf_hebin(self): list_name = [] file=listdir(fileDir, list_name,['.pdf'])#文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('pdf合并') @Screen(driver) def test_b_pdf_fenge(self): pdf_fenge=self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[1]/dd[3]/a/span') pdf_fenge.click() list_name = [] file = listdir(fileDir, list_name, ['.pdf']) # 文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('pdf分割') @Screen(driver) def test_c_pdf_psw_add(self): pdf_psw_add = self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[1]/dd[5]/a/span') pdf_psw_add.click() input_text=self.driver.find_element_by_id('inputpdfpwd') input_text.send_keys('123') list_name = [] file = listdir(fileDir, list_name, ['.pdf']) # 文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('pdf增加密码') @Screen(driver) def test_d_pdf_getpic(self): pdf_getpic = self.driver.find_element_by_xpath('/html/body/main/section/aside/div/dl[1]/dd[7]/a/span') pdf_getpic.click() list_name = [] file = listdir(fileDir, list_name, ['.pdf']) # 文件名的列表 for i in file: self.driver.find_element_by_name('file').send_keys(i) self.public() log.info('pdf图片获取') @classmethod def tearDownClass(cls): cls.driver.quit()
def find(self, ControlTypeName="Control", **kwargs): if ControlTypeName == "Control": control = auto.Control(**kwargs) if ControlTypeName == "ButtonControl": control = auto.ButtonControl(**kwargs) if ControlTypeName == "CalendarControl": control = auto.CalendarControl(**kwargs) if ControlTypeName == "CheckBoxControl": control = auto.CheckBoxControl(**kwargs) if ControlTypeName == "ComboBoxControl": control = auto.ComboBoxControl(**kwargs) if ControlTypeName == "CustomControl": control = auto.CustomControl(**kwargs) if ControlTypeName == "DataGridControl": control = auto.DataGridControl(**kwargs) if ControlTypeName == "DataItemControl": control = auto.DataItemControl(**kwargs) if ControlTypeName == "DocumentControl": control = auto.DocumentControl(**kwargs) if ControlTypeName == "EditControl": control = auto.EditControl(**kwargs) if ControlTypeName == "GroupControl": control = auto.GroupControl(**kwargs) if ControlTypeName == "HeaderControl": control = auto.HeaderControl(**kwargs) if ControlTypeName == "HeaderItemControl": control = auto.HeaderItemControl(**kwargs) if ControlTypeName == "HyperlinkControl": control = auto.HyperlinkControl(**kwargs) if ControlTypeName == "ImageControl": control = auto.ImageControl(**kwargs) if ControlTypeName == "ListControl": control = auto.ListControl(**kwargs) if ControlTypeName == "ListItemControl": control = auto.ListItemControl(**kwargs) if ControlTypeName == "MenuControl": control = auto.MenuControl(**kwargs) if ControlTypeName == "MenuBarControl": control = auto.MenuBarControl(**kwargs) if ControlTypeName == "MenuItemControl": control = auto.MenuItemControl(**kwargs) if ControlTypeName == "PaneControl": control = auto.PaneControl(**kwargs) if ControlTypeName == "ProgressBarControl": control = auto.ProgressBarControl(**kwargs) if ControlTypeName == "RadioButtonControl": control = auto.RadioButtonControl(**kwargs) if ControlTypeName == "ScrollBarControl": control = auto.ScrollBarControl(**kwargs) if ControlTypeName == "SemanticZoomControl": control = auto.SemanticZoomControl(**kwargs) if ControlTypeName == "SeparatorControl": control = auto.SeparatorControl(**kwargs) if ControlTypeName == "SliderControl": control = auto.SliderControl(**kwargs) if ControlTypeName == "SpinnerControl": control = auto.SpinnerControl(**kwargs) if ControlTypeName == "SplitButtonControl": control = auto.SplitButtonControl(**kwargs) if ControlTypeName == "StatusBarControl": control = auto.StatusBarControl(**kwargs) if ControlTypeName == "TabControl": control = auto.TabControl(**kwargs) if ControlTypeName == "TabItemControl": control = auto.TabItemControl(**kwargs) if ControlTypeName == "TextControl": control = auto.TextControl(**kwargs) if ControlTypeName == "ThumbControl": control = auto.ThumbControl(**kwargs) if ControlTypeName == "TitleBarControl": control = auto.TitleBarControl(**kwargs) if ControlTypeName == "ToolBarControl": control = auto.ToolBarControl(**kwargs) if ControlTypeName == "ToolTipControl": control = auto.ToolTipControl(**kwargs) if ControlTypeName == "TreeControl": control = auto.TreeControl(**kwargs) if ControlTypeName == "TreeItemControl": control = auto.TreeItemControl(**kwargs) if ControlTypeName == "WindowControl": control = auto.WindowControl(**kwargs) if control.Exists(): return control else: name = kwargs.__str__().replace(":", ":") Log.logger().error("元素查找失败%s" % name) autogui.screenshot("../log/%s.png" % name)