pais_legacy 2.6.11 → 2.6.12

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
  SHA256:
3
- metadata.gz: e55163cae0475afd98711ea8eb61b8ac777c526ea81c6203544fbb2f55086df0
4
- data.tar.gz: 35cba893d1eadd678ee3d2b9656b2a759161c029ab4b1932f2c9736208c03ef5
3
+ metadata.gz: 661d4713fc34b7e67ca8a49d1aaaa308cf803f3bed466f4dcf294d8385b14453
4
+ data.tar.gz: '09eac6e557d924fdeb809028db33697877b8d570ceddda29bf983ac4a429ede5'
5
5
  SHA512:
6
- metadata.gz: 3229db0bc6b6e6e9e8b0cee2bbe3e8b5bf54a46c7044fafc370141305c82fc93df728b42ce691cf5c08b4671a9c4eb35299f2bfb60caa637a077c1d65fdeeb59
7
- data.tar.gz: eb96fa38afeafd42c4e276433825fb00be1f4fdd01a543bef620fbd94ce9e1831ed2153213c0b2714a6cdaf21d8d969c4213b2958da76f5496858cb091bb2f1b
6
+ metadata.gz: 892be86aa2d46c83860fd59f5ea5627d55ca208115465ed6d78f43a1dcac2b530ac0690ea5531a5da5fce468d669a88d7ceb4a12821b51e94ce6c9852c346c56
7
+ data.tar.gz: cc1d69f67578dfe7767895c7f6c17886886f43a9319437e12fa034a1e870df3656a165b84cc568f963355e41e45a006c7ce005ec57e6c5d138fd0d1eae2f25eb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pais_legacy (2.6.9)
4
+ pais_legacy (2.6.11)
5
5
  net-ssh
6
6
  pastel (~> 0.8)
7
7
 
@@ -10,37 +10,39 @@ GEM
10
10
  specs:
11
11
  ast (2.4.2)
12
12
  byebug (11.1.3)
13
- json (2.6.3)
14
- minitest (5.18.1)
13
+ json (2.9.1)
14
+ language_server-protocol (3.17.0.4)
15
+ minitest (5.25.4)
15
16
  mocha (1.16.1)
16
- net-ssh (7.2.1)
17
- parallel (1.23.0)
18
- parser (3.2.2.3)
17
+ net-ssh (7.3.0)
18
+ parallel (1.26.3)
19
+ parser (3.3.7.0)
19
20
  ast (~> 2.4.1)
20
21
  racc
21
22
  pastel (0.8.0)
22
23
  tty-color (~> 0.5)
23
- racc (1.7.0)
24
+ racc (1.8.1)
24
25
  rainbow (3.1.1)
25
- rake (13.0.6)
26
- regexp_parser (2.8.1)
27
- rexml (3.2.5)
28
- rubocop (1.52.1)
26
+ rake (13.2.1)
27
+ regexp_parser (2.10.0)
28
+ rubocop (1.71.1)
29
29
  json (~> 2.3)
30
+ language_server-protocol (>= 3.17.0)
30
31
  parallel (~> 1.10)
31
- parser (>= 3.2.2.3)
32
+ parser (>= 3.3.0.2)
32
33
  rainbow (>= 2.2.2, < 4.0)
33
- regexp_parser (>= 1.8, < 3.0)
34
- rexml (>= 3.2.5, < 4.0)
35
- rubocop-ast (>= 1.28.0, < 2.0)
34
+ regexp_parser (>= 2.9.3, < 3.0)
35
+ rubocop-ast (>= 1.38.0, < 2.0)
36
36
  ruby-progressbar (~> 1.7)
37
- unicode-display_width (>= 2.4.0, < 3.0)
38
- rubocop-ast (1.29.0)
39
- parser (>= 3.2.1.0)
37
+ unicode-display_width (>= 2.4.0, < 4.0)
38
+ rubocop-ast (1.38.0)
39
+ parser (>= 3.3.1.0)
40
40
  ruby-progressbar (1.13.0)
41
- timecop (0.9.6)
41
+ timecop (0.9.10)
42
42
  tty-color (0.6.0)
43
- unicode-display_width (2.4.2)
43
+ unicode-display_width (3.1.4)
44
+ unicode-emoji (~> 4.0, >= 4.0.4)
45
+ unicode-emoji (4.0.4)
44
46
 
45
47
  PLATFORMS
46
48
  x86_64-linux
@@ -55,4 +57,4 @@ DEPENDENCIES
55
57
  timecop (~> 0.9)
56
58
 
57
59
  BUNDLED WITH
