echi-converter 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +22 -1
- data/Manifest.txt +5 -0
- data/config/application.yml +9 -4
- data/config/database.yml +3 -2
- data/config/extended_version12.yml +50 -2
- data/config/extended_version13.yml +50 -2
- data/config/install_files.yml +9 -0
- data/config/standard_version12.yml +50 -2
- data/config/standard_version13.yml +50 -2
- data/db/migrate/001_create_echi_records.rb +1 -1
- data/db/migrate/003_create_echi_agents.rb +15 -3
- data/db/migrate/006_create_echi_aux_reasons.rb +27 -0
- data/db/migrate/007_create_echi_cwcs.rb +27 -0
- data/db/migrate/008_create_echi_vdns.rb +27 -0
- data/examples/db_connect_test.rb +25 -0
- data/lib/database.rb +10 -1
- data/lib/echi-converter.rb +244 -233
- data/lib/echi-converter/version.rb +1 -1
- data/lib/ftp_fetcher.rb +82 -0
- data/lib/main.rb +7 -4
- data/lib/main_win32.rb +5 -4
- data/website/index.html +36 -6
- data/website/index.txt +23 -3
- metadata +7 -2
data/lib/ftp_fetcher.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
class FtpFetcher < Net::FTP
|
2
|
+
|
3
|
+
#Connect to the ftp server
|
4
|
+
def connect_ftp_session log
|
5
|
+
begin
|
6
|
+
#ftp_session = Net::FTP.new($config["echi_host"])
|
7
|
+
ftp_session = Net::FTP.new
|
8
|
+
ftp_session.connect($config["echi_host"], $config["echi_port"])
|
9
|
+
ftp_session.login $config["echi_username"], $config["echi_password"]
|
10
|
+
log.info "Successfully connected to the ECHI FTP server"
|
11
|
+
rescue => err
|
12
|
+
log.info "Could not connect with the FTP server - " + err
|
13
|
+
return -1
|
14
|
+
end
|
15
|
+
return ftp_session
|
16
|
+
end
|
17
|
+
|
18
|
+
#Obtain the list of files available on the server
|
19
|
+
def fetch_list log
|
20
|
+
attempts = 0
|
21
|
+
ftp_session = -1
|
22
|
+
while ftp_session == -1 do
|
23
|
+
ftp_session = connect_ftp_session log
|
24
|
+
if ftp_session == -1
|
25
|
+
sleep 5
|
26
|
+
end
|
27
|
+
attempts += 1
|
28
|
+
if $config["echi_ftp_retry"] == attempts
|
29
|
+
ftp_session = 0
|
30
|
+
end
|
31
|
+
end
|
32
|
+
if ftp_session != 0
|
33
|
+
begin
|
34
|
+
if $config["echi_ftp_directory"] != nil
|
35
|
+
ftp_session.chdir($config["echi_ftp_directory"])
|
36
|
+
end
|
37
|
+
files = ftp_session.list('chr*')
|
38
|
+
|
39
|
+
#Also fetch the *.dat files if it is configured to be processed
|
40
|
+
if $config["echi_process_dat_files"] == "Y"
|
41
|
+
files = files + ftp_session.list("*.dat")
|
42
|
+
end
|
43
|
+
#Build the queue of files to be fetched for the threads
|
44
|
+
filequeue = Queue.new
|
45
|
+
files.each do |file|
|
46
|
+
file_data = file.split(' ')
|
47
|
+
filequeue.push(file_data[8])
|
48
|
+
end
|
49
|
+
ftp_session.close
|
50
|
+
return filequeue
|
51
|
+
rescue => err
|
52
|
+
log.info "Unable to fetch list from ftp server - " + err
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
#Connect to the ftp server and fetch the files each time
|
59
|
+
def fetch_ftp_files filequeue, log
|
60
|
+
begin
|
61
|
+
ftp_session = connect_ftp_session log
|
62
|
+
if $config["echi_ftp_directory"] != nil
|
63
|
+
ftp_session.chdir($config["echi_ftp_directory"])
|
64
|
+
end
|
65
|
+
while filequeue.empty? != true
|
66
|
+
filename = filequeue.pop
|
67
|
+
local_filename = $workingdir + '/../files/to_process/' + filename
|
68
|
+
ftp_session.getbinaryfile(filename, local_filename)
|
69
|
+
if $config["echi_ftp_delete"] == 'Y'
|
70
|
+
ftp_session.delete(filename)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
ftp_session.close
|
74
|
+
log.info "Closed ftp session."
|
75
|
+
return true
|
76
|
+
rescue => err
|
77
|
+
log.info "Could not fetch from ftp server - " + err
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
data/lib/main.rb
CHANGED
@@ -31,12 +31,15 @@ if $config["export_type"] == 'database' || $config["export_type"] == 'both'
|
|
31
31
|
end
|
32
32
|
|
33
33
|
$init_date = Time.now
|
34
|
-
@log.info "
|
34
|
+
@log.info "ECHI-Converter daemon started with these settings:"
|
35
|
+
@log.info $config.inspect
|
35
36
|
|
36
37
|
#Our Main loop
|
37
38
|
loop do
|
38
39
|
#Process the files
|
39
|
-
fetch_ftp_files
|
40
|
+
#fetch_ftp_files
|
41
|
+
get_ftp_files
|
42
|
+
|
40
43
|
#Grab filenames from the to_process directory after an FTP fetch, so if the
|
41
44
|
#system fails it may pick up where it left off
|
42
45
|
to_process_dir = $workingdir + "/../files/to_process/"
|
@@ -55,8 +58,8 @@ loop do
|
|
55
58
|
end
|
56
59
|
end
|
57
60
|
|
58
|
-
if $config["
|
59
|
-
|
61
|
+
if $config["echi_process_dat_files"] == "Y" && $config["pco_process"] == "N"
|
62
|
+
process_dat_files
|
60
63
|
end
|
61
64
|
|
62
65
|
sleep $config["fetch_interval"]
|
data/lib/main_win32.rb
CHANGED
@@ -50,11 +50,12 @@ class EchiDaemon < Daemon
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def service_main
|
53
|
-
@log.info "ECHI-Converter service started"
|
53
|
+
@log.info "ECHI-Converter service started with these settings:"
|
54
|
+
@log.info $config.inspect
|
54
55
|
while running?
|
55
56
|
if state == RUNNING
|
56
57
|
#Process the files
|
57
|
-
|
58
|
+
get_ftp_files
|
58
59
|
#Grab filenames from the to_process directory after an FTP fetch, so if the
|
59
60
|
#system fails it may pick up where it left off
|
60
61
|
to_process_dir = $workingdir + "/../files/to_process/"
|
@@ -73,8 +74,8 @@ class EchiDaemon < Daemon
|
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
|
-
if $config["
|
77
|
-
|
77
|
+
if $config["echi_process_dat_files"] == "Y" && $config["pco_process"] == "N"
|
78
|
+
process_dat_files
|
78
79
|
end
|
79
80
|
|
80
81
|
sleep $config["fetch_interval"]
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>ECHI Converter</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/echi-converter"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/echi-converter" class="numbers">0.3.
|
36
|
+
<a href="http://rubyforge.org/projects/echi-converter" class="numbers">0.3.4</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘echi-converter’</h1>
|
39
39
|
|
@@ -63,8 +63,9 @@
|
|
63
63
|
<li>Convert from the defined Binary format to <span class="caps">ASCII</span></li>
|
64
64
|
<li>Insert the records into the defined database table using database transactions, via ActiveRecord, on a per file basis to support recovery on failure</li>
|
65
65
|
<li>Change schema structure via <span class="caps">YML</span> configuration file to accommodate various releases of the <span class="caps">ECHI</span> format</li>
|
66
|
-
<li>Supports inserting
|
66
|
+
<li>Supports inserting data from the various ’.dat’ files provided</li>
|
67
67
|
<li>Runs as a daemon (via fork) on *NIX and a service on Windows</li>
|
68
|
+
<li>Allows for multiple <span class="caps">FTP</span> sessions to be used for greater performance (via <a href="http://en.wikipedia.org/wiki/Green_threads">green threads</a>)</li>
|
68
69
|
</ol>
|
69
70
|
|
70
71
|
|
@@ -73,7 +74,10 @@
|
|
73
74
|
<ol>
|
74
75
|
<li>echi_records – stores all <span class="caps">ECHI</span> data </li>
|
75
76
|
<li>echi_logs – stores a log entry for each file processed</li>
|
76
|
-
<li>echi_agents – stores the data from the agname.dat file</li>
|
77
|
+
<li>echi_agents – stores the data from the agname.dat file </li>
|
78
|
+
<li>echi_aux_reasons – stores the data from the aux_rsn.dat file</li>
|
79
|
+
<li>echi_cwcs – stores data from the cwc.dat file</li>
|
80
|
+
<li>echi_vdns – stores data from the vdn.dat file</li>
|
77
81
|
</ol></li>
|
78
82
|
</ol>
|
79
83
|
|
@@ -151,7 +155,7 @@
|
|
151
155
|
</ol>
|
152
156
|
|
153
157
|
|
154
|
-
<p>For
|
158
|
+
<p>For <span class="caps">POSIX</span>:</p>
|
155
159
|
|
156
160
|
|
157
161
|
<ol>
|
@@ -159,7 +163,7 @@
|
|
159
163
|
<li>echi-converter start myproject – Start the <span class="caps">ECHI</span> converter in daemon mode from the location given</li>
|
160
164
|
<li>echi-converter stop myproject – Stop the <span class="caps">ECHI</span> converter daemon</li>
|
161
165
|
<li>echi-converter restart myproject – Restart the <span class="caps">ECHI</span> converter </li>
|
162
|
-
<li>echi-converter zap
|
166
|
+
<li>echi-converter zap myproject – If there has been an unexpected close and the system still thinks the converter is running, clean up the pid files</li>
|
163
167
|
</ol>
|
164
168
|
|
165
169
|
|
@@ -185,6 +189,14 @@
|
|
185
189
|
</ol>
|
186
190
|
|
187
191
|
|
192
|
+
<p>Multi-byte character support:</p>
|
193
|
+
|
194
|
+
|
195
|
+
<ol>
|
196
|
+
<li>If you require multi-byte character support be sure to set your database to ‘utf8’ as well as uncomment the option ‘encoding: utf8’ in the config/database.yml file</li>
|
197
|
+
</ol>
|
198
|
+
|
199
|
+
|
188
200
|
<h2>Demonstration of usage</h2>
|
189
201
|
|
190
202
|
|
@@ -198,6 +210,24 @@
|
|
198
210
|
|
199
211
|
<pre syntax="ruby">echi-converter stop myproject</pre>
|
200
212
|
|
213
|
+
<h2>Supported Platforms</h2>
|
214
|
+
|
215
|
+
|
216
|
+
<p>While the use of Ruby allows for operation on a multitude of platforms, these are the platforms that have actually been tested on. If you have success running on other platforms, please feel free to provide details on the Google Group.</p>
|
217
|
+
|
218
|
+
|
219
|
+
<h4>Operating Systems</h4>
|
220
|
+
|
221
|
+
|
222
|
+
<p><span class="caps">POSIX</span>, Windows <span class="caps">XP SP2</span>, Windows 2000 and Windows 2003.</p>
|
223
|
+
|
224
|
+
|
225
|
+
<h4><span class="caps">FTP</span> Servers</h4>
|
226
|
+
|
227
|
+
|
228
|
+
<p><span class="caps">VSFTP</span> and Windows 2003/XP <span class="caps">FTP</span> Servers.</p>
|
229
|
+
|
230
|
+
|
201
231
|
<h2>Screencast</h2>
|
202
232
|
|
203
233
|
|
@@ -230,7 +260,7 @@
|
|
230
260
|
|
231
261
|
<p>Comments are welcome. Send an email to <a href="mailto:jason@goecke.net">jason [at] goecke.net</a>.</p>
|
232
262
|
<p class="coda">
|
233
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
263
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 25th November 2007<br>
|
234
264
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
235
265
|
</p>
|
236
266
|
</div>
|
data/website/index.txt
CHANGED
@@ -22,13 +22,17 @@ The utility provides the following capabilities:
|
|
22
22
|
# Convert from the defined Binary format to ASCII
|
23
23
|
# Insert the records into the defined database table using database transactions, via ActiveRecord, on a per file basis to support recovery on failure
|
24
24
|
# Change schema structure via YML configuration file to accommodate various releases of the ECHI format
|
25
|
-
# Supports inserting
|
25
|
+
# Supports inserting data from the various '.dat' files provided
|
26
26
|
# Runs as a daemon (via fork) on *NIX and a service on Windows
|
27
|
+
# Allows for multiple FTP sessions to be used for greater performance (via "green threads":http://en.wikipedia.org/wiki/Green_threads)
|
27
28
|
|
28
29
|
# Table names:
|
29
30
|
## echi_records - stores all ECHI data
|
30
31
|
## echi_logs - stores a log entry for each file processed
|
31
32
|
## echi_agents - stores the data from the agname.dat file
|
33
|
+
## echi_aux_reasons - stores the data from the aux_rsn.dat file
|
34
|
+
## echi_cwcs - stores data from the cwc.dat file
|
35
|
+
## echi_vdns - stores data from the vdn.dat file
|
32
36
|
|
33
37
|
|
34
38
|
h2. Requirements
|
@@ -79,13 +83,13 @@ h2. Usage
|
|
79
83
|
# echi-converter create myproject - create the local project to run the ECHI converter from
|
80
84
|
# echi-converter upgrade myproject - location of project to upgrade after a new gem is installed
|
81
85
|
|
82
|
-
For
|
86
|
+
For POSIX:
|
83
87
|
|
84
88
|
# echi-converter run myproject - Run the ECHI converter interactively from the location given
|
85
89
|
# echi-converter start myproject - Start the ECHI converter in daemon mode from the location given
|
86
90
|
# echi-converter stop myproject - Stop the ECHI converter daemon
|
87
91
|
# echi-converter restart myproject - Restart the ECHI converter
|
88
|
-
# echi-converter zap
|
92
|
+
# echi-converter zap myproject - If there has been an unexpected close and the system still thinks the converter is running, clean up the pid files
|
89
93
|
|
90
94
|
For Windows:
|
91
95
|
|
@@ -100,6 +104,10 @@ For Windows:
|
|
100
104
|
# If you would like to run the script interactively, you may also execute this command:
|
101
105
|
## ruby "c:\myproject\lib\main_win32.rb"
|
102
106
|
|
107
|
+
Multi-byte character support:
|
108
|
+
|
109
|
+
# If you require multi-byte character support be sure to set your database to 'utf8' as well as uncomment the option 'encoding: utf8' in the config/database.yml file
|
110
|
+
|
103
111
|
h2. Demonstration of usage
|
104
112
|
|
105
113
|
Start the daemon/service:
|
@@ -110,6 +118,18 @@ Stop the daemon/service:
|
|
110
118
|
|
111
119
|
<pre syntax="ruby">echi-converter stop myproject</pre>
|
112
120
|
|
121
|
+
h2. Supported Platforms
|
122
|
+
|
123
|
+
While the use of Ruby allows for operation on a multitude of platforms, these are the platforms that have actually been tested on. If you have success running on other platforms, please feel free to provide details on the Google Group.
|
124
|
+
|
125
|
+
h4. Operating Systems
|
126
|
+
|
127
|
+
POSIX, Windows XP SP2, Windows 2000 and Windows 2003.
|
128
|
+
|
129
|
+
h4. FTP Servers
|
130
|
+
|
131
|
+
VSFTP and Windows 2003/XP FTP Servers.
|
132
|
+
|
113
133
|
h2. Screencast
|
114
134
|
|
115
135
|
You may view the screencast on howto install and use the ECHI-Converter "here":http://www.screencast.com/t/lQQkIVkUZMr.
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: echi-converter
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.3.
|
7
|
-
date: 2007-11-
|
6
|
+
version: 0.3.4
|
7
|
+
date: 2007-11-25 00:00:00 -08:00
|
8
8
|
summary: ECHI Conversion Utility - Provides a utility to fetch Avaya CMS / ECHI binary files, convert them and insert into a database table via ActiveRecord
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/database_presence.rb
|
41
41
|
- lib/main_win32.rb
|
42
42
|
- lib/echi-converter.rb
|
43
|
+
- lib/ftp_fetcher.rb
|
43
44
|
- scripts/txt2html
|
44
45
|
- setup.rb
|
45
46
|
- test/test_echi-converter.rb
|
@@ -61,11 +62,15 @@ files:
|
|
61
62
|
- db/migrate/003_create_echi_agents.rb
|
62
63
|
- db/migrate/004_change_log_name_size.rb
|
63
64
|
- db/migrate/005_change_log_processedat_name.rb
|
65
|
+
- db/migrate/006_create_echi_aux_reasons.rb
|
66
|
+
- db/migrate/007_create_echi_cwcs.rb
|
67
|
+
- db/migrate/008_create_echi_vdns.rb
|
64
68
|
- bin/echi-converter
|
65
69
|
- examples/extended_version12/chr0003
|
66
70
|
- examples/extended_version12/chr0003.txt
|
67
71
|
- examples/schemas/oracle_echi.sql
|
68
72
|
- examples/ascii_csv/chr5500.123
|
73
|
+
- examples/db_connect_test.rb
|
69
74
|
test_files:
|
70
75
|
- test/test_echi-converter.rb
|
71
76
|
- test/test_helper.rb
|