pais_legacy 2.6.15 → 2.6.17
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 +4 -4
- data/Gemfile.lock +13 -13
- data/lib/pais_legacy/version.rb +1 -1
- data/lib/pais_legacy.rb +77 -67
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4bc027926acd33cf21596f062b32a7df8e255025e55ee0d91430efc731b24eaf
|
|
4
|
+
data.tar.gz: 6cdb3bad8eff90e4e092f5ee5b8ac7bfa5157c80e9902ae8eaecf33e96fcfb2b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69c8e7b80e89a51907efeeae410cb387453b46884bc573ba00ea8a488c054f05f954b5801bc19cfc8b9a0aa3c782a6781df1ec23b3ad5e1ed091e55c8c6be849
|
|
7
|
+
data.tar.gz: 1a86989dbb53199054fed3d54bc795595a8c41c4a941c68ca9f41d0bda64c70656302c1afe5ff91ea193d54b999aeb3ef423edb31cd5354379e4190f9ea675dc
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
pais_legacy (2.6.
|
|
4
|
+
pais_legacy (2.6.17)
|
|
5
5
|
net-ssh
|
|
6
6
|
pastel (~> 0.8)
|
|
7
7
|
|
|
@@ -10,24 +10,24 @@ GEM
|
|
|
10
10
|
specs:
|
|
11
11
|
ast (2.4.3)
|
|
12
12
|
byebug (12.0.0)
|
|
13
|
-
json (2.
|
|
13
|
+
json (2.17.1)
|
|
14
14
|
language_server-protocol (3.17.0.5)
|
|
15
15
|
lint_roller (1.1.0)
|
|
16
|
-
minitest (5.
|
|
16
|
+
minitest (5.26.2)
|
|
17
17
|
mocha (1.16.1)
|
|
18
18
|
net-ssh (7.3.0)
|
|
19
19
|
parallel (1.27.0)
|
|
20
|
-
parser (3.3.
|
|
20
|
+
parser (3.3.10.0)
|
|
21
21
|
ast (~> 2.4.1)
|
|
22
22
|
racc
|
|
23
23
|
pastel (0.8.0)
|
|
24
24
|
tty-color (~> 0.5)
|
|
25
|
-
prism (1.
|
|
25
|
+
prism (1.6.0)
|
|
26
26
|
racc (1.8.1)
|
|
27
27
|
rainbow (3.1.1)
|
|
28
|
-
rake (13.3.
|
|
29
|
-
regexp_parser (2.
|
|
30
|
-
rubocop (1.
|
|
28
|
+
rake (13.3.1)
|
|
29
|
+
regexp_parser (2.11.3)
|
|
30
|
+
rubocop (1.81.7)
|
|
31
31
|
json (~> 2.3)
|
|
32
32
|
language_server-protocol (~> 3.17.0.2)
|
|
33
33
|
lint_roller (~> 1.1.0)
|
|
@@ -35,18 +35,18 @@ GEM
|
|
|
35
35
|
parser (>= 3.3.0.2)
|
|
36
36
|
rainbow (>= 2.2.2, < 4.0)
|
|
37
37
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
38
|
-
rubocop-ast (>= 1.
|
|
38
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
39
39
|
ruby-progressbar (~> 1.7)
|
|
40
40
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
41
|
-
rubocop-ast (1.
|
|
41
|
+
rubocop-ast (1.48.0)
|
|
42
42
|
parser (>= 3.3.7.2)
|
|
43
43
|
prism (~> 1.4)
|
|
44
44
|
ruby-progressbar (1.13.0)
|
|
45
45
|
timecop (0.9.10)
|
|
46
46
|
tty-color (0.6.0)
|
|
47
|
-
unicode-display_width (3.
|
|
48
|
-
unicode-emoji (~> 4.
|
|
49
|
-
unicode-emoji (4.0
|
|
47
|
+
unicode-display_width (3.2.0)
|
|
48
|
+
unicode-emoji (~> 4.1)
|
|
49
|
+
unicode-emoji (4.1.0)
|
|
50
50
|
|
|
51
51
|
PLATFORMS
|
|
52
52
|
x86_64-linux
|
data/lib/pais_legacy/version.rb
CHANGED
data/lib/pais_legacy.rb
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
require 'date'
|
|
4
4
|
require 'json' # Output
|
|
5
|
-
require
|
|
5
|
+
require 'open3' # File I/O
|
|
6
6
|
require 'pastel' # TTY Color
|
|
7
7
|
require 'net/ssh'
|
|
8
|
-
require 'byebug' unless ENV[
|
|
8
|
+
require 'byebug' unless ENV['RACK_ENV'] == 'production' or ENV['RAILS_ENV'] == 'production'
|
|
9
9
|
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
10
|
+
require_relative 'pais_legacy/trial_balance'
|
|
11
|
+
require_relative 'pais_legacy/version'
|
|
12
12
|
|
|
13
13
|
module PaisLegacy
|
|
14
14
|
class Error < StandardError; end
|
|
15
15
|
|
|
16
16
|
class Pais
|
|
17
|
-
#SERVER=
|
|
18
|
-
SERVER=
|
|
19
|
-
USER=
|
|
20
|
-
KEY=
|
|
17
|
+
#SERVER='192.168.200.4'
|
|
18
|
+
SERVER='pais.com.au'
|
|
19
|
+
USER='map7'
|
|
20
|
+
KEY='/home/map7/.ssh/id_rsa'
|
|
21
21
|
|
|
22
22
|
MAX_RETRIES = 5
|
|
23
23
|
RETRY_DELAY = 1 # seconds
|
|
@@ -31,36 +31,50 @@ module PaisLegacy
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def self.execute_ssh_command(command)
|
|
34
|
-
|
|
34
|
+
stdout = ''
|
|
35
|
+
stderr = ''
|
|
36
|
+
exit_status = nil
|
|
35
37
|
retries = 0
|
|
36
38
|
|
|
37
39
|
begin
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
stdout = ''
|
|
41
|
+
stderr = ''
|
|
42
|
+
exit_status = nil
|
|
43
|
+
|
|
44
|
+
# Start an SSH session.
|
|
45
|
+
#
|
|
46
|
+
# No pty is requested, deliberately. A pty merges the remote stderr
|
|
47
|
+
# into stdout, so any notice from the remote side (a `docker compose`
|
|
48
|
+
# "variable is not set" WARN, an ANSI colour code, a 4GL error) lands
|
|
49
|
+
# in the middle of the JSON we are about to parse. A pty also sets
|
|
50
|
+
# SSH_TTY, which makes the remote `fglgo` wrapper take its interactive
|
|
51
|
+
# branch: it names the 4GL container after the tty number and stops
|
|
52
|
+
# whatever already holds that name, so two callers landing on the same
|
|
53
|
+
# recycled tty number collide with each other.
|
|
40
54
|
Net::SSH.start(SERVER,USER,keys: [KEY]) do |ssh|
|
|
41
55
|
# Open a new SSH channel
|
|
42
56
|
ssh.open_channel do |channel|
|
|
43
|
-
#
|
|
44
|
-
channel.
|
|
45
|
-
raise
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
ch.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
# Execute the command
|
|
58
|
+
channel.exec(command) do |ch, success|
|
|
59
|
+
raise 'Could not execute command' unless success
|
|
60
|
+
|
|
61
|
+
# Collect the data received from the command's standard output
|
|
62
|
+
ch.on_data do |c, data|
|
|
63
|
+
stdout += data
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Collect the data received from the command's standard error,
|
|
67
|
+
# kept apart from stdout so it cannot corrupt the payload
|
|
68
|
+
ch.on_extended_data do |c, type, data|
|
|
69
|
+
stderr += data
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
ch.on_request('exit-status') do |c, data|
|
|
73
|
+
exit_status = data.read_long
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
ch.on_close do
|
|
77
|
+
puts 'Command execution finished' if ENV['DEBUG'] == 'true'
|
|
64
78
|
end
|
|
65
79
|
end
|
|
66
80
|
end
|
|
@@ -69,31 +83,27 @@ module PaisLegacy
|
|
|
69
83
|
ssh.loop
|
|
70
84
|
end
|
|
71
85
|
|
|
72
|
-
rescue Net::SSH::ConnectionTimeout => e
|
|
86
|
+
rescue Net::SSH::ConnectionTimeout, Errno::ECONNRESET => e
|
|
73
87
|
retries += 1
|
|
74
88
|
if retries <= MAX_RETRIES
|
|
75
|
-
puts "
|
|
89
|
+
puts "#{e.class}, retrying (#{retries}/#{MAX_RETRIES})..." if ENV['DEBUG'] == 'true'
|
|
76
90
|
sleep RETRY_DELAY
|
|
77
91
|
retry
|
|
78
|
-
else
|
|
79
|
-
puts "Max retries reached. Could not connect." if ENV['DEBUG'] == 'true'
|
|
80
92
|
end
|
|
93
|
+
raise Error, "#{command}: #{e.class} after #{MAX_RETRIES} retries"
|
|
94
|
+
end
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
retry
|
|
88
|
-
else
|
|
89
|
-
puts "Max retries reached. Could not connect." if ENV['DEBUG'] == 'true'
|
|
90
|
-
end
|
|
96
|
+
# Fail loudly rather than handing back a partial or empty payload for
|
|
97
|
+
# the caller to trip over in JSON.parse.
|
|
98
|
+
unless exit_status.nil? || exit_status.zero?
|
|
99
|
+
raise Error, "#{command} exited #{exit_status}: #{stderr.strip}"
|
|
100
|
+
end
|
|
91
101
|
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
if stdout.empty? && !stderr.empty?
|
|
103
|
+
raise Error, "#{command} produced no output: #{stderr.strip}"
|
|
94
104
|
end
|
|
95
105
|
|
|
96
|
-
|
|
106
|
+
stdout
|
|
97
107
|
end
|
|
98
108
|
|
|
99
109
|
# delegate :execute_ssh_command, to: :class
|
|
@@ -103,9 +113,9 @@ module PaisLegacy
|
|
|
103
113
|
# --------------------------------------------------------------------------------
|
|
104
114
|
def self.clfi_read_cmd(client=nil)
|
|
105
115
|
if client
|
|
106
|
-
pais_api(
|
|
116
|
+
pais_api('clfi_read ','10000',client)
|
|
107
117
|
else
|
|
108
|
-
pais_api(
|
|
118
|
+
pais_api('clfi_read ','10000')
|
|
109
119
|
end
|
|
110
120
|
end
|
|
111
121
|
|
|
@@ -119,9 +129,9 @@ module PaisLegacy
|
|
|
119
129
|
# --------------------------------------------------------------------------------
|
|
120
130
|
def self.glfi_read_cmd(ledger=nil)
|
|
121
131
|
if ledger
|
|
122
|
-
pais_api(
|
|
132
|
+
pais_api('glfi_read',ledger)
|
|
123
133
|
else
|
|
124
|
-
pais_api(
|
|
134
|
+
pais_api('glfi_read')
|
|
125
135
|
end
|
|
126
136
|
end
|
|
127
137
|
|
|
@@ -136,16 +146,16 @@ module PaisLegacy
|
|
|
136
146
|
# Accounts
|
|
137
147
|
# --------------------------------------------------------------------------------
|
|
138
148
|
def self.glch_read_cmd(ledger)
|
|
139
|
-
pais_api(
|
|
149
|
+
pais_api('glch_read',ledger)
|
|
140
150
|
end
|
|
141
151
|
|
|
142
152
|
def self.glch_read(ledger)
|
|
143
153
|
# out=execute_ssh_command(glch_read_cmd(ledger.to_s))
|
|
144
154
|
# out.
|
|
145
|
-
# split(
|
|
146
|
-
# map{|line| line.split(
|
|
155
|
+
# split('\n').
|
|
156
|
+
# map{|line| line.split(',')}.
|
|
147
157
|
# map{|line| {value: line[0], text: "#{line[0]}-#{line[1]}"}}
|
|
148
|
-
glch_read_all(ledger)[
|
|
158
|
+
glch_read_all(ledger)['accounts'].map {|h| {value: h['code'], text: "#{h['code']}-#{h['description']}"}}
|
|
149
159
|
end
|
|
150
160
|
|
|
151
161
|
def self.glch_read_all(ledger)
|
|
@@ -156,21 +166,21 @@ module PaisLegacy
|
|
|
156
166
|
|
|
157
167
|
|
|
158
168
|
# SCREEN T1 10000 1 999999 0 0 0 001 0 9999 0 9999 0 3 N Y N 5200 6153 1 6110 6 A 1 30/06/2023
|
|
159
|
-
def self.raw(params,program=
|
|
169
|
+
def self.raw(params,program='rdefi00a')
|
|
160
170
|
params = params.gsub(" "," \\")
|
|
161
171
|
|
|
162
172
|
# cmd = ssh + ' "bash -c \"'+ fglgo("rptrun") +' pgs 1 pais '+program+' \''+ params + ' \' \""'
|
|
163
|
-
cmd = fglgo(
|
|
173
|
+
cmd = fglgo('rptrun') +' api 1 pais '+program+' \''+ params + ' \' '
|
|
164
174
|
|
|
165
175
|
out=execute_ssh_command(cmd)
|
|
166
176
|
[out]
|
|
167
177
|
end
|
|
168
178
|
|
|
169
|
-
def self.raw_zsh(params,program=
|
|
179
|
+
def self.raw_zsh(params,program='rdefi00a')
|
|
170
180
|
params = params.gsub(" "," \\")
|
|
171
181
|
|
|
172
182
|
cmd = 'zsh -c "'+ fglgo("rptrun") +' api 1 pais '+program+' \''+ params + ' \' "'
|
|
173
|
-
stdout,
|
|
183
|
+
stdout, _stderr, _status = Open3.capture3(cmd)
|
|
174
184
|
[stdout]
|
|
175
185
|
end
|
|
176
186
|
|
|
@@ -178,17 +188,17 @@ module PaisLegacy
|
|
|
178
188
|
# Performance Report
|
|
179
189
|
# --------------------------------------------------------------------------------
|
|
180
190
|
# '\SCREEN \T1 \336 \spar \N \2 \1 \2 \3 \4 \5 \01/07/2021 \30/06/2022 '
|
|
181
|
-
def self.get_performance(ledger =
|
|
182
|
-
program=
|
|
191
|
+
def self.get_performance(ledger = '1', date_to = '30/06/2022',prior=false,from=1,to=9999)
|
|
192
|
+
program='rglch10a'
|
|
183
193
|
|
|
184
194
|
date_to = Date.parse(date_to)
|
|
185
195
|
date_to = Date.parse("30/06/#{date_to.year}")
|
|
186
196
|
date_from = Date.parse("01/07/#{date_to.year - 1}")
|
|
187
197
|
|
|
188
|
-
cmd = fglgo(
|
|
198
|
+
cmd = fglgo('rptrun') +' pgs 1 pais {{program}} \'\{{printer}} \{{ccode}} \{{ledger}} \spar \N \2 \1 \2 \3 \4 \5 \{{date_from}} \{{date_to}} \' '
|
|
189
199
|
.gsub("{{program}}",program)
|
|
190
|
-
.gsub("{{printer}}",
|
|
191
|
-
.gsub("{{ccode}}",
|
|
200
|
+
.gsub("{{printer}}",'SCREEN')
|
|
201
|
+
.gsub("{{ccode}}",'T1')
|
|
192
202
|
.gsub("{{ledger}}",ledger)
|
|
193
203
|
.gsub("{{account_from}}",from.to_s)
|
|
194
204
|
.gsub("{{account_to}}",to.to_s)
|
|
@@ -204,7 +214,7 @@ module PaisLegacy
|
|
|
204
214
|
# --------------------------------------------------------------------------------
|
|
205
215
|
# Trial Balance
|
|
206
216
|
# --------------------------------------------------------------------------------
|
|
207
|
-
def self.get_trial_balance(ledger =
|
|
217
|
+
def self.get_trial_balance(ledger = '1', date_to = '30/06/2021',prior=false,from=1,to=9999)
|
|
208
218
|
if prior
|
|
209
219
|
program="rglch01p"
|
|
210
220
|
else
|
|
@@ -515,7 +525,7 @@ module PaisLegacy
|
|
|
515
525
|
end
|
|
516
526
|
|
|
517
527
|
def self.table_unload(table)
|
|
518
|
-
|
|
528
|
+
_out = execute_ssh_command(table_unload_cmd(table))
|
|
519
529
|
end
|
|
520
530
|
|
|
521
531
|
def self.tables_cmd
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pais_legacy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.6.
|
|
4
|
+
version: 2.6.17
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Pope
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-09-15 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: pastel
|
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
75
|
version: '0'
|
|
76
76
|
requirements: []
|
|
77
|
-
rubygems_version: 3.6.
|
|
77
|
+
rubygems_version: 3.6.2
|
|
78
78
|
specification_version: 4
|
|
79
79
|
summary: PAIS Legacy API Wrapper
|
|
80
80
|
test_files: []
|