Rpyc - Is it possible to get the original type back from rypc? - rpyc

I am using Rpyc and have setup a client server model. The server sends Python objects but I’m having trouble working with them on the client side as their types changed (eg a dict won’t be a dict but a netref.something) - is it possible to get the original type back?

Related

R mongolite: correct format for connecting with a Mogodb on a remote server?

I'm writing some R code that queries a MongoDB database, imports records matching the query criteria into R, performs record linkage with another data source, and then pushes the updated records back into MongoDB.
The code needs to work with any instance of the MongoDB database. Some people have it installed as standalone on their own computers, while others have it installed on their organisational servers. Note that these are servers specific to individual organisations and not the public mongo server.
To test my code, I have access to both scenarios - one instance is set up on my own computer, and I have several remote server instances as well.
The MongoDB database has some APIs, but I was struggling with the adapting the APIs to include the correct syntax to form my query, so I thought I would try the mongolite package instead.
I was able to create a successful connection string for the MongoDB instance on my local computer, using my user ID (which I retrieve first with an API and save as the R object myids), password, the localhost and port number as below:
# Load library:
library(mongolite)
# Create connection:
con <- mongolite::mongo(collection = "person",
db = "go-data",
url = paste0("mongodb://localhost:3000",
myids$userid,
":",
rawToChar(password)))
I understood from reading the mongolite user manual that to create the connection string / URI, you skip the http or https part of the address and preface it with either mongodb:// when the Mongodb database is on a local computer, or mongodb+srv:// when the Mongodb database is on a remote server.
However, when I try just changing the prefix and login details for the remote server version, the connection fails. Say the URL for my remote server is https://mydb-r21.orgname.org/ which opens a web page where you can log in to the Mongodb database and interact with it via a graphical user interface. Just swapping localhost:3000 for the web address mydb-r21.orgname.org/ and supplying the relevant login credentials for that server doesn't work:
# Load library:
library(mongolite)
# Create connection:
con <- mongolite::mongo(collection = "person",
db = "go-data",
url = paste0("mongodb+srv://mydb-r21.orgname.org/",
myids$userid,
":",
rawToChar(password)))
When I try, this is the error I get:
Warning: [ERROR] Failed to look up SRV record "_mongodb._tcp.mydb-r21.orgname.org": DNS name does not exist.
Error: Invalid uri_string. Try mongodb://localhost
If I try changing to mongodb::// (not localhost because it isn't hosted locally) I get this:
Error: No suitable servers found (`serverSelectionTryOnce` set): [connection timeout calling hello on 'mydb-r21.orgname.org:27017']
Interestingly, the port that is suffixed in the error message is the correct one that I was expecting, but that still doesn't help me.
The documentation in the mongolite user manual and other places I've found online seem to add some read/write specifications to the connection string, but as I'm not very familiar with how connection strings are constructed, I don't know if these are specific to the databases they are using in their examples. I can't find any clear explanation of what the extra bits that are not part of the URL mean, e.g. as shown in this blog. All the prefixes seem to be a bit different too, so I am not even sure what would be appropriate to try in my case.
Can anyone explain why the connection string works fine with localhost:port number for the local instance, but doesn't work with the URL for the remote server / online instance?
Also what do I need to do to make the URI for the remote server valid?

Problem using ArduinoHTTPClient sending GET requests with ESP32

