How to use get_key method in yandex-tank

Best Python code snippet using yandex-tank

LSB.py

Source:LSB.py Github

copy

Full Screen

...6from PIL import Image7def plus(string):8 # Python zfill() 方法返回指定长度的字符串,原字符串右对齐,前面填充0。9 return string.zfill(8)10def get_key(strr):11 # 获取要隐藏的文件内容12 with open(strr, "rb") as f:13 s = f.read()14 string = ""15 for i in range(len(s)):16 # 逐个字节将要隐藏的文件内容转换为二进制,并拼接起来17 # 1.先用ord()函数将s的内容逐个转换为ascii码18 # 2.使用bin()函数将十进制的ascii码转换为二进制19 # 3.由于bin()函数转换二进制后,二进制字符串的前面会有"0b"来表示这个字符串是二进制形式,所以用replace()替换为空20 # 4.又由于ascii码转换二进制后是七位,而正常情况下每个字符由8位二进制组成,所以使用自定义函数plus将其填充为8位21 string = string + "" + plus(bin(s[i]).replace('0b', ''))22 return string23def mod(x, y):24 return x % y25def opreations(n, key, count):26 e = 827 print(count, len(key))28 return n - mod(n, (2**e)) + (int(key[count])*(2**e))29# str1为载体图片路径,str2为隐写文件,str3为加密图片保存的路径30def func(str1, str2, str3):31 im = Image.open(str1)32 # 获取图片的宽和高33 width, height = im.size[0], im.size[1]34 print("width:" + str(width))35 print("height:" + str(height))36 count = 037 # 获取需要隐藏的信息38 key = get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2) + get_key(str2)39 keylen = len(key)40 for h in range(height):41 for w in range(width):42 pixel = im.getpixel((w, h))43 a = pixel[0]44 b = pixel[1]45 c = pixel[2]46 if count == keylen:47 break48 # 下面的操作是将信息隐藏进去49 # 分别将每个像素点的RGB值余2,这样可以去掉最低位的值50 # 再从需要隐藏的信息中取出一位,转换为整型51 # 两值相加,就把信息隐藏起来了52 a = opreations(a, key, count)...

Full Screen

Full Screen

yamlget

Source:yamlget Github

copy

Full Screen

...14import os15import sys16from optparse import OptionParser17import yaml18def get_key(fullkey, data):19 """20 Get the requested key from the parsed data.21 :param fullkey: the key to get, nested values can be accessed by using a22 colon (":") as the separator23 :param data: the parsed data, from yaml.load()24 Examples:25 >>> data = {26 ... 'bool': [True, False, True, False],27 ... 'dict': {'hp': 13, 'sp': 5},28 ... 'float': 3.14159,29 ... 'int': 42,30 ... 'list': ['LITE', 'RES_ACID', 'SUS_DEXT'],31 ... 'none': [None, None],32 ... 'text': "The Set of Gauntlets 'Pauraegen'",33 ... }34 >>> get_key('bool', data)35 [True, False, True, False]36 >>> get_key('bool:2', data)37 False38 >>> get_key('dict', data)39 {'hp': 13, 'sp': 5}40 >>> get_key('dict:hp', data)41 1342 >>> get_key('float', data)43 3.1415944 >>> get_key('int', data)45 4246 >>> get_key('list', data)47 ['LITE', 'RES_ACID', 'SUS_DEXT']48 >>> get_key('list:2', data)49 'RES_ACID'50 >>> get_key('list:2:5', data)51 'RES_ACID'52 >>> get_key('none', data)53 [None, None]54 >>> get_key('none:1', data)55 >>> get_key('text', data)56 "The Set of Gauntlets 'Pauraegen'"57 >>> get_key('2', ['item1', 'item2', 'item3'])58 'item2'59 """60 value = data61 while value is not None:62 key, _sep, fullkey = fullkey.partition(":")63 if isinstance(value, list):64 try:65 key = int(key)66 except TypeError:67 print("Wrong key format: %s, it should be an integer" % key,68 file=sys.stderr)69 sys.exit(1)70 value = value[key - 1] # start at 1, not 071 elif isinstance(value, dict):72 value = value.get(key)73 else:74 break # we've got the value now75 if not fullkey:76 break # can't go any further77 return value78def main():79 parser = OptionParser(usage="%prog <key> <yaml-file>")80 args = parser.parse_args()[1]81 if len(args) != 2:82 parser.error("wrong number of arguments")83 fullkey, filepath = args84 if not os.path.exists(filepath):85 parser.error("no such file: %s" % filepath)86 with open(filepath) as yamlfile:87 data = yaml.safe_load_all(yamlfile).next()88 #from pprint import pprint; pprint(data)89 value = get_key(fullkey, data)90 if value is not None:91 print(value)92if __name__ == "__main__":...

Full Screen

Full Screen

env_variables.py

Source:env_variables.py Github

copy

Full Screen

...12 project_folder = Path(__file__).parent.absolute()13 envPath = find_dotenv(os.path.join(project_folder, '.env'))14 except Exception:15 print(".env not found")16azureSubscriptionId = get_key(envPath, "SUBSCRIPTION_ID")17resourceLocation = get_key(envPath, "RESOURCE_LOCATION")18resourceGroupName = get_key(envPath, "RESOURCE_GROUP")19acrServiceName = get_key(envPath, "ACR_SERVICE_NAME")20acrServiceFullName = get_key(envPath, "ACR_SERVICE_FULL_NAME")21iotHubServiceName = get_key(envPath, "IOT_HUB_SERVICE_NAME")22iotDeviceId = get_key(envPath, "IOT_DEVICE_ID")23mediaServiceName = get_key(envPath, "AMS_ACCOUNT")24storageServiceName = get_key(envPath, "STORAGE_SERVICE_NAME")25acrUserName = get_key(envPath, "CONTAINER_REGISTRY_USERNAME_myacr")26acrPassword = get_key(envPath, "CONTAINER_REGISTRY_PASSWORD_myacr")27containerImageName = get_key(envPath, "CONTAINER_IMAGE_NAME")28debugOutputFolder = get_key(envPath, "DEBUG_OUTPUT_FOLDER")29aadTenantId = get_key(envPath, "AAD_TENANT_ID")30aadServicePrincipalId = get_key(envPath, "AAD_SERVICE_PRINCIPAL_ID")31aadServicePrincipalSecret = get_key(envPath, "AAD_SERVICE_PRINCIPAL_SECRET")32iotHubConnString = get_key(envPath, "IOT_HUB_CONN_STRING")33iotEdgeDeviceConnString = get_key(envPath, "IOT_EDGE_DEVICE_CONN_STRING")34sshstring = get_key(envPath, "SSH_STRING")35lvaExtensionPath = get_key(envPath, "LVA_EXTENSION_PATH")36userName = get_key(envPath, "USERNAME")37lvaSamplePath = get_key(envPath, "LVA_SAMPLE_PATH")38topologyFile = get_key(envPath, "TOPOLOGY_FILE")39graphInstanceName = get_key(envPath, "GRAPH_INSTANCE_NAME")40topologyName = get_key(envPath, "TOPOLOGY_NAME")...

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 yandex-tank 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