Пример #1
0
    def test_result_update(
        sheet_number, row_number, data_list, analysis_file_update=False
    ):
        if analysis_file_update:
            result_file_path = (
                os.path.abspath(".")
                + "/config/"
                + Common.get_config_value("analysis_input_file")
            )
        else:
            result_file_path = (
                os.path.abspath(".")
                + "/report/"
                + Common.get_config_value("analysis_output_file")
            )

        xlsObj, wb_copy = Xlsparser.copy_xls(result_file_path, sheet_number)
        column_number = 0
        for content in data_list:
            xlsObj.write(
                row_number, column_number, f"{content}", Xlsparser.cell_styles()
            )
            column_number += 1
        wb_copy.save(result_file_path)
        del xlsObj
        del wb_copy
Пример #2
0
def Conftest():
    uri = "/api/user/login"
    allure.attach(SX_API_URl + uri, '地址', allure.attachment_type.TEXT)
    data = {"account": User_account, "password": User_password}
    headers = {'content-type': 'application/json'}
    allure.attach(json.dumps(data, ensure_ascii=False, indent=4), '请求',
                  allure.attachment_type.TEXT)
    allure.attach(json.dumps(headers, ensure_ascii=False, indent=4), '请求头',
                  allure.attachment_type.TEXT)
    comm = Common()
    response = comm.post(uri, params=data, headers=headers)
    allure.attach(json.dumps(response.json(), ensure_ascii=False, indent=4),
                  '响应', allure.attachment_type.TEXT)
    print("__________________________")
    print(response.text)
    code = int(response.status_code)
    print(code)
    code1 = json.loads(response.text)['code']
    if code == 200 and code1 == 0:
        msg = response.json().get('msg')
        # with open('./Config/config_token', 'w', encoding='utf-8') as f:
        #     f.write(msg)
        login_headers["token"] = msg
        print("Conftest——成功")
    else:
        print("Conftest——失败")
def index(job_name=None, build_number=None, component_version=None):
    """
    This API is used to search the result based on the selected filtered options.
    :param str job_name:
    :param int build_number:
    :param str component_version:
    :return: Searched results and search job menu
    """
    search_form = JobSearchForm(request.form)
    if request.method == "POST":
        job_name = search_form.data["job_name"].strip()
        try:
            pattern_type = re.search(r"\w*-\w*", job_name).group()
        except AttributeError:
            Common.logger.warn(
                f"index:failed to search the job name: {job_name}")
            pattern_type = job_name
        build_number = search_form.data["build_number"]
        component_version = search_form.data["component_version"]

        fs = extracting_build_info(
            job_name=job_name,
            build_number=build_number,
            component_version=component_version,
        )
        if fs.count() == 0:
            return render_template("404.html", title="404"), 404
        data_list = Common.collection_creation(fs)
        return render_template(
            "search_results.html",
            List=data_list,
            pattern_type=pattern_type,
            data_display="True",
        )
    if job_name and build_number and component_version:
        fs = extracting_build_info(
            job_name=job_name,
            build_number=build_number,
            component_version=component_version,
        )
        if fs.count() == 0:
            return render_template("404.html", title="404"), 404
        data_list = Common.collection_creation(fs)
        test_data_map = Common.test_map_details(data_list)
        try:
            pattern_type = re.search(r"\w*-\w*",
                                     data_list[0]["Job-Name"]).group()
        except AttributeError:
            Common.logger.warn(
                f"index:failed to search the job: {data_list[0]['Job-Name']}")
            pattern_type = job_name

        return render_template(
            "search_results.html",
            List=data_list,
            pattern_type=pattern_type,
            data_display="False",
            test_data_map=test_data_map,
        )
    return render_template("search.html", form=search_form)
def search_by_component():
    """
    This API is used to search the job based on the their component
    :return:
    """
    search_form = SearchByField(request.form)
    if request.method == "POST":
        Common.logger.info("search_by_component:Post API called")
        field_name = search_form.select.data
        field_value = search_form.data["search"].strip()
        fs = extracting_data_by_field(field_name=field_name,
                                      field_value=field_value)
        if fs.count() == 0:
            return render_template("404.html", title="404"), 404

        data_list = Common.collection_creation(fs)
        test_data_map = Common.test_map_details(data_list)
        if test_data_map == 500:
            Common.logger.warn(
                f"search_by_component:Internal server error comes while listing "
                f"the data_list={data_list}")
            return render_template("500.html", title="500"), 500
        return render_template("search_results.html",
                               List=data_list,
                               test_data_map=test_data_map)
    return render_template("component_search_by_field.html",
                           search_form=search_form)
Пример #5
0
def google(client: Client, message: Message) -> None:
    query = " ".join(message.command[1:])
    command = message.command[0]

    with GoogleAPI() as g_client:
        if command == "g":
            response: GoogleResponse = g_client.search(
                query, search_type=SEARCH_TYPE.TEXT)
            if response:
                client.send_chat_action(message.chat.id, "typing")
                client.send_message(
                    message.chat.id,
                    f"<b>{response.title}</b>\n\n{response.snippet}\n\n{response.url}",
                    parse_mode="HTML",
                )
            else:
                Common.send_not_found_message(message)

        if command == "gi" or command == "p":
            response: GoogleImageResponse = g_client.search(
                query, search_type=SEARCH_TYPE.IMAGE)

            if response:
                client.send_chat_action(message.chat.id, "upload_photo")
                client.send_photo(
                    message.chat.id,
                    response.url,
                    caption=
                    f"<i>{response.snippet}</i>\n\n{response.source_url}",
                    parse_mode="HTML",
                )
            else:
                Common.send_not_found_message(message)
Пример #6
0
    def __init__(self, client_id, log_obj):
        self.logger = log_obj.logger
        self.client_id = client_id
        self.client = MqttClient(client_id=client_id)

        self.config = Common.load_config('../../configs/mqtt_config.yaml')
        self.mqtt_configs = self.config['mqtt']
        self.__mqtt_host = self.mqtt_configs['host']
        self.__mqtt_port = self.mqtt_configs['port']
        self.__mqtt_topic = self.mqtt_configs['topic']
        self.mqtt_topics = []
        self.set_callbacks()

        self.kafka_config = Common.load_config(
            '../../configs/kafka_configs.yaml')['kafka']
        self.__kafka_host = self.kafka_config['host']
        self.__kafka_topic = self.kafka_config['topic']

        self.mongo_config = Common.load_config(
            '../../configs/mongo.yaml')['mongo']
        self.__mongo_host = self.mongo_config['host']
        self.__mongo_port = self.mongo_config['port']
        self.__mongo_database = self.mongo_config['database']
        self.__mongo_collection = self.mongo_config['collection']

        self.qos = int(self.mqtt_configs['qos'])
        self.kafka_service = KafkaService(self.__kafka_host, log_obj=log_obj)
        self.mongo_service = MongoService(self.__mongo_host,
                                          self.__mongo_port,
                                          log_obj=log_obj)
Пример #7
0
 def env_setup():
     if not os.path.isfile(
             os.path.join(os.path.abspath("."),
                          Common.get_config_value("data_location"))):
         os.mkdir(
             os.path.join(os.path.abspath("."),
                          Common.get_config_value("data_location")))
     return 0
Пример #8
0
 def __enter__(self):
     self.jenkinsObj = Jenkins(
         Common.get_config_value("jenkins_base_url"),
         Common.decrypt(Common.get_config_value("jenkins_username")),
         Common.decrypt(Common.get_config_value("jenkins_password")),
         ssl_verify=False,
     )
     return self.jenkinsObj
Пример #9
0
def approve(contract_address,pay_address,get_address, amount,node_index = None,errorcode=47001,errorkey="error"):
	if len(get_address)!=34 :
		send_get_address=ByteToHex(bytes(get_address, encoding = "utf8"))
	else:
		send_get_address=Common.bl_address(get_address)
		if send_get_address=="0000000000000000000000000000000000000000":
			send_get_address=ByteToHex(bytes(get_address, encoding = "utf8"))
	if len(pay_address)!=34 :
		send_pay_address=ByteToHex(bytes(pay_address, encoding = "utf8"))
	else:
		send_pay_address=Common.bl_address(pay_address)
		if send_pay_address=="0000000000000000000000000000000000000000":
			send_pay_address=ByteToHex(bytes(pay_address, encoding = "utf8"))
	request = {
		"REQUEST": {
			"Qid": "t",
			"Method": "signeovminvoketx",
			"Params": {
				"gas_price": 0,
				"gas_limit": 1000000000,
				"address": contract_address,
				"version": 1,
				"params": [
					{
						"type": "string",
						"value": "approve"
					},
					
					{
						"type": "array",
						"value":  [
							{
								"type": "bytearray",
								
								"value": send_pay_address
							},
							{
								"type": "bytearray",
								"value": send_get_address
							},
							{
								"type": "int",
								"value": amount
							}
						]
					}
				]
			}
		},
		"RESPONSE":{"error" : errorcode},
		"NODE_INDEX":node_index
	}
	if (errorkey =="error_code"):
		request["SIGN_RESPONSE"]={errorkey : errorcode}
	if len(contract_address)<=5:
		logger.error("contract address error! now is contract address:\"" + contract_address+"\"")
		return (False,{"error":10000,"desc":"contract address error!"})
	return API.contract().call_contract(Task(name="approve", ijson=request), twice = True,sleep=0)
def edit_observation(pattern_type, id):
    """
    This API is used to edit the observation based on the available record.
    :param pattern_type:
    :param id:
    """
    fs = accessing_data_via_id(build_id=f"{id}")
    if fs.count() == 0:
        return render_template("404.html", title="404"), 404
    record = Common.collection_creation(fs)[0]
    form = ObservationUpdate(request.form)
    if request.method == "POST":
        Common.logger.info(
            f"edit_observation: Post API called against id {id} and pattern type"
            f" {pattern_type}")
        observations = ast.literal_eval(form.data["observation_data"])
        try:
            Common.logger.info(
                f"edit_observation: The provided observation is {observations}"
                f" {pattern_type}")
            if pattern_type not in Common.get_config_value("test_map"):
                if type(observations) is dict:
                    for observation in observations:
                        db_update(
                            observation_record_key=f"{observation}",
                            observation_record_value="{}".format(
                                observations[observation]),
                        )
                record["Validation"] = Common.record_updater(
                    record["Validation"], observations)
                update_record(f"{id}", old_record=record)
            else:
                os.popen("touch problem_in_before_update")
                failed_test_details = {
                    "test_details":
                    record["Validation"]["Pre_Upgrade_test_Failure"]
                }
                updated_data = Common.record_updater(failed_test_details,
                                                     observations)
                record["Validation"][
                    "Pre_Upgrade_test_Failure"] = updated_data["test_details"]
                update_record(f"{id}", old_record=record)
        except Exception as ex:
            Common.logger.warn(
                f"edit_observation: The provided dictionary is not in correct "
                f"format {ex}")
            flash(
                "Please provide the proper dictionary format {} of pattern {}".
                format(observations, pattern_type))
            return render_template("observation.html",
                                   form=form,
                                   pattern_type=pattern_type,
                                   record=record)
        flash("Data Submitted Successfully")
    return render_template("observation.html",
                           form=form,
                           pattern_type=pattern_type,
                           record=record)
Пример #11
0
def approve(contract_address,
            pay_address,
            get_address,
            amount,
            node_index=None,
            errorcode=47001,
            errorkey="error"):
    request = {
        "REQUEST": {
            "Qid": "t",
            "Method": "signeovminvoketx",
            "Params": {
                "gas_price":
                0,
                "gas_limit":
                1000000000,
                "address":
                contract_address,
                "version":
                1,
                "params": [{
                    "type": "string",
                    "value": "approve"
                }, {
                    "type":
                    "array",
                    "value": [{
                        "type":
                        "bytearray",
                        "value":
                        Common.bl_reserver(
                            Common.base58_to_address(pay_address))
                    }, {
                        "type":
                        "bytearray",
                        "value":
                        Common.bl_reserver(
                            Common.base58_to_address(get_address))
                    }, {
                        "type": "int",
                        "value": amount
                    }]
                }]
            }
        },
        "RESPONSE": {
            "error": errorcode
        },
        "NODE_INDEX": node_index
    }
    if (errorkey == "error_code"):
        request["SIGN_RESPONSE"] = {errorkey: errorcode}
    return API.contract().call_contract(Task(name="approve", ijson=request),
                                        twice=True)
Пример #12
0
def allowance(contract_address,
              pay_address,
              get_address,
              node_index=None,
              errorcode=47001,
              errorkey="error"):
    if len(get_address) != 34:
        send_get_address = ByteToHex(bytes(get_address, encoding="utf8"))
    else:
        send_get_address = Common.bl_address(get_address)
    if len(pay_address) != 34:
        send_pay_address = ByteToHex(bytes(pay_address, encoding="utf8"))
    else:
        send_pay_address = Common.bl_address(pay_address)
    request = {
        "REQUEST": {
            "Qid": "t",
            "Method": "signeovminvoketx",
            "Params": {
                "gas_price":
                0,
                "gas_limit":
                1000000000,
                "address":
                contract_address,
                "version":
                1,
                "params": [{
                    "type": "string",
                    "value": "allowance"
                }, {
                    "type":
                    "array",
                    "value": [{
                        "type": "bytearray",
                        "value": send_pay_address
                    }, {
                        "type": "bytearray",
                        "value": send_get_address
                    }]
                }]
            }
        },
        "RESPONSE": {
            "error": errorcode
        },
        "NODE_INDEX": node_index
    }
    if (errorkey == "error_code"):
        request["SIGN_RESPONSE"] = {errorkey: errorcode}
    return API.contract().call_contract(Task(name="allowance", ijson=request),
                                        twice=True,
                                        sleep=0)
Пример #13
0
 def test_get_mer_addorupdate(self, merchantName_id):
     uri = "/api/merchant/getMerchant/{}".format(merchantName_id)
     data = {"id": merchantName_id}
     headers1 = login_headers
     comm = Common()
     status = comm.get(uri, data, headers1)
     if status:
         merchantName_id, is_delete = self.test_select_db(
             merchantName_id=merchantName_id)
         print("商户的id能够正常的显示,id为{}".format(merchantName_id))
     else:
         print("商户的id")
Пример #14
0
def youtube(client: Client, message: Message) -> None:
    query = " ".join(message.command[1:])

    with YouTubeAPI() as y_client:
        response = y_client.search(query)

        if response:
            client.send_chat_action(message.chat.id, "typing")
            result = f'<b><a href="{response.url}">{response.title}</a></b>'
            client.send_message(message.chat.id, result, parse_mode="HTML")
        else:
            Common.send_not_found_message(message)
def progress(job_type):
    """
    This API is used to call the action based on the provided job type
    :param job_type:
    """
    if job_type == "log_analysis":
        Common.logger.info("progress: log analysis called")
        obj = Controller()
        th1 = Thread(target=obj.run)
    else:
        Common.logger.info("progress: mail send report called")
        th1 = Thread(target=Common.mail_send())
    th1.start()
    return Response(Common.generate(th1), mimetype="text/event-stream")
Пример #16
0
 def __init__(self,
              driver: WebDriver = None,
              platform="web",
              desired_caps=None):
     """
     实例化时如果传入 driver,直接使用 传入的 driver,如果没有则判断 platform ,并生成对应的driver
     默认生成 selenium webdriver
     暂时只实现了web 和 android 平台
     :param platform: 平台,web android ios
     :param driver:
     :param desired_caps: Android 平台的 desired_capabilities
     """
     self.project_path = Common().parse_path().get("project_path")
     if driver is None:
         if platform == "web":
             webdriver = selenium.webdriver
             options = Options()
             options.debugger_address = "127.0.0.1:9999"
             self._driver = webdriver.Chrome(
                 executable_path=ChromeDriver().get_driver(),
                 options=options)
             self._driver.implicitly_wait(3)
         elif platform == "android":
             webdriver = appium_webdriver
             self._driver = webdriver.Remote('http://localhost:4723/wd/hub',
                                             desired_caps)
             self._driver.implicitly_wait(10)
         elif platform == "ios":
             pass
     else:
         self._driver = driver
     if self._base_url != "":
         self._driver.get(self._base_url)
         self.log.info(f'访问地址:{self._base_url}')
