How to use check_time method in autotest

Best Python code snippet using autotest_python

test.py

Source:test.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2"""3Created on Mon Mar 7 14:16:19 20224Modified Structure and Queries on Sun Apr 3 20225@author: BHuang6"""7import pandas as pd8import numpy as np9import csv10from datetime import datetime, timedelta11from database_pipeline import DatabaseConnector, Database12from tech_indicator import TechnicalIndicators, get_chg, get_chg_rate13from settings import db_name, table_name, tushare_token14#from collect_indicator import collect_indicator15# 确认数据库名称和表格名称,并生成连接数据库所用的connector16connector_engine = DatabaseConnector(db_name).engine17database = Database(connector_engine, table_name)18tech_ind = TechnicalIndicators(database, tushare_token)19# database.create_index(table_name, 'code')20# 想要计算indicator的股票代码list21#tu_handle = TuData(tushare_token)22#adjdf = tu_handle.get_adj_factor('601789.SH', '20200227', '20200423')23#sharedf = tu_handle.get_float_share('601789.SH', '20200227', '20200423')24#with open('adj.csv', 'w', newline='') as f:25# adjdf.to_csv(f)26#with open('share.csv', 'w', newline='') as f:27# sharedf.to_csv(f)28check_time = datetime.fromisoformat('2020-03-02 13:23:00')29code = '601789.XSHG'30lb = tech_ind.LB(code, check_time)31ma1w = tech_ind.MA(code, check_time, period=5)32ma1m = tech_ind.MA(code, check_time, period=5, unit='m')33k, d, j = tech_ind.KDJ(code, check_time)34ub, mb, _ = tech_ind.BOLL(code, check_time)35dif1d, dea1d, macd1d = tech_ind.MACD(code, check_time)36dif1m, dea1m, macd1m = tech_ind.MACD(code, check_time, unit='1m')37dif5m, dea5m, macd5m = tech_ind.MACD(code, check_time, unit='5m')38hsl1d, mahsl1d = tech_ind.HSL(code, check_time)39hsl1m, mahsl1m = tech_ind.HSL(code, check_time, unit='1m')40mfi1d = tech_ind.MFI(code, check_time)41rsi1d = tech_ind.RSI(code, check_time)42accer5m = tech_ind.ACCER(code, check_time, unit='5m')43accer15m = tech_ind.ACCER(code, check_time, unit='15m')44ar, br = tech_ind.BRAR(code, check_time)45pcnt1d, mapcnt1d = tech_ind.PCNT(code, check_time)46cci1d = tech_ind.CCI(code, check_time)47cci1m = tech_ind.CCI(code, check_time, unit='1m')48cci5m = tech_ind.CCI(code, check_time, unit='5m')49lb_chg = get_chg(tech_ind.LB, code, check_time, timedelta(minutes=1))50ma1w_chg = get_chg_rate(tech_ind.MA, code, check_time, timedelta(days=1))51ma1m_chg = get_chg_rate(tech_ind.MA, code, check_time, timedelta(minutes=1), unit='m')52k_chg, d_chg, j_chg = get_chg(tech_ind.KDJ, code, check_time, timedelta(days=1))53dif1d_chg, dea1d_chg, macd1d_chg = get_chg(tech_ind.MACD, code, check_time, timedelta(days=1))54dif1m_chg, dea1m_chg, macd1m_chg = get_chg(tech_ind.MACD, code, check_time, timedelta(minutes=1), unit='1m')55dif5m_chg, dea5m_chg, macd5m_chg = get_chg(tech_ind.MACD, code, check_time, timedelta(minutes=1), unit='5m')56ub_chg, mb_chg, _ = get_chg_rate(tech_ind.BOLL, code, check_time, timedelta(days=1))57hsl1d_chg, mahsl1d_chg = get_chg(tech_ind.HSL, code, check_time, timedelta(days=1))58hsl1m_chg, mahsl1m_chg = get_chg(tech_ind.HSL, code, check_time, timedelta(minutes=1))59mfi1d_chg = get_chg(tech_ind.MFI, code, check_time, timedelta(days=1))60rsi1d_chg = get_chg(tech_ind.RSI, code, check_time, timedelta(days=1))61accer15m_chg = get_chg(tech_ind.ACCER, code, check_time, timedelta(minutes=1), unit='15m')62accer5m_chg = get_chg(tech_ind.ACCER, code, check_time, timedelta(minutes=1), unit='5m')63ar_chg, br_chg = get_chg(tech_ind.BRAR, code, check_time, timedelta(days=1))64pcnt1d_chg, mapcnt1d_chg = get_chg(tech_ind.PCNT, code, check_time, timedelta(days=1))65cci1d_chg = get_chg(tech_ind.CCI, code, check_time, timedelta(days=1))66cci1m_chg = get_chg(tech_ind.CCI, code, check_time, timedelta(minutes=1), unit='1m')67cci5m_chg = get_chg(tech_ind.CCI, code, check_time, timedelta(minutes=1), unit='5m')68print("LB:", lb)69#print("MA1w/MA1m:", ma1w, ma1m)70print("K/D/J:", k, d, j)71print("DIF1d/DEA1d/MACD1d:", dif1d, dea1d, macd1d)72print("DIF1m/DEA1m/MACD1m:", dif1m, dea1m, macd1m)73print("DIF5m/DEA5m/MACD5m:", dif5m, dea5m, macd5m)74print("UB/MB:", ub, mb)75print("MFI:", mfi1d)76print("RSI:", rsi1d)77print("ACCER5m/15m:", accer5m, accer15m)78print("AR/BR:", ar, br)79print("PCNT/MAPCNT:", pcnt1d, mapcnt1d)80print("CCI1d/1m/5m:", cci1d, cci1m, cci5m)81with open("out.csv", 'w', newline='') as f:82 csv_wt = csv.writer(f)83 header = ['lb','k','d','j','dif1d','dea1d','macd1d','dif1m','dea1m','macd1m',84 'dif5m','dea5m','macd5m','ub','mb','mfi1d','rsi1d',85 'accer5m','accer15m','ar','br','pcnt1d','mapcnt1d','cci1d','cci1m','cci5m',86 'lb_chg', 'k_chg', 'd_chg', 'j_chg', 'dif1d_chg', 'dea1d_chg', 'macd1d_chg', 'dif1m_chg', 'dea1m_chg', 'macd1m_chg',87 'dif5m_chg', 'dea5m_chg', 'macd5m_chg', 'ub_chg', 'mb_chg', 'mfi1d_chg', 'rsi1d_chg',88 'accer5m_chg', 'accer15m_chg', 'ar_chg', 'br_chg', 'pcnt1d_chg', 'mapcnt1d_chg', 'cci1d_chg', 'cci1m_chg', 'cci5m_chg',89 ]90 make_list = [lb, k, d, j, dif1d, dea1d, macd1d, dif1m, dea1m, macd1m,91 dif5m, dea5m, macd5m, ub, mb, mfi1d, rsi1d,92 accer5m, accer15m, ar, br, pcnt1d, mapcnt1d, cci1d, cci1m, cci5m,93 lb_chg, k_chg, d_chg, j_chg, dif1d_chg, dea1d_chg, macd1d_chg, dif1m_chg, dea1m_chg, macd1m_chg,94 dif5m_chg, dea5m_chg, macd5m_chg, ub_chg, mb_chg, mfi1d_chg, rsi1d_chg,95 accer5m_chg, accer15m_chg, ar_chg, br_chg, pcnt1d_chg, mapcnt1d_chg, cci1d_chg, cci1m_chg, cci5m_chg,96 ]97 csv_wt.writerow(header)...

