annotate UrlRequestScheduler.R @ 5:fb9c0409d85c draft

planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
author prog
date Wed, 19 Apr 2017 10:00:05 -0400
parents 20d69a062da3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
1 if ( ! exists('UrlRequestScheduler')) { # Do not load again if already loaded
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
2
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
3 #############
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
4 # CONSTANTS #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
5 #############
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
6
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
7 RLIB.GET <- 'GET'
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
8 RLIB.POST <- 'POST'
0
e66bb061af06 planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 3529b25417f8e1a5836474c9adec4b696d35099d-dirty
prog
parents:
diff changeset
9
5
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
10 #####################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
11 # CLASS DECLARATION #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
12 #####################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
13
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
14 UrlRequestScheduler <- setRefClass("UrlRequestScheduler", fields = list(.n = "numeric", .t = "numeric", .time.of.last.request = "ANY", .useragent = "character", .ssl.verifypeer = "logical", .nb.max.tries = "integer", .verbose = "integer"))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
15
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
16 # n: number of connections
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
17 # t: time (in seconds)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
18
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
19 # The scheduler restrict the number of connections at n per t seconds.
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
20
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
21 ###############
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
22 # CONSTRUCTOR #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
23 ###############
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
24
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
25 UrlRequestScheduler$methods( initialize = function(n = 1, t = 1, useragent = NA_character_, ssl.verifypeer = TRUE, ...) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
26 .n <<- n
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
27 .t <<- t
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
28 .time.of.last.request <<- -1
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
29 .useragent <<- useragent
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
30 .nb.max.tries <<- 10L
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
31 .ssl.verifypeer <<- ssl.verifypeer
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
32 .verbose <<- 0L
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
33 callSuper(...) # calls super-class initializer with remaining parameters
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
34 })
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
35
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
36 ##################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
37 # SET USER AGENT #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
38 ##################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
39
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
40 UrlRequestScheduler$methods( setUserAgent = function(useragent) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
41 .useragent <<- useragent
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
42 })
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
43
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
44 ###############
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
45 # SET VERBOSE #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
46 ###############
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
47
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
48 UrlRequestScheduler$methods( setVerbose = function(verbose) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
49 .verbose <<- verbose
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
50 })
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
51
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
52 ##################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
53 # WAIT AS NEEDED #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
54 ##################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
55
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
56 # Wait the specified between two requests.
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
57 UrlRequestScheduler$methods( .wait.as.needed = function() {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
58
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
59 # Compute minimum waiting time between two URL requests
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
60 waiting_time <- .self$.t / .self$.n
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
61
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
62 # Wait, if needed, before previous URL request and this new URL request.
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
63 if (.self$.time.of.last.request > 0) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
64 spent_time <- Sys.time() - .self$.time.of.last.request
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
65 if (spent_time < waiting_time)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
66 Sys.sleep(waiting_time - spent_time)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
67 }
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
68
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
69 # Store current time
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
70 .time.of.last.request <<- Sys.time()
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
71 })
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
72
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
73 ####################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
74 # GET CURL OPTIONS #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
75 ####################
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
76
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
77 UrlRequestScheduler$methods( .get_curl_opts = function(url) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
78 opts <- curlOptions(useragent = .self$.useragent, timeout.ms = 60000, verbose = FALSE)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
79 return(opts)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
80 })
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
81
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
82 ###########
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
83 # GET URL #
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
84 ###########
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
85
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
86 UrlRequestScheduler$methods( .doGetUrl = function(url, params = NULL, method = RLIB.GET) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
87
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
88 content <- NA_character_
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
89
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
90 # Use form to send URL request
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
91 if ( ! is.null(params) && ! is.na(params))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
92 switch(method,
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
93 GET = { content <- getForm(url, .opts = .self$.get_curl_opts(), .params = params) },
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
94 POST = { content <- postForm(url, .opts = .self$.get_curl_opts(), .params = params) },
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
95 stop(paste('Unknown method "', method, '".'))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
96 )
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
97
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
98 # Get URL normally
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
99 else
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
100 content <- getURL(url, .opts = .self$.get_curl_opts(), ssl.verifypeer = .self$.ssl.verifypeer)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
101
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
102 return(content)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
103 })
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
104
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
105 UrlRequestScheduler$methods( getUrl = function(url, params = NULL, method = RLIB.GET) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
106
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
107 # Load library here and not inside .doGetUrl() since it is called from inside a try/catch clause, hence if library is missing the error will be ignored.
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
108 library(bitops)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
109 library(RCurl)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
110
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
111 content <- NA_character_
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
112
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
113 # Wait required time between two requests
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
114 .self$.wait.as.needed()
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
115
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
116 # Run query
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
117 for (i in seq(.self$.nb.max.tries)) {
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
118 tryCatch({ content <- .self$.doGetUrl(url, params = params, method = method) },
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
119 error = function(e) { if (.self$.verbose > 0) print("Retry connection to server...") } )
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
120 if ( ! is.na(content))
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
121 break
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
122 }
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
123
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
124 return(content)
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
125 })
fb9c0409d85c planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 608d9e59a0d2dcf85a037968ddb2c61137fb9bce
prog
parents: 2
diff changeset
126 }