58
- 2.2.28
60
+ 2.6.3
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaisLegacy
4
- VERSION = "2.6.11"
4
+ VERSION = "2.6.12"
5
5
  end
data/lib/pais_legacy.rb CHANGED
@@ -18,6 +18,9 @@ module PaisLegacy
18
18
  SERVER="pais.com.au"
19
19
  USER="map7"
20
20
  KEY="/home/map7/.ssh/id_rsa"
21
+
22
+ MAX_RETRIES = 5
23
+ RETRY_DELAY = 1 # seconds
21
24
 
22
25
  SUSPENSE_ACCOUNT=1599
23
26
  CLEARING_ACCOUNT=5199
@@ -29,40 +32,67 @@ module PaisLegacy
29
32
 
30
33
  def self.execute_ssh_command(command)
31
34
  output = ""
32
-
33
- # Start an SSH session
34
- Net::SSH.start(SERVER,USER,keys: [KEY]) do |ssh|
35
- # Open a new SSH channel
36
- ssh.open_channel do |channel|
37
- # Request a pseudo-tty
38
- channel.request_pty do |ch, success|
39
- raise "Could not obtain pty" unless success
40
-
41
- # Execute the command
42
- ch.exec(command) do |ch, success|
43
- raise "Could not execute command" unless success
44
-
45
- # Collect the data received from the command's standard output
46
- ch.on_data do |c, data|
47
- output += data
48
- end
49
-
50
- # Collect the data received from the command's standard error
51
- ch.on_extended_data do |c, type, data|
52
- output += "stderr: #{data}"
53
- end
54
-
55
- ch.on_close do
56
- puts "Command execution finished"
35
+ retries = 0
36
+
37
+ begin
38
+
39
+ # Start an SSH session
40
+ Net::SSH.start(SERVER,USER,keys: [KEY]) do |ssh|
41
+ # Open a new SSH channel
42
+ ssh.open_channel do |channel|
43
+ # Request a pseudo-tty
44
+ channel.request_pty do |ch, success|
45
+ raise "Could not obtain pty" unless success
46
+
47
+ # Execute the command
48
+ ch.exec(command) do |ch, success|
49
+ raise "Could not execute command" unless success
50
+
51
+ # Collect the data received from the command's standard output
52
+ ch.on_data do |c, data|
53
+ output += data
54
+ end
55
+
56
+ # Collect the data received from the command's standard error
57
+ ch.on_extended_data do |c, type, data|
58
+ output += "stderr: #{data}"
59
+ end
60
+
61
+ ch.on_close do
62
+ puts "Command execution finished"
63
+ end
57
64
  end
58
65
  end
59
66
  end
67
+
68
+ # Keep the session open until the command execution is finished
69
+ ssh.loop
60
70
  end
61
71
 
62
- # Keep the session open until the command execution is finished
63
- ssh.loop
64
- end
72
+ rescue Net::SSH::ConnectionTimeout => e
73
+ retries += 1
74
+ if retries <= MAX_RETRIES
75
+ puts "Connection timed out, retrying (#{retries}/#{MAX_RETRIES})..."
76
+ sleep RETRY_DELAY
77
+ retry
78
+ else
79
+ puts "Max retries reached. Could not connect."
80
+ end
65
81
 
82
+ rescue Errno::ECONNRESET => e
83
+ retries += 1
84
+ if retries <= MAX_RETRIES
85
+ puts "Connection reset by peer, retrying (#{retries}/#{MAX_RETRIES})..."
86
+ sleep RETRY_DELAY
87
+ retry
88
+ else
89
+ puts "Max retries reached. Could not connect."
90
+ end
91
+
92
+ rescue StandardError => e
93
+ puts "An error occurred: #{e.message}"
94
+ end
95
+
66
96
  output
67
97
  end
68
98
 
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pais_legacy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.11
4
+ version: 2.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Pope
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-09-23 00:00:00.000000000 Z
10
+ date: 2025-02-04 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: pastel
@@ -61,7 +60,6 @@ licenses:
61
60
  - MIT
62
61
  metadata:
63
62
  homepage_uri: https://github.com/map7/pais_legacy
64
- post_install_message:
65
63
  rdoc_options: []
66
64
  require_paths:
67
65
  - lib
@@ -76,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
74
  - !ruby/object:Gem::Version
77
75
  version: '0'
78
76
  requirements: []
79
- rubygems_version: 3.5.16
80
- signing_key:
77
+ rubygems_version: 3.6.3
81
78
  specification_version: 4
82
79
  summary: PAIS Legacy API Wrapper
83
80
  test_files: []