Full Screen

Full Screen

configure.py

Source:configure.py Github

copy

Full Screen

...24 """获取数据帧等待超时时间"""25 return "wait_timeout"262728def get_unexecuted_opr_check_time():29 """30 获取未执行的操作的检查时间31 例如:每5秒检查是否有操作还未执行32 :return:33 """34 key = 'unexecuted_opr_check_time'35 check_time = cache.get_hash('configure', key)36 # 如果不存在缓存中,则从数据库中读取37 if check_time is None:38 check_time = Configure.objects.get(name=key).val39 check_time = int(check_time)40 cache.set_hash('configure', key, check_time)4142 return int(check_time)434445def set_unexecuted_opr_check_time(check_time):46 """47 获取未执行的操作的检查时间48 例如:每5秒检查是否有操作还未执行49 :return:50 """51 key = 'unexecuted_opr_check_time'52 conf = Configure.objects.get(name=key)53 conf.val = str(check_time)5455 with transaction.atomic():56 conf.save()57 cache.set_hash('configure', key, check_time)5859 ...

Full Screen

Full Screen

py_storage_check_emc_unity_300.py

Source:py_storage_check_emc_unity_300.py Github

copy

Full Screen

1import json 2import pandas as pd 3import requests4import sys 5import os6import csv7from pprint import pprint8from py_storageDeclarations_emc_unity_300 import *9server_ip=sys.argv[1]10server_name=sys.argv[2]11check_time=sys.argv[3]12username=sys.argv[4]13password=sys.argv[5]14result_file=sys.argv[6]15def genericParser(server_ip,server_name,check_time,uri,field_list,module_name,cols): 16 api_url_base = 'https://'+server_ip17 headers = {'Content-Type': 'application/json', 'X-EMC-REST-CLIENT': 'true', 'Accept': 'application/json', 'compact':'true'}18 api_url = api_url_base+uri+"?fields="+",".join(field_list)19 response = requests.get(api_url,verify=False, headers=headers,auth=(username, password))20 raw_input=json.loads(response.text)21 normalized_data = pd.json_normalize(data = raw_input['entries'])22 df= normalized_data[list(normalized_data.columns[3:])]23 df.insert(0, 'object_group', module_name)24 df.insert(0, 'server_ip', server_ip)25 df.insert(0, 'server_name',server_name)26 df.insert(0, 'check_type', 'STORAGE')27 df.insert(0, 'check_time', check_time) 28 formatted_data=pd.DataFrame(df, columns = cols)29 #formatted_data.to_csv('outputfile_storage_'+server_name+'_'+check_time,mode='a', header=False,index=None)30 formatted_data.to_csv(result_file,mode='a', header=False,index=None)31 32 33genericParser(server_ip,server_name,check_time,BATTERY_URI,BATTERY,"BATTERY",BATTERY_COLS)34genericParser(server_ip,server_name,check_time,DISK_URI,DISK,"DISK",DISK_COLS)35genericParser(server_ip,server_name,check_time,POWER_SUPPLIES_URI,POWER_SUPPLIES,"POWER_SUPPLY",POWER_SUPPLIES_COLS)36genericParser(server_ip,server_name,check_time,MEMORY_MODULE_URI,MEMORY_MODULE,"MEMORY_MODULE",MEMORY_MODULE_COLS)37genericParser(server_ip,server_name,check_time,IO_MODULE_URI,IO_MODULE,"IO_MODULE",IO_MODULE_COLS)38genericParser(server_ip,server_name,check_time,HOST_URI,HOST,"HOSTS",HOST_COLS)39genericParser(server_ip,server_name,check_time,FANS_URI,FANS,"FANS",FANS_COLS)40genericParser(server_ip,server_name,check_time,SAS_PORT_URI,SAS_PORT,"SAS_PORTS;PORT_STATUS",SAS_PORT_COLS)41genericParser(server_ip,server_name,check_time,FCPORT_URI,FCPORT,"FCPORTS;PORT_STATUS",FCPORT_COLS)42genericParser(server_ip,server_name,check_time,ETHERNET_PORTS_URI,ETHERNET_PORTS,"ETHERNET_PORTS;PORT_STATUS",ETHERNET_PORTS_COLS)43genericParser(server_ip,server_name,check_time,LINK_CONTROL_CARDS_URI,LINK_CONTROL_CARDS,"LINK_CONTROL_CARDS",LINK_CONTROL_CARDS_COLS)44genericParser(server_ip,server_name,check_time,LUN_URI,LUN,"LUNS",LUN_COLS)45genericParser(server_ip,server_name,check_time,POOLS_URI,POOLS,"POOLS",POOLS_COLS)46genericParser(server_ip,server_name,check_time,DISK_PROCESSOR_ENCLOSURES_URI,DISK_PROCESSOR_ENCLOSURES,"DISK_PROCESSOR_ENCLOSURES",DISK_PROCESSOR_ENCLOSURES_COLS)47genericParser(server_ip,server_name,check_time,DISKGROUP_URI,DISKGROUP,"DISKGROUPS",DISKGROUP_COLS)48genericParser(server_ip,server_name,check_time,SSD_URI,SSD,"SSDS",SSD_COLS)49genericParser(server_ip,server_name,check_time,DISK_ARRAY_ENCLOSURES_URI,DISK_ARRAY_ENCLOSURES,"DISK_ARRAY_ENCLOSURES",DISK_ARRAY_ENCLOSURES_COLS)50genericParser(server_ip,server_name,check_time,STORAGE_PROCESSOR_URI,STORAGE_PROCESSOR,"STORAGE_PROCESSORS",STORAGE_PROCESSOR_COLS)51genericParser(server_ip,server_name,check_time,BASIC_SYSTEM_INFORMATION_URI,BASIC_SYSTEM_INFORMATION,"BASIC_SYSTEM_INFORMATION",BASIC_SYSTEM_INFORMATION_COLS)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful