pampa_workers 1.1.34 → 1.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dbc2b6257c0445e17e467fdefbe07287edb7826
4
- data.tar.gz: f8c8e793e86d1edd41bbed035264e0a87295a6a0
3
+ metadata.gz: acfb10a1b7c85ff28da7bd78336fb50bd1bab2fd
4
+ data.tar.gz: 88b45ef4d3e3766cc6e6fb5cab4de98aed251196
5
5
  SHA512:
6
- metadata.gz: cf98374841d9f711ca46b5a7a537899d49abbfbd22489f3b9a5a646d8128bc012750b1e9fe2993576a7387f5ab705e5b4b13c5c624d187f054403fd8a675c6b0
7
- data.tar.gz: 581b24c2101a8a9c5315906fb61ba0c98ec0bb2c80aa228080217faddf40fb23b67f52d2221172743957a4144d16375a442b2a439ef0a01d28f673ba60a17d0c
6
+ metadata.gz: 12257f58a67f506832dcd5907b7eccf3b710b03d729955f05774ca9c0c4d1160c0d87487514691e2618b9cda2de735bc9aba18e6bf59764b3dacd049ab52ca3c
7
+ data.tar.gz: 3ddb29b711b144b64d0fa0801c059940976a7925bb6b28015c6bdd1bf26d3897df08be076cb12fcd9b9171d9a0521349410e6a7392d6486f681dd21dee5f4062
data/lib/client.rb CHANGED
@@ -30,6 +30,7 @@ module BlackStack
30
30
  end
31
31
 
32
32
  # returns the hosts belong this client
33
+ # TODO: deprecated
33
34
  def own_hosts()
34
35
  BlackStack::LocalHost.where(:id_client=>self.id, :delete_time=>nil)
35
36
  end
@@ -4,6 +4,6 @@ module BlackStack
4
4
  # en cada iteracion saluda a la central (hello), obtiene parametros (get)
5
5
  class MyChildProcess < BlackStack::MyProcess
6
6
 
7
- end # MyChildProcess
7
+ end # class MyChildProcess
8
8
 
9
9
  end # module BlackStack
data/lib/myprocess.rb CHANGED
@@ -27,6 +27,48 @@ module BlackStack
27
27
  self.password = the_password
28
28
  end
29
29
 
30
+ # Sube un registro a la tabla boterrorlog, con el id del worker, el proceso asignado, on id de objeto relacionado (opcional) y un screenshot (opcional).
31
+ #
32
+ # uid: id de un registro en la tabla lnuser.
33
+ # description: backtrace de la excepcion.
34
+ #
35
+ def notifyError(uid, description, oid=nil, screenshot_file=nil)
36
+ # subo el error
37
+ nTries = 0
38
+ bSuccess = false
39
+ parsed = nil
40
+ sError = ""
41
+ while (nTries < 5 && bSuccess == false)
42
+ begin
43
+ nTries = nTries + 1
44
+ url = "#{BlackStack::Pampa::api_protocol}://#{self.ws_url}:#{self.ws_port}/api1.3/bots/boterror.json"
45
+ res = BlackStack::Netting::call_post(url, # TODO: migrar a RestClient para poder hacer file upload
46
+ 'api_key' => BlackStack::Pampa::api_key,
47
+ 'id_lnuser' => uid,
48
+ 'id_object' => oid,
49
+ 'worker_name' => PROCESS.fullWorkerName,
50
+ 'process' => PROCESS.worker.assigned_process,
51
+ 'description' => description,
52
+ 'screenshot' => screenshot_file,
53
+ )
54
+ parsed = JSON.parse(res.body)
55
+ if (parsed['status']=='success')
56
+ bSuccess = true
57
+ else
58
+ sError = parsed['status']
59
+ end
60
+ rescue Errno::ECONNREFUSED => e
61
+ sError = "Errno::ECONNREFUSED:" + e.to_console
62
+ rescue => e2
63
+ sError = "Exception:" + e2.to_console
64
+ end
65
+ end # while
66
+
67
+ if (bSuccess==false)
68
+ raise "#{sError}"
69
+ end
70
+ end
71
+
30
72
  # retrieves the id of the current process
31
73
  def pid()
32
74
  Process.pid.to_s
@@ -109,11 +151,11 @@ module BlackStack
109
151
  def set(new_assigned_process, new_id_client)
110
152
  if (self.ws_url.to_s.size > 0 && self.ws_port.to_s.size > 0)
111
153
  url = "#{BlackStack::Pampa::api_protocol}://#{self.ws_url.to_s}:#{self.ws_port.to_s}/api1.3/pampa/notify.json"
112
- puts
113
- puts
114
- puts "url: #{url}"
115
- puts
116
- puts
154
+ #puts
155
+ #puts
156
+ #puts "url: #{url}"
157
+ #puts
158
+ #puts
117
159
  res = BlackStack::Netting::call_post(url, {
118
160
  'api_key' => BlackStack::Pampa::api_key,
119
161
  'name' => self.fullWorkerName,
@@ -127,11 +169,11 @@ puts
127
169
  def get()
128
170
  # me notifico a la central. obtengo asignacion que tenga
129
171
  url = "#{BlackStack::Pampa::api_url}/api1.3/pampa/get.json"
130
- puts
131
- puts
132
- puts "url: #{url}"
133
- puts
134
- puts
172
+ #puts
173
+ #puts
174
+ #puts "url: #{url}"
175
+ #puts
176
+ #puts
135
177
  res = BlackStack::Netting::call_post(url, {
136
178
  'api_key' => BlackStack::Pampa::api_key,
137
179
  'name' => self.fullWorkerName }.merge( BlackStack::RemoteHost.new.poll )
@@ -219,11 +261,11 @@ puts
219
261
 
220
262
  # me notifico a la division. obtengo trabajo
221
263
  url = "#{BlackStack::Pampa::api_protocol}://#{self.ws_url}:#{self.ws_port}/api1.3/pampa/notify.json"
222
- puts
223
- puts
224
- puts "url: #{url}"
225
- puts
226
- puts
264
+ #puts
265
+ #puts
266
+ #puts "url: #{url}"
267
+ #puts
268
+ #puts
227
269
  res = BlackStack::Netting::call_post(url,
228
270
  {
229
271
  'api_key' => BlackStack::Pampa::api_key,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pampa_workers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.34
4
+ version: 1.1.37
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: 2022-02-28 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: websocket