echi-converter 0.2.1 → 0.3.0
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.
- data/History.txt +19 -1
- data/Manifest.txt +1 -0
- data/bin/echi-converter +76 -12
- data/config/application.yml +2 -6
- data/config/install_files.yml +2 -0
- data/lib/database_presence.rb +4 -4
- data/lib/echi-converter.rb +25 -25
- data/lib/echi-converter/version.rb +2 -2
- data/lib/main.rb +18 -16
- data/lib/main_win32.rb +79 -0
- data/website/index.html +28 -5
- data/website/index.txt +17 -2
- metadata +3 -2
data/History.txt
CHANGED
@@ -84,4 +84,22 @@
|
|
84
84
|
* Major enhancement(s):
|
85
85
|
* Minor enhancement(s):
|
86
86
|
* Bug fix(es):
|
87
|
-
* Fixed the database schema to pull from the appropriate config file information for the PCO schema
|
87
|
+
* Fixed the database schema to pull from the appropriate config file information for the PCO schema
|
88
|
+
|
89
|
+
== 0.2.2 2007-10-26
|
90
|
+
|
91
|
+
* Major enhancement(s):
|
92
|
+
* Minor enhancement(s):
|
93
|
+
* Bug fix(es):
|
94
|
+
* Fixed the utility to only process files with the prefix 'chr' in order to avoid picking up other files from the 'to_process' directory
|
95
|
+
* Fixed the database_presence.rb to explicitly define tables rather than derive from the application.yml
|
96
|
+
|
97
|
+
== 0.3.0 2007-11-02
|
98
|
+
|
99
|
+
* Major enhancement(s):
|
100
|
+
* Added the ability to auto-recognize when running on Windows and enable running as a Windows Service (FR#14856/14852)
|
101
|
+
* Minor enhancement(s):
|
102
|
+
* Changed 'echi_ftp_delete:' default setting to 'Y'
|
103
|
+
* A fair amount of internal code refactoring
|
104
|
+
* Bug fix(es):
|
105
|
+
* Fixed bug so that the log file properly reports when a file is processed
|
data/Manifest.txt
CHANGED
data/bin/echi-converter
CHANGED
@@ -4,6 +4,32 @@ require 'daemons'
|
|
4
4
|
require 'fileutils'
|
5
5
|
include FileUtils
|
6
6
|
|
7
|
+
usage = "Usage:
|
8
|
+
echi-converter create myproject - create the local project to run the ECHI converter from (on Windows, directory names must not have spaces)
|
9
|
+
echi-converter upgrade myproject - location of project to upgrade after a new gem version is installed"
|
10
|
+
|
11
|
+
#If we are running on Windows lets load the libraries necessary to run a win32 service
|
12
|
+
if RUBY_PLATFORM["-mswin32"]
|
13
|
+
require 'win32/service'
|
14
|
+
include Win32
|
15
|
+
usage = usage +
|
16
|
+
"
|
17
|
+
echi-converter install myproject - install the service (must specify complete path such as c:\path\to\my\project )
|
18
|
+
echi-converter start - start the service
|
19
|
+
echi-converter stop - stop the service
|
20
|
+
echi-converter pause - pause the service
|
21
|
+
echi-converter resume - resume the service
|
22
|
+
echi-converter uninstall - uninstall the service
|
23
|
+
echi-converter delete - delete the service"
|
24
|
+
else
|
25
|
+
usage = usage +
|
26
|
+
"echi-converter run myproject - Run the ECHI converter interactively from the location given
|
27
|
+
echi-converter start myproject - Start the ECHI converter in daemon mode from the location given
|
28
|
+
echi-converter stop myproject - Stop the ECHI converter daemon
|
29
|
+
echi-converter restart myproject - Restart the ECHI converter
|
30
|
+
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"
|
31
|
+
end
|
32
|
+
|
7
33
|
def set_operating_environ
|
8
34
|
#Build details on the gem installed and its location and version
|
9
35
|
gem_searcher = Gem::GemPathSearcher.new
|
@@ -15,7 +41,11 @@ end
|
|
15
41
|
def create_project dir_name
|
16
42
|
if dir_name == nil
|
17
43
|
puts 'You must specify a directory name, proper usage is:'
|
18
|
-
|
44
|
+
if RUBY_PLATFORM['-mswin']
|
45
|
+
puts 'echi-converter create c:\path\to\my\directory'
|
46
|
+
else
|
47
|
+
puts 'echi-converter create /path/to/my/directory'
|
48
|
+
end
|
19
49
|
puts 'Exiting...'
|
20
50
|
exit
|
21
51
|
end
|
@@ -70,7 +100,43 @@ def upgrade_project project_name
|
|
70
100
|
puts 'Successfully upgraded ' + project_name
|
71
101
|
end
|
72
102
|
|
73
|
-
#
|
103
|
+
#Launches as a Windows Service
|
104
|
+
def launch_service run_type, project_name
|
105
|
+
service_status = nil
|
106
|
+
if project_name != nil
|
107
|
+
service_exe = "c:\\ruby\\bin\\rubyw.exe " + project_name + "\\lib\\main_win32.rb"
|
108
|
+
end
|
109
|
+
begin
|
110
|
+
case run_type
|
111
|
+
when "install"
|
112
|
+
s = Service.new()
|
113
|
+
s.create_service { |s|
|
114
|
+
s.service_name = "ECHI-Converter"
|
115
|
+
s.binary_path_name = service_exe
|
116
|
+
#s.service_type = Service::AUTO_START
|
117
|
+
s.display_name = "ECHI-Converter"
|
118
|
+
s.service_description = "ECHI-Converter Service for " + project_name
|
119
|
+
}
|
120
|
+
s.close
|
121
|
+
when "start"
|
122
|
+
Service.start("ECHI-Converter")
|
123
|
+
when "stop"
|
124
|
+
Service.stop("ECHI-Converter")
|
125
|
+
when "pause"
|
126
|
+
Service.pause("ECHI-Converter")
|
127
|
+
when "resume"
|
128
|
+
Service.resume("ECHI-Converter")
|
129
|
+
when "delete"
|
130
|
+
Service.delete("ECHI-Converter")
|
131
|
+
end
|
132
|
+
service_status = Service.status("ECHI-Converter")
|
133
|
+
return service_status.current_state
|
134
|
+
rescue => err
|
135
|
+
return err
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
#Launches dynamically or as a deamon for *NIX platforms
|
74
140
|
def launch_project run_type, project_name
|
75
141
|
|
76
142
|
#Set various file paths
|
@@ -113,17 +179,15 @@ if ARGV[0] == 'create'
|
|
113
179
|
create_project ARGV[1]
|
114
180
|
elsif ARGV[0] == 'upgrade'
|
115
181
|
upgrade_project ARGV[1]
|
182
|
+
elsif RUBY_PLATFORM["-mswin32"]
|
183
|
+
if ARGV[0] == 'install' || ARGV[0] == 'start' || ARGV[0] == 'stop' || ARGV[0] == 'pause' || ARGV[0] == 'resume' || ARGV[0] == 'uninstall' || ARGV[0] == 'delete' || ARGV[0] == 'status'
|
184
|
+
service_status = launch_service ARGV[0], ARGV[1]
|
185
|
+
puts 'ECHI-Converter: ' + service_status
|
186
|
+
else
|
187
|
+
puts usage
|
188
|
+
end
|
116
189
|
elsif ARGV[0] == 'run' || ARGV[0] == 'start' || ARGV[0] == 'stop' || ARGV[0] == 'zap' || ARGV[0] == 'restart'
|
117
190
|
launch_project ARGV[0], ARGV[1]
|
118
191
|
else
|
119
|
-
usage = "Usage:
|
120
|
-
echi-converter create myproject - create the local project to run the ECHI converter from
|
121
|
-
echi-converter upgrade myproject - location of project to upgrade after a new gem version is installed
|
122
|
-
|
123
|
-
echi-converter run myproject - Run the ECHI converter interactively from the location given
|
124
|
-
echi-converter start myproject - Start the ECHI converter in daemon mode from the location given
|
125
|
-
echi-converter stop myproject - Stop the ECHI converter daemon
|
126
|
-
echi-converter restart myproject - Restart the ECHI converter
|
127
|
-
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"
|
128
192
|
puts usage
|
129
|
-
end
|
193
|
+
end
|
data/config/application.yml
CHANGED
@@ -8,7 +8,7 @@ echi_password:
|
|
8
8
|
echi_connect_type: ftp #only ftp supported now, possible for ssh in the future
|
9
9
|
echi_ftp_directory: #/Users/ftp/anonymous #If blank/nil, the system will not do a CD at the start
|
10
10
|
echi_ftp_retry: 3
|
11
|
-
echi_ftp_delete:
|
11
|
+
echi_ftp_delete: Y #to not delete the files off of the FTP server set to N, Y to delete the files
|
12
12
|
echi_schema: extended_version13.yml
|
13
13
|
echi_format: BINARY #valid settings are ASCII or BINARY
|
14
14
|
echi_process_log: Y #valid is Y/N to turn it on or off
|
@@ -42,8 +42,4 @@ smtp_server: mail.presenceco.com
|
|
42
42
|
smtp_port: 25
|
43
43
|
|
44
44
|
#Special settings for a specific application database
|
45
|
-
pco_process: N #Set to yes or no if running with a PCO database
|
46
|
-
pco_record_tablename: PCO_ECHIRECORD
|
47
|
-
pco_record_seqname: PCO_ECHIRECORDSEQ
|
48
|
-
pco_log_tablename: PCO_ECHILOG
|
49
|
-
pco_log_seqname: PCO_ECHILOGSEQ
|
45
|
+
pco_process: N #Set to yes or no if running with a PCO database
|
data/config/install_files.yml
CHANGED
@@ -37,6 +37,7 @@ files_to_copy:
|
|
37
37
|
- name: lib/database_presence.rb
|
38
38
|
- name: lib/echi-converter.rb
|
39
39
|
- name: lib/main.rb
|
40
|
+
- name: lib/main_win32.rb
|
40
41
|
- name: lib/echi-converter/version.rb
|
41
42
|
- name: examples/schemas/oracle_echi.sql
|
42
43
|
|
@@ -45,4 +46,5 @@ files_to_upgrade:
|
|
45
46
|
- name: lib/database_presence.rb
|
46
47
|
- name: lib/echi-converter.rb
|
47
48
|
- name: lib/main.rb
|
49
|
+
- name: lib/main_win32.rb
|
48
50
|
- name: lib/echi-converter/version.rb
|
data/lib/database_presence.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class EchiRecord < ActiveRecord::Base
|
2
|
-
set_table_name
|
3
|
-
set_sequence_name
|
2
|
+
set_table_name "PCO_ECHIRECORD"
|
3
|
+
set_sequence_name "PCO_ECHIRECORDSEQ"
|
4
4
|
end
|
5
5
|
|
6
6
|
class EchiLog < ActiveRecord::Base
|
7
|
-
set_table_name
|
8
|
-
set_sequence_name
|
7
|
+
set_table_name "PCO_ECHILOG"
|
8
|
+
set_sequence_name "PCO_ECHILOGSEQ"
|
9
9
|
end
|
data/lib/echi-converter.rb
CHANGED
@@ -15,10 +15,10 @@ end
|
|
15
15
|
module EchiConverter
|
16
16
|
|
17
17
|
def connect_database
|
18
|
-
databaseconfig =
|
19
|
-
dblogfile =
|
20
|
-
ActiveRecord::Base.logger = Logger.new(dblogfile,
|
21
|
-
case
|
18
|
+
databaseconfig = $workingdir + '/../config/database.yml'
|
19
|
+
dblogfile = $workingdir + '/../log/database.log'
|
20
|
+
ActiveRecord::Base.logger = Logger.new(dblogfile, $config["log_number"], $config["log_length"])
|
21
|
+
case $config["log_level"]
|
22
22
|
when 'FATAL'
|
23
23
|
ActiveRecord::Base.logger.level = Logger::FATAL
|
24
24
|
when 'ERROR'
|
@@ -41,9 +41,9 @@ module EchiConverter
|
|
41
41
|
|
42
42
|
#Method to open our application log
|
43
43
|
def initiate_logger
|
44
|
-
logfile =
|
45
|
-
@log = Logger.new(logfile,
|
46
|
-
case
|
44
|
+
logfile = $workingdir + '/../log/application.log'
|
45
|
+
@log = Logger.new(logfile, $config["log_number"], $config["log_length"])
|
46
|
+
case $config["log_level"]
|
47
47
|
when 'FATAL'
|
48
48
|
@log.level = Logger::FATAL
|
49
49
|
when 'ERROR'
|
@@ -60,10 +60,10 @@ module EchiConverter
|
|
60
60
|
#Method to send alert emails
|
61
61
|
def send_email_alert reason
|
62
62
|
begin
|
63
|
-
Net::SMTP.start(
|
64
|
-
smtp.open_message_stream('donotreply@echi-converter.rubyforge.org', [
|
63
|
+
Net::SMTP.start($config["smtp_server"], $config["smtp_port"]) do |smtp|
|
64
|
+
smtp.open_message_stream('donotreply@echi-converter.rubyforge.org', [$config["alert_email_address"]]) do |f|
|
65
65
|
f.puts "From: donotreply@echi-converter.rubyforge.org"
|
66
|
-
f.puts "To: " +
|
66
|
+
f.puts "To: " + $config['alert_email_address']
|
67
67
|
f.puts "Subject: ECHI-Converter Failure"
|
68
68
|
case reason
|
69
69
|
when "DATABASE"
|
@@ -140,7 +140,7 @@ module EchiConverter
|
|
140
140
|
#Mehtod that performs the conversions
|
141
141
|
def convert_binary_file filename
|
142
142
|
#Open the file to process
|
143
|
-
echi_file =
|
143
|
+
echi_file = $workingdir + "/../files/to_process/" + filename
|
144
144
|
@binary_file = open(echi_file,"rb")
|
145
145
|
@log.debug "File size: " + @binary_file.stat.size.to_s
|
146
146
|
|
@@ -150,7 +150,7 @@ module EchiConverter
|
|
150
150
|
fileversion = dump_binary 'int', 4
|
151
151
|
@log.debug "Version " + fileversion.to_s
|
152
152
|
|
153
|
-
if
|
153
|
+
if $config["echi_process_log"] == "Y"
|
154
154
|
#Log the file
|
155
155
|
echi_log = EchiLog.new
|
156
156
|
echi_log.filename = filename
|
@@ -208,7 +208,7 @@ module EchiConverter
|
|
208
208
|
#Move the file to the processed directory
|
209
209
|
FileUtils.mv(echi_file, @processeddirectory)
|
210
210
|
|
211
|
-
if
|
211
|
+
if $config["echi_process_log"] == "Y"
|
212
212
|
#Finish logging the details on the file
|
213
213
|
echi_log.records = @record_cnt
|
214
214
|
echi_log.processed_at = Time.now
|
@@ -221,9 +221,9 @@ module EchiConverter
|
|
221
221
|
def connect_ftpsession
|
222
222
|
#Open ftp connection
|
223
223
|
begin
|
224
|
-
if
|
225
|
-
ftp_session = Net::FTP.new(
|
226
|
-
ftp_session.login
|
224
|
+
if $config["echi_connect_type"] == 'ftp'
|
225
|
+
ftp_session = Net::FTP.new($config["echi_host"])
|
226
|
+
ftp_session.login $config["echi_username"], $config["echi_password"]
|
227
227
|
@log.info "Successfully connected to the ECHI FTP server"
|
228
228
|
else
|
229
229
|
#Stub for possible SSH support in the future
|
@@ -250,14 +250,14 @@ module EchiConverter
|
|
250
250
|
sleep 5
|
251
251
|
end
|
252
252
|
attempts += 1
|
253
|
-
if
|
253
|
+
if $config["echi_ftp_retry"] == attempts
|
254
254
|
ftp_session = 0
|
255
255
|
end
|
256
256
|
end
|
257
257
|
if ftp_session != 0
|
258
258
|
begin
|
259
|
-
if
|
260
|
-
ftp_session.chdir(
|
259
|
+
if $config["echi_ftp_directory"] != nil
|
260
|
+
ftp_session.chdir($config["echi_ftp_directory"])
|
261
261
|
end
|
262
262
|
files = ftp_session.list('chr*')
|
263
263
|
file_cnt = 0
|
@@ -265,10 +265,10 @@ module EchiConverter
|
|
265
265
|
#ACTION: Need to detect which OS we are running on and then parse the ftp data appropriately
|
266
266
|
file_data = file.split(' ')
|
267
267
|
remote_filename = file_data[8]
|
268
|
-
local_filename =
|
268
|
+
local_filename = $workingdir + '/../files/to_process/' + remote_filename
|
269
269
|
ftp_session.getbinaryfile(remote_filename, local_filename)
|
270
270
|
files_to_process[file_cnt] = remote_filename
|
271
|
-
if
|
271
|
+
if $config["echi_ftp_delete"] == 'Y'
|
272
272
|
begin
|
273
273
|
ftp_session.delete(remote_filename)
|
274
274
|
rescue => err
|
@@ -287,9 +287,9 @@ module EchiConverter
|
|
287
287
|
end
|
288
288
|
|
289
289
|
def process_ascii filename
|
290
|
-
echi_file =
|
290
|
+
echi_file = $workingdir + "/../files/to_process/" + filename
|
291
291
|
|
292
|
-
if
|
292
|
+
if $config["echi_process_log"] == "Y"
|
293
293
|
#Log the file
|
294
294
|
echi_log = EchiLog.new
|
295
295
|
echi_log.filename = filename
|
@@ -333,7 +333,7 @@ def process_ascii filename
|
|
333
333
|
#Move the file to the processed directory
|
334
334
|
FileUtils.mv(echi_file, @processeddirectory)
|
335
335
|
|
336
|
-
if
|
336
|
+
if $config["echi_process_log"] == "Y"
|
337
337
|
#Finish logging the details on the file
|
338
338
|
echi_log.records = @record_cnt
|
339
339
|
echi_log.processed_at = Time.now
|
@@ -343,4 +343,4 @@ def process_ascii filename
|
|
343
343
|
return @record_cnt
|
344
344
|
end
|
345
345
|
|
346
|
-
require
|
346
|
+
require $workingdir + '/echi-converter/version.rb'
|
data/lib/main.rb
CHANGED
@@ -2,57 +2,59 @@ require 'rubygems'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
#Determine our working directory
|
5
|
-
|
6
|
-
require
|
5
|
+
$workingdir = File.expand_path File.dirname(__FILE__)
|
6
|
+
require $workingdir + '/echi-converter.rb'
|
7
7
|
include EchiConverter
|
8
|
+
|
8
9
|
|
9
10
|
#Open the configuration file
|
10
|
-
configfile =
|
11
|
-
|
11
|
+
configfile = $workingdir + '/../config/application.yml'
|
12
|
+
$config = YAML::load(File.open(configfile))
|
12
13
|
|
13
14
|
#Load ActiveRecord Models
|
14
|
-
if
|
15
|
-
require
|
15
|
+
if $config["pco_process"] == 'Y'
|
16
|
+
require $workingdir + '/database_presence.rb'
|
16
17
|
else
|
17
|
-
require
|
18
|
+
require $workingdir + '/database.rb'
|
18
19
|
end
|
19
20
|
|
20
21
|
#Load the configured schema
|
21
|
-
schemafile =
|
22
|
+
schemafile = $workingdir + "/../config/" + $config["echi_schema"]
|
22
23
|
@echi_schema = YAML::load(File.open(schemafile))
|
23
24
|
|
24
25
|
#Open the logfile with appropriate output level
|
25
26
|
initiate_logger
|
26
27
|
|
27
28
|
#If configured for database insertion, connect to the database
|
28
|
-
if
|
29
|
+
if $config["export_type"] == 'database' || $config["export_type"] == 'both'
|
29
30
|
connect_database
|
30
31
|
end
|
31
32
|
|
32
33
|
@log.info "Running..."
|
33
34
|
|
35
|
+
#Our Main loop
|
34
36
|
loop do
|
35
37
|
#Process the files
|
36
38
|
ftp_files = fetch_ftp_files
|
37
39
|
#Grab filenames from the to_process directory after an FTP fetch, so if the
|
38
40
|
#system fails it may pick up where it left off
|
39
|
-
to_process_dir =
|
41
|
+
to_process_dir = $workingdir + "/../files/to_process/"
|
40
42
|
|
41
43
|
#Establish where to copy the processed files to
|
42
|
-
@processeddirectory = set_directory(
|
44
|
+
@processeddirectory = set_directory($workingdir)
|
43
45
|
|
44
46
|
Dir.entries(to_process_dir).each do | file |
|
45
|
-
if file
|
46
|
-
if
|
47
|
+
if file.slice(0,3) == 'chr'
|
48
|
+
if $config["echi_format"] == 'BINARY'
|
47
49
|
record_cnt = convert_binary_file file
|
48
|
-
elsif
|
50
|
+
elsif $config["echi_format"] == 'ASCII'
|
49
51
|
record_cnt = process_ascii file
|
50
52
|
end
|
53
|
+
@log.info "Processed file #{file} with #{record_cnt.to_s} records"
|
51
54
|
end
|
52
|
-
@log.info "Processed file #{file} with #{record_cnt.to_s} records"
|
53
55
|
end
|
54
56
|
|
55
|
-
sleep
|
57
|
+
sleep $config["fetch_interval"]
|
56
58
|
|
57
59
|
#Make sure we did not lose our database connection while we slept
|
58
60
|
if ActiveRecord::Base.connected? == 'FALSE'
|
data/lib/main_win32.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'win32/service'
|
4
|
+
include Win32
|
5
|
+
|
6
|
+
class EchiDaemon < Daemon
|
7
|
+
#Determine our working directory
|
8
|
+
$workingdir = File.expand_path File.dirname(__FILE__)
|
9
|
+
require $workingdir + '/echi-converter.rb'
|
10
|
+
include EchiConverter
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
#Open the configuration file
|
14
|
+
configfile = $workingdir + '/../config/application.yml'
|
15
|
+
$config = YAML::load(File.open(configfile))
|
16
|
+
|
17
|
+
#Load ActiveRecord Models
|
18
|
+
if $config["pco_process"] == 'Y'
|
19
|
+
require $workingdir + '/database_presence.rb'
|
20
|
+
else
|
21
|
+
require $workingdir + '/database.rb'
|
22
|
+
end
|
23
|
+
|
24
|
+
#Load the configured schema
|
25
|
+
schemafile = $workingdir + "/../config/" + $config["echi_schema"]
|
26
|
+
@echi_schema = YAML::load(File.open(schemafile))
|
27
|
+
|
28
|
+
#Open the logfile with appropriate output level
|
29
|
+
initiate_logger
|
30
|
+
|
31
|
+
#If configured for database insertion, connect to the database
|
32
|
+
if $config["export_type"] == 'database' || $config["export_type"] == 'both'
|
33
|
+
connect_database
|
34
|
+
end
|
35
|
+
|
36
|
+
@log.info "Running..."
|
37
|
+
end
|
38
|
+
|
39
|
+
def service_main
|
40
|
+
loop do
|
41
|
+
#Process the files
|
42
|
+
ftp_files = fetch_ftp_files
|
43
|
+
#Grab filenames from the to_process directory after an FTP fetch, so if the
|
44
|
+
#system fails it may pick up where it left off
|
45
|
+
to_process_dir = $workingdir + "/../files/to_process/"
|
46
|
+
|
47
|
+
#Establish where to copy the processed files to
|
48
|
+
@processeddirectory = set_directory($workingdir)
|
49
|
+
|
50
|
+
Dir.entries(to_process_dir).each do | file |
|
51
|
+
if file.slice(0,3) == 'chr'
|
52
|
+
if $config["echi_format"] == 'BINARY'
|
53
|
+
record_cnt = convert_binary_file file
|
54
|
+
elsif $config["echi_format"] == 'ASCII'
|
55
|
+
record_cnt = process_ascii file
|
56
|
+
end
|
57
|
+
@log.info "Processed file #{file} with #{record_cnt.to_s} records"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
sleep $config["fetch_interval"]
|
62
|
+
|
63
|
+
#Make sure we did not lose our database connection while we slept
|
64
|
+
if ActiveRecord::Base.connected? == 'FALSE'
|
65
|
+
connect_database
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def service_cleanup
|
71
|
+
#Close the logfile
|
72
|
+
@log.info "Shutdown..."
|
73
|
+
@log.close
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
d = EchiDaemon.new
|
78
|
+
d.mainloop
|
79
|
+
d.service_cleanup
|
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.
|
36
|
+
<a href="http://rubyforge.org/projects/echi-converter" class="numbers">0.3.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘echi-converter’</h1>
|
39
39
|
|
@@ -63,6 +63,7 @@
|
|
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>Runs as a daemon (via fork) on *NIX and a service on Windows</li>
|
66
67
|
</ol>
|
67
68
|
|
68
69
|
|
@@ -85,7 +86,8 @@
|
|
85
86
|
<li><a href="http://activesupport.rubyforge.org/">ActiveSupport v1.4.2+</a></li>
|
86
87
|
<li><a href="http://daemons.rubyforge.org/">Daemons v1.0.7+</a></li>
|
87
88
|
<li><a href="http://fastercsv.rubyforge.org/">FasterCSV v1.2.0+</a></li>
|
88
|
-
<li><a href="http://rake.rubyforge.org/">Rake v0.7.3+</a
|
89
|
+
<li><a href="http://rake.rubyforge.org/">Rake v0.7.3+</a>
|
90
|
+
# <a href="http://win32utils.rubyforge.org/">Win32-service v.0.5.2+</a> (Manual install for Windows only)</li>
|
89
91
|
<li><a href="http://rubyforge.org/projects/seattlerb/">Hoe v1.2.2+</a></li>
|
90
92
|
</ol>
|
91
93
|
|
@@ -143,6 +145,9 @@
|
|
143
145
|
</ol>
|
144
146
|
|
145
147
|
|
148
|
+
<p>For *NIX:</p>
|
149
|
+
|
150
|
+
|
146
151
|
<ol>
|
147
152
|
<li>echi-converter run myproject – Run the <span class="caps">ECHI</span> converter interactively from the location given</li>
|
148
153
|
<li>echi-converter start myproject – Start the <span class="caps">ECHI</span> converter in daemon mode from the location given</li>
|
@@ -152,6 +157,20 @@
|
|
152
157
|
</ol>
|
153
158
|
|
154
159
|
|
160
|
+
<p>For Windows:</p>
|
161
|
+
|
162
|
+
|
163
|
+
<ol>
|
164
|
+
<li>echi-converter install myproject – install the service (must specify complete path such as c:\path\to\my\project )</li>
|
165
|
+
<li>echi-converter start – start the service</li>
|
166
|
+
<li>echi-converter stop – stop the service</li>
|
167
|
+
<li>echi-converter pause – pause the service</li>
|
168
|
+
<li>echi-converter resume – resume the service</li>
|
169
|
+
<li>echi-converter uninstall – uninstall the service</li>
|
170
|
+
<li>echi-converter delete – delete the service”</li>
|
171
|
+
</ol>
|
172
|
+
|
173
|
+
|
155
174
|
<h2>Demonstration of usage</h2>
|
156
175
|
|
157
176
|
|
@@ -165,14 +184,18 @@
|
|
165
184
|
|
166
185
|
<pre syntax="ruby">echi-converter stop myproject</pre>
|
167
186
|
|
168
|
-
<h2>
|
187
|
+
<h2>Limitations</h2>
|
169
188
|
|
170
189
|
|
171
190
|
<p>Items to be done to move this out of alpha stage:</p>
|
172
191
|
|
173
192
|
|
174
193
|
<ol>
|
175
|
-
<li
|
194
|
+
<li>There are currently two limitations when running on Windows
|
195
|
+
<ol>
|
196
|
+
<li>Project directories may not have spaces</li>
|
197
|
+
<li>The Ruby interpreter must be installed in the default location of c:\ruby\bin</li>
|
198
|
+
</ol></li>
|
176
199
|
</ol>
|
177
200
|
|
178
201
|
|
@@ -208,7 +231,7 @@
|
|
208
231
|
|
209
232
|
<p>Comments are welcome. Send an email to <a href="mailto:jason@goecke.net">jason [at] goecke.net</a>.</p>
|
210
233
|
<p class="coda">
|
211
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
234
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 2nd November 2007<br>
|
212
235
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
213
236
|
</p>
|
214
237
|
</div>
|
data/website/index.txt
CHANGED
@@ -22,6 +22,7 @@ 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
|
+
# Runs as a daemon (via fork) on *NIX and a service on Windows
|
25
26
|
|
26
27
|
# Table names:
|
27
28
|
## echi_records - stores all ECHI data
|
@@ -37,6 +38,7 @@ h2. Requirements
|
|
37
38
|
# "Daemons v1.0.7+":http://daemons.rubyforge.org/
|
38
39
|
# "FasterCSV v1.2.0+":http://fastercsv.rubyforge.org/
|
39
40
|
# "Rake v0.7.3+":http://rake.rubyforge.org/
|
41
|
+
# "Win32-service v.0.5.2+":http://win32utils.rubyforge.org/ (Manual install for Windows only)
|
40
42
|
# "Hoe v1.2.2+":http://rubyforge.org/projects/seattlerb/
|
41
43
|
|
42
44
|
|
@@ -74,12 +76,23 @@ h2. Usage
|
|
74
76
|
# echi-converter create myproject - create the local project to run the ECHI converter from
|
75
77
|
# echi-converter upgrade myproject - location of project to upgrade after a new gem is installed
|
76
78
|
|
79
|
+
For *NIX:
|
80
|
+
|
77
81
|
# echi-converter run myproject - Run the ECHI converter interactively from the location given
|
78
82
|
# echi-converter start myproject - Start the ECHI converter in daemon mode from the location given
|
79
83
|
# echi-converter stop myproject - Stop the ECHI converter daemon
|
80
84
|
# echi-converter restart myproject - Restart the ECHI converter
|
81
85
|
# echi-converter zap myrpoject - If there has been an unexpected close and the system still thinks the converter is running, clean up the pid files
|
82
86
|
|
87
|
+
For Windows:
|
88
|
+
|
89
|
+
# echi-converter install myproject - install the service (must specify complete path such as c:\path\to\my\project )
|
90
|
+
# echi-converter start - start the service
|
91
|
+
# echi-converter stop - stop the service
|
92
|
+
# echi-converter pause - pause the service
|
93
|
+
# echi-converter resume - resume the service
|
94
|
+
# echi-converter uninstall - uninstall the service
|
95
|
+
# echi-converter delete - delete the service"
|
83
96
|
|
84
97
|
h2. Demonstration of usage
|
85
98
|
|
@@ -92,11 +105,13 @@ Stop the daemon/service:
|
|
92
105
|
<pre syntax="ruby">echi-converter stop myproject</pre>
|
93
106
|
|
94
107
|
|
95
|
-
h2.
|
108
|
+
h2. Limitations
|
96
109
|
|
97
110
|
Items to be done to move this out of alpha stage:
|
98
111
|
|
99
|
-
#
|
112
|
+
# There are currently two limitations when running on Windows
|
113
|
+
## Project directories may not have spaces
|
114
|
+
## The Ruby interpreter must be installed in the default location of c:\ruby\bin
|
100
115
|
|
101
116
|
h2. Screencast
|
102
117
|
|
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.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.3.0
|
7
|
+
date: 2007-11-03 00:00:00 -07: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
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/echi-converter/version.rb
|
39
39
|
- lib/database.rb
|
40
40
|
- lib/database_presence.rb
|
41
|
+
- lib/main_win32.rb
|
41
42
|
- lib/echi-converter.rb
|
42
43
|
- scripts/txt2html
|
43
44
|
- setup.rb
|