Board : ESP32 T-Call SIM800L
Code Functioning
Collect Data from phone -> Put Into URL -> Send to Server
CollectQualitativeData() -> AppendQueryParameters() -> http.get(resource)
My code allows me to enter 4 different strings in my android app which my ESP32 receives via bluetooth and stores as an array of char arrays QualArray[4][30] (eg. {"string1","string2"....) . It then adds these strings in the URL query parameters for which I send data to my google sheets web app with a GET request (I know i'm posting data but the get request is what is used for the google apps script when posting data).
Problem
The code works when I pre-define the URL to be sent, although the issue seems to be that adding the strings obtained from the android app to the URL returns an HTTP response of -3 and doesn't upload to the google sheets server. This confuses me as the strings are stored okay because I print them out and they are correct, and then adding them to the URL and printing the URL it looks correct (and identical to the pre-defined URL that works) but for some reason it doesn't work. I thought it could be memory related so I pre-defined all the char arrays with set buffers but still didn't work
Code
https://github.com/Conwon99/4th-Year-Project/blob/main/ESP32_HTTP_REQUEST
The functions to look at are CollectQualitativeData() which is called in setup and AppendQueryParameters() which is called in the loop, then http.get(resource) is called afterwards in the loop which makes the GET request.

Freeswitch Guide how to get CDR UUID from client side

My system contain:
- Freeswitch server
- Sip Client: Web using sipjs , mobile react-native using https://github.com/datso/react-native-pjsip to receive call.
My problem is when call done i need to know the uuid of CDR recently add to Postgres DB of that call to attach some info to that call
I try many way but can not success ex: write http request to select into postgres DB, but can not find exactly which uuid because one extension can make many call one time.
Can anyone help me solve this case?
Mark each call with custom variable like callid
Send that to your app via any method, as sipheader, as sip message, using http post etc.
But you also can just search cdr by start date.

MarkLogic I don't know how to get all the result

Hello I am trying to read a module with this code:
(: Entry point - must be a read-only query. :)
xdmp:invoke(
'/path/mydocument.xqy',
(xs:QName('var1'), 'test',
xs:QName('var2'), "response"))
I am new in MarkLogic, I am using groovy and the api to connect to it, but also I saw I can invoke the module with this and indeed I did but it returns me
your query returned an empty sequence
I want to know if I can query xs:QName('var1'), 'test', changing test with a wildcard or how can I get all the information from the file called /path/mydocument.xqy?
I tried to use this:
xdmp:document-get("/path/mydocument.xqy)
but it says the file is not found. Although, if I use invoke I can query it, but I don't know what are the values I have to pass. I was wondering if there is something like sql using %% or something to give me all the data.
To answer the first question: "I am trying to read a module "
IF the module is in the database, then you must query the Modules database in which the module resides.
If the module is in the filesystem then you cannot directly access its source as a document but you can by executing xdmp:filesystem-file()
Simplification:
With the Default configuration of the server and REST client, user placed modules are in the "Modules" database and user placed documents are in the "Documents" database. This means, if you do a GET (read a "Document") with no additional parameters, it will return documents from the "Documents" database. Assuming you are using the default configuration for client and server, this would result in the behavior you are seeing. E.g. your Module code is in the Modules database, doing a GET for it by name will search the Documents database and correctly not find it.
You don't mention, and I don't know, the groovy library being used, but the REST API itself and all implementations of general purpose ML REST client libraries I am familiar with have options for overriding the default database with another. If the groovy library supports that, then specify the "Modules" database for your query and it should return the module document. Note: content-type will be application/text not text/xml.
You can simplify things for testing by bypassing the libraries and simply use a browser and try a URL like this http://yourserver.com:8000/v1/documents?uri=/your/module.xqy&database=Modules
Ref: https://docs.marklogic.com/REST/GET/v1/documents
Making the appropriate changes to the path and server for your use.
If you are still confused, then you should start with the basic MarkLogic tutorials and work through them one by one. You will most likely succeed faster by doing this then jumping straight into coding you don't understand yet.
DETAIL:
Note: The default behaviour is to EXECUTE documents when doing a GET call, using the Modules database. Thus doing a GET of http://yourserver:8000/your/module.xqy will EXECUTE it not return its source.
You will notice the REST API has a uri query parameter. This is EXECUTING the REST API code on /v1/documents which in turn will read the document specified by the uri and database parameters and return it.
I guess I can use:
xdmp:invoke(/pview/get-pview-browse-profiles.xqy,
cts:and-query((
cts:element-value-query(
xs:QName("letter"),"*", "wildcarded"),
cts:element-value-query(
xs:QName("collection"),"*", "wildcarded"))))
although it doesn't return anything

Trouble with PUT/GET in Riak testing

I'm working on a little e2 application that needs to put/get data
to/from riak. I apparently have a misunderstanding
about some things.
I can successfully put and get key-value pairs to a bucket using the
erlang client. However, when I try to curl the
data out, I get nothing. In fact, doing:
curl -X GET
"http://riak1:8098/riak?buckets=true" returns '{"buckets":[]}'.
Ditto for curl -X GET "http://192.168.29.11:8098/buckets?buckets=true"
In my application, though, I can do this:
8> Object = riakc_obj:new(<<"testbucket">>, <<"testkey">>,
<<"testdata">>). {riakc_obj,<<"testbucket">>,<<"testkey">>,undefined,[],
undefined,<<"testdata">>}
9> riakc_pb_socket:put(Pid, Object).
ok
10> riakc_pb_socket:get(Pid, <<"testbucket">>, <<"testkey">>).
{ok,{riakc_obj,<<"testbucket">>,<<"testkey">>,
<<107,206,97,96,96,96,204,96,202,5,82,28,202,156,255,126,
238,185,94,62,53,131,41,...>>,
[{{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],...}}},
<<"testdata">>}],
undefined,undefined}}
11> riakc_pb_socket:list_buckets(Pid).
{ok,[<<"tb1">>,<<"testbucket">>]}
So what is the difference between the two? How can I use curl (or any
other client) to see the buckets, and retrieve
data?
--
Note that this was also sent to the riak-user mailing list
I figured out what the problem was. I had another instance of Riak running on the machine where my application was running, and the app was defaulting to "localhost" when connecting to Riak, rather than connecting to my test cluster.
The data was written correctly, just to the wrong instance.

Resources