-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSudo.R
36 lines (26 loc) · 878 Bytes
/
Sudo.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
###
# Same as the AddData.R example, but this time add the data
# for (ie. impersonating) another user.
###
library(romero.gateway)
# Load "Iris" example dataset
library(datasets)
data("iris")
data.frame(iris)
# Connect to server
server <- OMEROServer(host = "localhost", username = "xx", password = "xx", port = as.integer(4064))
server <- connect(server)
# 'Impersonate' another user (so that he will be the owner
# of the attached data)
server <- sudo(server, 'john', 'lab-1')
# Load an image (the 'impersonated' user must have read/write access)
imageId <- 1
image <- loadObject(server, "ImageData", imageId)
# Attach the dataframe to the image.
invisible(attachDataframe(image, iris, "Iris Example dataset"))
# To carry on again as the original logged in user,
# disable the 'sudo' context again:
server <- sudo(server, NA)
# ...
# Disconnect
disconnect(server)