Пример #17
0
 def download_the_logs(downloadlink, job_name):
     status = subprocess.call(
         [
             "wget {} -P {}/{} --no-check-certificate".format(
                 downloadlink,
                 os.path.abspath("."),
                 Common.get_config_value("data_location"),
             )
         ],
         shell=True,
     )
     if status == 0:
         rename_file_name = "{}_{}".format(job_name,
                                           random.randint(1, 10000))
         os.rename(
             f"{os.path.abspath('.')}/{Common.get_config_value('data_location')}"
             "/consoleFull",
             f"{os.path.abspath('.')}/{Common.get_config_value('data_location')}/"
             f"{rename_file_name}",
         ) if os.path.isfile(
             f"{os.path.abspath('.')}/{Common.get_config_value('data_location')}"
             f"/consoleFull") else "Nothing"
         Common.logger.info(f"[download_the_logs] Downloaded logs renamed")
         return rename_file_name
     else:
         Common.logger.warn(
             f"[download_the_logs]: The job does not exist {job_name} "
             f"and downloadable link {downloadlink}")
         return False
def job_list():
    """
    This api help us to get the details of job name, build number and component version.
    """
    fs = accessing_all_data()
    if fs.count() == 0:
        Common.logger.info(
            f"job_list: there is no details available in the database")
        return render_template("404.html", title="404"), 404
    records = Common.collection_creation(fs)
    job_records = dict()
    for job in records:
        if job["Job-Name"] not in job_records and ("Build-Number" in job
                                                   and "Build-Version" in job):

            job_records[job["Job-Name"]] = {
                "Build-Number": [job["Build-Number"]],
                "Build-Version": [job["Build-Version"]],
            }
        elif "Build-Number" in job and "Build-Version" in job:
            job_records[job["Job-Name"]]["Build-Number"].append(
                job["Build-Number"])
            job_records[job["Job-Name"]]["Build-Version"].append(
                job["Build-Version"])
    if job_records == dict():
        return render_template("404.html", title="404"), 404
    return render_template("job_name.html", job_records=job_records)
Пример #19
0
class TestAddMember:
    desired_caps = {
        "platformName": "Android",
        "deviceName": "127.0.0.1:7555",
        "appPackage": "com.tencent.wework",
        "appActivity": ".launch.WwMainActivity",
        "noReset": True
    }
    data_path = Common().parse_path().get("data_path")

    def setup_class(self):
        self.main_page = MainPage(platform="android",
                                  desired_caps=self.desired_caps)

    def teardown_class(self):
        self.main_page.quit()

    def teardown(self):
        self.main_page.back()

    @pytest.mark.parametrize("username, address, mobile_phone",
                             yaml.safe_load(
                                 open(os.path.join(data_path, 'user.yml'))))
    def test_add_member(self, username, address, mobile_phone):
        page = self.main_page.go_to_contacts().go_to_add_member().go_to_manual(
        ).add_member(username=username,
                     address=address,
                     mobile_phone=mobile_phone)
        result = page.get_toast()
        assert "成功" in result
def delete_build_data():
    """
    This API is used to delete the job based
    """
    search_form = JobSearchForm(request.form)
    if request.method == "POST":
        job_name = search_form.data["job_name"].strip()
        build_number = search_form.data["build_number"]
        component_version = search_form.data["component_version"]
        fs = extracting_build_info(
            job_name=job_name,
            build_number=build_number,
            component_version=component_version,
        )
        if fs.count() == 0:
            return render_template("404.html", title="404"), 404

        record = Common.collection_creation(fs)[0]
        response_json = delete_record(build_id=record["_id"])
        if response_json.acknowledged:
            flash(
                "Build No {} of Job {} having version {} deleted successfully".
                format(job_name, build_number, component_version))
        else:
            flash("Failed to delete content")
    return render_template("delete_build.html", form=search_form)
def index_pagination(job_name):
    """
    This API  is used to list the job based on their job name
    :param str job_name: Name of the Jenkins job
    :return: redirect the build history page
    """
    fs = regex_data_retrieval(job_name=job_name)
    if fs.count() == 0:
        return render_template("404.html", title="404"), 404
    try:
        pattern_type = re.search(r"\w*-\w*", job_name).group()
    except AttributeError:
        Common.logger.warn(
            f"index_pagination:failed to search the job name: {job_name}")
        pattern_type = job_name
    offset = {"page": 1, "per_page": Common.get_config_value("per_page")}
    page, per_page, offset = get_page_args(page_parameter="page",
                                           per_page_parameter="per_page",
                                           **offset)
    pagination_items = page_list(fs, per_page=per_page, offset=offset)
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=fs.count(),
                            css_framework="bootstrap4")
    return render_template(
        "index_pagination.html",
        List=pagination_items,
        page=page,
        per_page=per_page,
        pagination=pagination,
        pattern_type=pattern_type,
        job_name=job_name,
    )
