mass-client 1.0.20 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/first-line/profile_rpa.rb +61 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ee4e0f04af40b7fb0a7e26fedb26ec7fa3d76602baec49add355f620940c9b0
4
- data.tar.gz: 73fa2542b417954bedc8352420b131d81dbaeea82dacca0e43dffd96002728b4
3
+ metadata.gz: 89942512c664d6c1e10f0511db2f17c914a22d4b5b80d6b50fa4151c17997304
4
+ data.tar.gz: c7dc604ffa10a35ed2f1e74377d73a7402a2714b3c554c086c91216f867fccb7
5
5
  SHA512:
6
- metadata.gz: 458fd9aa4929a889264c7e90b69b856e8272ee9ed26106243e64dca225ece4ec847a91b0d536036c10d8f0a43525adf6922f88587e35de8963f40fc11d2b35f7
7
- data.tar.gz: a20f0ce501ed952360e071a696fc39e0c060c18a5d8d89af7cea557709f0296db2700f79152e63430766e870b1ba2e66d811bc9c116635e7cccf82a340e460c6
6
+ metadata.gz: b1480e0a4e9f4b414a7bec3148ee96c8611e2f44fd3b7dde949e296be04a4b3ab0354f485dfa964546ec40e1e15876612cfca54781073d8dcc104ad932205e1a
7
+ data.tar.gz: 6abc1702733af395df62d3c8ff01b1d2c701f337d32427bfb77b59ea4ebff591f87ab39690fb3943d87a77f2e7560a96f4aedbfb045ac69d08156734d6fd2bfd
@@ -175,7 +175,23 @@ module Mass
175
175
  automaticDownloads.find_element(:id => status.to_s).click()
176
176
  end # def automatic_downloads
177
177
 
178
-
178
+ # Waits for the presence of a file in specified file paths within a given timeout period.
179
+ # This function checks each file path in the provided array and returns the path of the
180
+ # first file it finds to exist. It raises an exception if none of the files are found
181
+ # within the specified timeout.
182
+ #
183
+ # @param file_paths [Array<String>] An array of file paths to check for the file's existence.
184
+ # @param timeout [Integer] The maximum number of seconds to wait for the file to appear.
185
+ # Default is 30 seconds.
186
+ #
187
+ # @return [String] The path of the first file found in `file_paths`.
188
+ # @raise [RuntimeError] If no file is found within the specified timeout, raises an error with a message
189
+ # listing the paths that were checked and the timeout duration.
190
+ #
191
+ # @example
192
+ # wait_for_file(['/path/to/file1', '/path/to/file2'], timeout: 60)
193
+ # # => "/path/to/file1" (if the file appears within 60 seconds)
194
+ #
179
195
  def wait_for_file(file_paths, timeout = 30)
180
196
  Timeout.timeout(timeout) do
181
197
  loop do
@@ -189,6 +205,45 @@ module Mass
189
205
  raise "Downloaded file not found in paths #{file_paths.join(',')} after #{timeout} seconds."
190
206
  end
191
207
 
208
+
209
+ # Retrieves the URL of a file stored in Dropbox with a timeout mechanism.
210
+ # This function continuously attempts to retrieve the file URL until it
211
+ # becomes available in Dropbox, up to a specified maximum wait time.
212
+ #
213
+ # @param path [String] The path to the file in Dropbox.
214
+ # @param max_wait [Integer] Maximum time to wait (in seconds) for the file to
215
+ # appear in Dropbox. Default is 30 seconds.
216
+ # @param interval [Integer] Time interval (in seconds) between each retry
217
+ # attempt. Default is 2 seconds.
218
+ #
219
+ # @return [String] The URL of the file in Dropbox, with the `&dl=1` parameter
220
+ # replaced by `&dl=0`.
221
+ # @raise [RuntimeError] If the file is not available within the specified
222
+ # maximum wait time, raises an error with a timeout message.
223
+ #
224
+ # @example
225
+ # wait_for_dropbox_url('/path/to/file', max_wait: 60, interval: 3)
226
+ # # => "https://www.dropbox.com/s/yourfile?dl=0"
227
+ #
228
+ def wait_for_dropbox_url(path, max_wait: 30, interval: 2)
229
+ start_time = Time.now
230
+
231
+ loop do
232
+ begin
233
+ # Try to get the file URL
234
+ return BlackStack::DropBox.get_file_url(path).gsub('&dl=1', '&dl=0')
235
+ rescue => e
236
+ # Check if the timeout has been exceeded
237
+ if Time.now - start_time > max_wait
238
+ raise "Timeout exceeded while waiting for Dropbox file (#{path}): #{e.message}"
239
+ end
240
+
241
+ # Wait for a short interval before retrying
242
+ sleep(interval)
243
+ end
244
+ end
245
+ end
246
+
192
247
  # download image from Selenium using JavaScript and upload to Dropbox
193
248
  # return the URL of the screenshot
194
249
  #
@@ -274,8 +329,12 @@ module Mass
274
329
  BlackStack::DropBox.dropbox_upload_file(tmp_path, path)
275
330
  # Delete the local file
276
331
  File.delete(tmp_path)
332
+
277
333
  # Return the URL of the file in Dropbox
278
- BlackStack::DropBox.get_file_url(path).gsub('&dl=1', '&dl=0')
334
+ #
335
+ # Add a timeout to wait the file is present in the cloud.
336
+ # Reference: https://github.com/MassProspecting/docs/issues/320
337
+ self.wait_for_dropbox_url(path).gsub('&dl=1', '&dl=0')
279
338
  end
280
339
 
281
340
  # download image from Selenium using JavaScript and upload to Dropbox
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mass-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.20
4
+ version: 1.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leandro Daniel Sardi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-21 00:00:00.000000000 Z
11
+ date: 2024-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: timeout