pyzk how to get the result of live capture - python-3.x

: 1495 : 2020-02-11 11:55:00 (1, 0)
Here is my sample result but then when I'm trying to split it gives me error
Process terminate : 'Attendance' object has no attribute 'split'
In the documentation it says
print (attendance) # Attendance object
How to access it?

Convert the attendance object into a string and split it.
str(attendance).split()
After splitting you can access the user ID and use it where ever you want.

found the solution
i check in the github repository of pyzk and look for the attendance class and found all the object being return by the live_capture thank you :)

It's an object of class Attendance. The split() is a method of string. So you can't directly split() an object. Dan is right, to split an object, first, you have to convert it to a string.
str(obj).split()
Although, you don't need to split this object to get the user id. All you have to do is, use accessor. e.g
user_id = attendance_obj.user_id

Related

TypeError: Member "encodepacked" not found or not visible after argument-dependent lookup in abi

here is a screenshort of my code
actually i want o/p like
{
"9658965896":"50",
"9658745896":"100"
}
eg: "phone":"balance", using hashmap I convert mapping to string and return string because without hashmap i try alot but nothg done soo i try these, please contribute to solve my problem , If you have another option than edit my code and send but i want above mention in output ,thanks in advance......

Calling methods dynamically, but not from a custom class

I'm trying to create a simple loop that prints out all available values of dir("Hello") side by side with the help("Hello".xxx) for each dir returned.
I've seen a number of stackoverflow threads on calling functions dynamically from a custom class, but it's not so clear how I can loop through built-in methods.
Taking this as an example:
for dr in dir("Hello"):
Using 'format' converts the "Hello.%d" % dr into a string of "hello.upper", but the print(help('hello.upper')) fails, because the help function expects "hello".upper, not "hello.upper":
for dr in dir("Hello"):
print(dr)
print(help("Hello.%d" % dr))
I've tried researching getattr, but the help function is not a method of the string, so getattr("Hello", "help")("upper") isn't working either.
expected results are:
dir value (followed by:)
dir help output
help doesn't return a string, it opens an interactive viewer for reading the help page.
To view each of these pages for some object (warning: there are going to be a lot of these pages), you can use getattr to get the attribute of the object given its name
obj = "Hello"
for attr_name in dir(obj):
help(getattr(obj, attr_name))

How to remove id from select active record?

Query on console
User.select('email','dob')
returns,
[#<User:0x000000084a9b08 id: nil, email: "xyz#zyx.com">,
Why am I getting id attributes in rails 4? How to get rid of this?
Pluck only returns the values if you want keys and values then
try this:
User.select('email','dob').as_json(:except => :id)
In my case the desired result was a JSON object. So, inside the as_json method
you can exclude any column you desire
(additionally you can invoke object methods or access associated tables as well)
This will give you desired output
User.pluck(:email, :dob)

Excel VBA copy the value of a label from Internet Explorer

I'm trying to retrieve the value "CONGE STATUTAIRE" from the following html code
<span class="DescriptionLabel" id="lblProjectDescription">CONGE STATUTAIRE</span>
I've tried this
nom_proj = IE.Document.getElementsByClassName("DescriptionLabel")(0).innerText
The code pass this line without problem but the the value of nom_proj is " ", and I would have hope to get "CONGE STATUTAIRE" for result.
Could anyone tells me what's wrong with it? The rest of my code is working i.e. I can retrieve value by using the getelementbyID method.
Any help will be welcomed.
I would use the getElementById() method, to make sure it can return only one HTML element and not a collection of objects:
nom_proj = IE.Document.getElementById("lblProjectDescription").innerText
However, the reason why you get "" is most probably that the collection returned by getElementsByClassName() has more than one element (often, when retrieving object by class names).
Which means: in the Document of your browser there will be most probably more elements that are styled with the CSS class DescriptionLabel; for example, something like this:
<div name="emptyRow" class = "DescriptionLabel"></div>
You can test if there are more than one element by:
1) either, adding a watcher to IE.Document.getElementsByClassName("DescriptionLabel");
2) or, printing all the elements inside, I bet my hat you'll find inside more than one:
For Each obj In IE.Document.getElementsByClassName("DescriptionLabel")
Debug.Print obj.InnerText
Next obj
GENERAL SUGGESTION: if an HTML object has an id, use the getElementByID; that method returns a single object, not a collection, so even if you would be sure that the collection will contain a unique element, it would anyway be less clean and efficient in terms of coding.

gatling combining transform with jsonpath

I'm trying to extract a security_token from this response :
{}&&{"containers":{"userID":"p8admin","connected":true,"desktop":"icm"},
"userid":"p8admin",
"user_displayname": "p8admin",
"security_token":"-1829880900612241155",
"messages":[{"adminResponse":null,
"moreInformation":null,
"explanation":null,
"number":"0",
"userResponse":null,
"text":"p8admin connect\u00e9."
}]
}
I've tried combining transform and jsonPath :
.check(bodyString.transform(_.split("&&")(1)).jsonPath("&.security_token").saveAs("security_token"))
but i get this error :
value jsonPath is not a member of com.excilys.ebi.gatling.core.check.MatcherCheckBuilder
Let me know if there is a simple way to achieve this.
Thanks
From the documentation on checks:
This API provides a dedicated DSL for chaining the following steps:
defining the check
extracting
transforming
verifying
saving
Since the response isn't valid JSON, you'll need to use bodyString as the type. You can then transform and then save, but you can't go back to step 1. You can parse the value you need out of the JSON during the transform step.
As Stéphane pointed out, the easiest way to get the value is to use a regex check and extract the security_token value directly, as long as you don't need the rest of your JSON object for any logic.
I have the same problem, I used the regex() function like this :
.check(regex(""""security_token":"(.*)",""").saveAs("security_token"))

Resources