Пример #22
0
    def nodeCountCheck(InResponse, nodeCount):
        (result1, response1) = API.rpc().getstorage(
            "0700000000000000000000000000000000000000",
            ByteToHex(b"governanceView"))
        if not result1:
            return (False, {"error_info": "getstorage governanceView error !"})
        viewvalue = ""
        viewvalue = response1["result"][0:8]
        print(viewvalue)
        (result1, response1) = API.rpc().getstorage(
            "0700000000000000000000000000000000000000",
            ByteToHex(b"peerPool") + viewvalue)
        if not result1:
            return (False, {
                "error_info":
                "getstorage peerPool error ! viewValue:" + viewvalue
            })
        resCheck = Common.bl_reserver(response1["result"][0:2])
        print(resCheck)
        resInt = bytes.fromhex(resCheck)
        print(resInt.hex())
        if isinstance(InResponse, dict):
            InResponse["nodeCountNow"] = int(resInt.hex(), 16)
        else:
            InResponse = {
                "response": InResponse,
                "nodeCountNow": int(resInt.hex(), 16)
            }

        if (nodeCount == int(resInt.hex(), 16)):
            return (True, InResponse)
        else:
            return (False, InResponse)
Пример #23
0
	def multi_sig_transfer(neo_contract_address, from_address, to_address, amount, m, pubkey_array, node_index=0):
		request = {
				"REQUEST":  {
				"Qid": "t",
				"Method": "signeovminvoketx",
				"Params": {
					"gas_price": 0,
					"gas_limit": 1000000000,
					"address": neo_contract_address,
					"version": 1,
					"params": [
						{
							"type": "string",
							"value": "transfer"
						},
						{	
							"type" : "string",
							"value" : ""
						},
						{
							"type": "array",
							"value": [
								{
									"type": "bytearray",
									"value": Common.bl_reserver(Common.base58_to_address(from_address))
								},
								{
									"type": "bytearray",
									"value": Common.bl_reserver(Common.base58_to_address(to_address))
								},
								{
									"type": "int",
									"value": amount
								}
							]
						}
					]
				}
			},
			"RESPONSE":{"error" : 0},
			"NODE_INDEX":node_index
		}

		return CONTRACT_API.call_multisig_contract(Task(name="multi_sig_transfer", ijson=request), m, pubkey_array)
Пример #24
0
	def transfer(contract_address,from_address,to_address,amount, node_index = None):
		request = {
			"REQUEST": {
				"Qid": "t",
				"Method": "signeovminvoketx",
				"Params": {
					"gas_price": 0,
					"gas_limit": 1000000000,
					"address": contract_address,
					"version": 1,
					"params": [
						{
							"type": "string",
							"value": "transfer"
						},
						{	
							"type" : "string",
							"value" : ""
						},
						{
							"type": "array",
							"value":  [
								{
									"type": "bytearray",
									
									"value": Common.bl_reserver(Common.base58_to_address(from_address))
								},
								{
									"type": "bytearray",
									"value": Common.bl_reserver(Common.base58_to_address(to_address))
								},
								{
									"type": "int",
									"value": amount
								}
							]
						}
					]
				}
			},
			"RESPONSE":{"error" : 0},
			"NODE_INDEX":node_index
		}
		return API.contract().call_contract(Task(name="transfer", ijson=request), twice = True)
Пример #25
0
def fate_question(client: Client, message: Message) -> None:
    _message = " ".join(
        Common.pronoun_replace(message.text).replace("?", "").split()[1:])

    random.seed(datetime.now())

    correct_answer = f"{_message.split('ли')[1]} {_message.split('ли')[0]}"
    incorrect_answer = random.choice(("Нет.", "Ни в коем случае."))

    message.reply_text(random.choice((correct_answer, incorrect_answer)))
Пример #26
0
 def run(self):
     """
     This method is used to trigger the main method and perform the cleanup of all
     properties
     :return:
     """
     sheet_number = {"Sheet_1": 0}
     Common.environment_preparation()
     for sheet in sheet_number.keys():
         row_no = 0
         self.prop_obj.sheets_number = sheet_number
         self.prop_obj.rows_no = row_no
         self.prop_obj.sheets = sheet
         self.mapper_builder()
         del self.prop_obj.rows_no
         del self.prop_obj.job_mapper
         del self.prop_obj.jobs_list
         del self.prop_obj.sheets_number
         del self.prop_obj.sheets
