XBMC GetInfoLabels command not working - json

got a quick question about the JSON XBMC API. I want to use the GetInfoLabels command to get a lot of information about the system on my webpage. But I can't figure out how this command works. I tried the following
http://192.168.5.34/jsonrpc?request={"jsonrpc":"2.0","id":"1","method":"XBMC.GetInfoLabels","params":["Network.IPAddress","Network.MacAddress"]}
But then I get this output
{"error":{"code":-32602,"data":{"method":"XBMC.GetInfoLabels","stack":{"message":"Invalid type string received","name":"labels","type":"array"}},"message":"Invalid params."},"id":"1","jsonrpc":"2.0"}
So the error is "Invalid type string received" but I can't get it to work. I tried only 1 label, without the quotes, between extra {}, ... Most of them give a "Parse errro" so I think this is the best I could get it. ANy one got an idea how to use this command?
Thanks

Ok, after a lot of research it seems I had to make an object of an array of labels. So this is the working solution
http://192.168.5.34/jsonrpc?request={"jsonrpc":"2.0","method":"XBMC.GetInfoLabels","params":{"labels": ["Network.IPAddress","Network.MacAddress"] },"id":1}
As a result you get the IP and MAC from the XBMC system.

Related

unable to unrar when the syntax built from function

I work in google colab, I've got an error with this code...
I have so many rar files, and I need to unpack them, those are in different path and I made a function in to simplify my work. I made variables those are changeable so I can replace the path to something else, unfortunately the result says No file extracted or asking me a password even I have true password it doesn't wanna stop asking
type hereaddress = "/content/temporary/myfile.rar"
foldestny = "/content/hasilekstrak"
ps ="pass2345"
def rara(adrs, fdstn, pswrd):
!unrar x "$adrs" "$dstn" "-p$psward"
rara(address, foldestny, ps)
however if I type the code in singgle line, it will work.
why does this happen?
I hope I can make a function to extract anything when I need, so simple by typing variables

JSON error with Julia Dash simple example

I've been trying to replicate the "A simple example" posted at https://dash-julia.plotly.com/clientside-callbacks
The server runs... but when I connect to it I get a JSON parse error in Firefox.
I was able to solve the problem, but I'd like to understand what's wrong...
The problem was this line inside the Dash app.layout:
options=[(label = country, value = country) for country in available_countries]
and the available_countries variable was obatined from:
read_remote_csv(url) = DataFrame(CSV.File(HTTP.get(url).body))
df = read_remote_csv("https://raw.githubusercontent.com/plotly/datasets/master/gapminderDataFiveYear.csv")
available_countries = unique(df.country)
Apparently the error showed because available_countries was an Array{String31,1}: and specifically the problem was the String31 type.
when I converted the variable to a plain String type:
available_countries = convert(Array{String,1},available_countries)
the problem solved.
Now... I'm not sure if the String31 type came from the HTTP.get(), CSV.File() or the DataFrame() functions.
I'm assuming the example used to work when it was originally written but it broke with an update...
Can anyone explain where exactly the error originates? Is it a Package version thing? which package? (HTTP, CSV, Dataframes)? How can I avoid it moving on?

Accesing Json data after 'loading' it

With a lot of help from people in this site, I managed to get some Json data from an amazon page. The data, for example, looks like this.
https://jsoneditoronline.org/?id=9ea92643044f4ac88bcc3e76d98425fc
First I have a list of strings which is converted to a string.
script = response.xpath('//script/text()').extract()
#For example, I need the variationValues data
variationValues = re.findall(r'variationValues\" : ({.*?})', ' '.join(script))[0]
Then, in my code, I have this (not a great name, will be changed later)
variationValuesJson = json.loads(variationValues)
variationValuesJson is in fact a dictionary, so doing something like this
variationValues["size_name"][3]
Should return "5.5 M US"
My issue is that, when running the program, I get the string indices must be integers error. Anyone knows whats wrong?
Note: I have tried using 'size_name' instead of "size_name", same error
variationValues["size_name"][3] #this is the raw string which you have converted to variationValuesjson
I think this is not what you actually want.
Your code should be this.
variationValuesJson['size_name'][3] #use variationValuesjson ;)

How to use the key values of a prolog dict in a predicate?

I have a simple question which I'm getting a lot of trouble finding an answer.
I'm building an api that reads json and at the moment it successfully converts the json to a dict with http_read_json_dict. The problem is that, I have no clue how to access the attributes inside the dict and use that that data in a predicate. I tried following the swi-prolog documentation but to no avail... Do you guys know of a way?
I tried this to test read the content of the dict but I get a "key_value expected, found a dict" error. Please don't burn me at the stake:
json contains: [{"task":"learnprolog","dayofmonth":2}]
http_read_json_dict(Request, JSONIn,[json_object(term)]),
X = JSONIn,
format(user_output,"task is: ~p~n",[X.task]),
JSONOut=JSONIn.
But i was really hoping to do something like:
predicate(X):- X.dayofmonth==2,doSomething(X.task);doSomethingElse(X.task).
Thanks a lot for the help!
not sure about the details, without a server setup similar to what you're using... but
?- open_codes_stream(`[{"task":"learnprolog","dayofmonth":"2"}]`,S),json_read_dict(S,[J]),close(S),write(J.dayofmonth).
2
S = <stream>(0x7f5f14304dd0),
J = _G15591{dayofmonth:"2", task:"learnprolog"}.
note the square brackets around J

R - Twitter Extraction - Error in .subset2(x, i, exact=exact)

I am making an R-script to get all of the mentions (#username) of a specific set of users.
My first issue isn't a big deal. I try to work at home, as well as work. At work, the code works fine. At home, I get Error 32 - Could not authenticate you from Oauth. This is using the exact same code, key, secret, token. I have tried resetting my secret key/token, same thing. Not a problem, since I can do remote login, but its frustrating.
The REAL issue here...
I construct a URL (ex: final_url = "https://api.twitter.com/1.1/search/tweets.json?q=#JimFKenney&until=2015-10-25&result_type=recent&count=100")
Then I search twitter for my query of #usernameDesired to get all the comments where they were mentioned.
mentions = GET(final_url, sig)
This works fine, but then I want my data in a usable format so I do...
library(rjson)
#install.packages("jsonlite", repos="http://cran.rstudio.com/")
library(jsonlite)
#install.packages("bit64", repos="http://cran.rstudio.com/")
json = content(mentions)
I then get the following error -
$statuses
Error in .subset2(x, i, exact = exact) : subscript out of bounds
I don't have even the first idea of what can be causing this.
Any help is gratly appreciated.
EDIT 1: For Clarity, I get the error when trying to see what is in json. If I do "json = content(mentions)" that line of code executes fine. I then type "json" to see what is in the variable, and I get the above error that starts with $statuses.