Пример #27
0
def forNeo(contract_address, pay_address, get_address, node_index=None):
    request = {
        "REQUEST": {
            "Qid": "t",
            "Method": "signeovminvoketx",
            "Params": {
                "gas_price":
                0,
                "gas_limit":
                1000000000,
                "address":
                contract_address,
                "version":
                1,
                "params": [{
                    "type": "string",
                    "value": "transfer"
                }, {
                    "type":
                    "array",
                    "type":
                    "array",
                    "value": [{
                        "type": "bytearray",
                        "value": Common.bl_address(pay_address)
                    }, {
                        "type": "bytearray",
                        "value": Common.bl_address(get_address)
                    }, {
                        "type": "int",
                        "value": "10"
                    }]
                }]
            }
        },
        "RESPONSE": {
            "error": 0
        },
        "NODE_INDEX": node_index
    }
    return API.contract().call_contract(Task(name="forNeo", ijson=request),
                                        twice=True)
Пример #28
0
    def run_single_task(task, judge=True, process_log=True):
        connecttype = task.type()
        name = task.name()
        start_time = time.time()

        if process_log:
            logger.print("[-------------------------------]")
            logger.print("[ CONNECT  ] " + str(connecttype) + "." + str(name))

        cfg_content = task.data()
        cfg_request = cfg_content["REQUEST"]
        cfg_response = cfg_content["RESPONSE"]
        if process_log:
            logger.print(
                "[ REQUEST  ]" +
                json.dumps(cfg_content, indent=4, sort_keys=True).replace(
                    "\"num#!#start-", "").replace("-num#!#end\"", ""))

        # (result, response) = self.multithread_run(logger, cfg_request, cfg_response)
        node_index = task.node_index()
        node_ip = None
        if node_index is None:
            node_index = 0

        if connecttype.lower() == "rpc":
            node_ip = Config.NODES[int(node_index)]["ip"] + ":" + str(
                Config.NODES[int(node_index)]["rpcport"])
        if connecttype.lower() == "st":
            node_ip = Config.NODES[int(node_index)]["ip"] + ":" + str(
                Config.NODES[int(node_index)]["stport"])
        logger.print("run on service(" + str(node_index) + "):  " + node_ip)

        response = utils.connect.con(connecttype, node_ip, cfg_request)
        if process_log:
            logger.print("[ RESPONSE ]" + json.dumps(response, indent=4))

        end_time = time.time()
        time_consumed = (end_time - start_time) * 1000

        result = True
        if judge:
            result = Common.cmp(cfg_response, response)
            if process_log:
                if result:
                    logger.print("[ OK       ] " + connecttype + "." + name +
                                 " (%d ms)" % (time_consumed))
                else:
                    logger.print("[ Failed   ] " + connecttype + "." + name +
                                 " (%d ms)" % (time_consumed))
                logger.print("[-------------------------------]")
                logger.print("")

        return (result, response)
def page_list(fs, per_page, offset=0):
    """
    This function is used to calculate the current offset value
    :param fs:
    :param per_page:
    :param offset:
    :return: offset number
    """
    Common.logger.info(
        f"Collecting the requested record by the pagination module {fs}")
    requested_record = Common.collection_creation(fs)
    return requested_record[offset:offset + per_page]
def job_process():
    """
    This API is used to download the logs and analyze it based on the provided details
    """
    form = ValidatorName(request.form)
    if request.method == "POST":
        Common.logger.info(f"job_process: Post method called")
        job_processing_type = "log_analysis"
        job_type = form.data["job_type"].strip()
        job_number = form.data["job_number"]
        component_not_check = form.data["skip_selection"]
        component_version = form.data["component_version"]
        snap_number = form.data["snap_number"]
        Common.version_update(component_version, job_type)
        DataUpdater.build_sheet_update(job_type, job_number,
                                       component_not_check, component_version,
                                       snap_number)
        return render_template("data_processing.html",
                               form=form,
                               job_processing_type=job_processing_type)
    return render_template("analyser_input.html", form=form)