echi-converter 0.3.0 → 0.3.1
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 +11 -1
- data/bin/echi-converter +18 -9
- data/lib/echi-converter.rb +3 -7
- data/lib/echi-converter/version.rb +1 -1
- data/lib/main.rb +1 -1
- data/lib/main_win32.rb +45 -32
- data/website/index.html +5 -19
- data/website/index.txt +4 -13
- metadata +2 -2
data/History.txt
CHANGED
@@ -102,4 +102,14 @@
|
|
102
102
|
* Changed 'echi_ftp_delete:' default setting to 'Y'
|
103
103
|
* A fair amount of internal code refactoring
|
104
104
|
* Bug fix(es):
|
105
|
-
* Fixed bug so that the log file properly reports when a file is processed
|
105
|
+
* Fixed bug so that the log file properly reports when a file is processed
|
106
|
+
|
107
|
+
== 0.3.1 2007-11-TBD
|
108
|
+
|
109
|
+
* Major enhancement(s):
|
110
|
+
* Minor enhancement(s):
|
111
|
+
* Removed the need for the default install requirement, Ruby may now be installed anywhere on the Windows system (FR#15302)
|
112
|
+
* Modified the return status when creating or manipulating a Windows service
|
113
|
+
* Add the 'echi-converter status' command to check the status of a Windows service
|
114
|
+
* Bug fix(es):
|
115
|
+
* Fixed bug #15293, the service now exists cleanly
|
data/bin/echi-converter
CHANGED
@@ -19,6 +19,7 @@ if RUBY_PLATFORM["-mswin32"]
|
|
19
19
|
echi-converter stop - stop the service
|
20
20
|
echi-converter pause - pause the service
|
21
21
|
echi-converter resume - resume the service
|
22
|
+
echi-converter status - check the status of a configured service
|
22
23
|
echi-converter uninstall - uninstall the service
|
23
24
|
echi-converter delete - delete the service"
|
24
25
|
else
|
@@ -102,9 +103,10 @@ end
|
|
102
103
|
|
103
104
|
#Launches as a Windows Service
|
104
105
|
def launch_service run_type, project_name
|
105
|
-
service_status = nil
|
106
106
|
if project_name != nil
|
107
|
-
|
107
|
+
rubyw_path = Config::CONFIG["bindir"] + "/" + Config::CONFIG["RUBYW_INSTALL_NAME"] + Config::CONFIG["EXEEXT"]
|
108
|
+
rubyw_path = rubyw_path.gsub("/","\\")
|
109
|
+
service_exe = '"' + rubyw_path + '" "' + project_name + "\\lib\\main_win32.rb" + '"'
|
108
110
|
end
|
109
111
|
begin
|
110
112
|
case run_type
|
@@ -112,25 +114,32 @@ def launch_service run_type, project_name
|
|
112
114
|
s = Service.new()
|
113
115
|
s.create_service { |s|
|
114
116
|
s.service_name = "ECHI-Converter"
|
115
|
-
s.binary_path_name = service_exe
|
117
|
+
s.binary_path_name = service_exe.gsub(" ","\s")
|
116
118
|
#s.service_type = Service::AUTO_START
|
117
119
|
s.display_name = "ECHI-Converter"
|
118
120
|
s.service_description = "ECHI-Converter Service for " + project_name
|
119
121
|
}
|
120
122
|
s.close
|
123
|
+
service_status = "Service successfully created."
|
121
124
|
when "start"
|
122
|
-
Service.start("ECHI-Converter")
|
125
|
+
service_status = Service.start("ECHI-Converter")
|
126
|
+
service_status = "Service successfully started"
|
123
127
|
when "stop"
|
124
|
-
Service.stop("ECHI-Converter")
|
128
|
+
service_status = Service.stop("ECHI-Converter")
|
129
|
+
service_status = "Service successfully stopped"
|
125
130
|
when "pause"
|
126
|
-
Service.pause("ECHI-Converter")
|
131
|
+
service_status = Service.pause("ECHI-Converter")
|
132
|
+
service_status = "Service successfully paused"
|
127
133
|
when "resume"
|
128
|
-
Service.resume("ECHI-Converter")
|
134
|
+
service_status = Service.resume("ECHI-Converter")
|
135
|
+
service_status = "Service successfully resumed"
|
129
136
|
when "delete"
|
130
137
|
Service.delete("ECHI-Converter")
|
138
|
+
service_status = "Service successfully deleted"
|
139
|
+
when "status"
|
140
|
+
service_status = Service.status("ECHI-Converter").current_state
|
131
141
|
end
|
132
|
-
service_status
|
133
|
-
return service_status.current_state
|
142
|
+
return service_status
|
134
143
|
rescue => err
|
135
144
|
return err
|
136
145
|
end
|
data/lib/echi-converter.rb
CHANGED
@@ -243,7 +243,6 @@ module EchiConverter
|
|
243
243
|
def fetch_ftp_files
|
244
244
|
attempts = 0
|
245
245
|
ftp_session = -1
|
246
|
-
files_to_process = Array.new
|
247
246
|
while ftp_session == -1 do
|
248
247
|
ftp_session = connect_ftpsession
|
249
248
|
if ftp_session == -1
|
@@ -262,12 +261,9 @@ module EchiConverter
|
|
262
261
|
files = ftp_session.list('chr*')
|
263
262
|
file_cnt = 0
|
264
263
|
files.each do | file |
|
265
|
-
#ACTION: Need to detect which OS we are running on and then parse the ftp data appropriately
|
266
264
|
file_data = file.split(' ')
|
267
|
-
|
268
|
-
local_filename
|
269
|
-
ftp_session.getbinaryfile(remote_filename, local_filename)
|
270
|
-
files_to_process[file_cnt] = remote_filename
|
265
|
+
local_filename = $workingdir + '/../files/to_process/' + file_data[8]
|
266
|
+
ftp_session.getbinaryfile(file_data[8], local_filename)
|
271
267
|
if $config["echi_ftp_delete"] == 'Y'
|
272
268
|
begin
|
273
269
|
ftp_session.delete(remote_filename)
|
@@ -282,7 +278,7 @@ module EchiConverter
|
|
282
278
|
@log.fatal "Could not fetch from ftp server - " + err
|
283
279
|
end
|
284
280
|
end
|
285
|
-
return
|
281
|
+
return
|
286
282
|
end
|
287
283
|
end
|
288
284
|
|
data/lib/main.rb
CHANGED
@@ -35,7 +35,7 @@ end
|
|
35
35
|
#Our Main loop
|
36
36
|
loop do
|
37
37
|
#Process the files
|
38
|
-
|
38
|
+
fetch_ftp_files
|
39
39
|
#Grab filenames from the to_process directory after an FTP fetch, so if the
|
40
40
|
#system fails it may pick up where it left off
|
41
41
|
to_process_dir = $workingdir + "/../files/to_process/"
|
data/lib/main_win32.rb
CHANGED
@@ -9,7 +9,20 @@ class EchiDaemon < Daemon
|
|
9
9
|
require $workingdir + '/echi-converter.rb'
|
10
10
|
include EchiConverter
|
11
11
|
|
12
|
-
def
|
12
|
+
def service_stop
|
13
|
+
@log.info "ECHI-Converter service stopped"
|
14
|
+
@log.close
|
15
|
+
end
|
16
|
+
|
17
|
+
def service_pause
|
18
|
+
@log.info "ECHI-Converter service paused"
|
19
|
+
end
|
20
|
+
|
21
|
+
def service_resume
|
22
|
+
@log.info "ECHI-Converter service resumed"
|
23
|
+
end
|
24
|
+
|
25
|
+
def service_init
|
13
26
|
#Open the configuration file
|
14
27
|
configfile = $workingdir + '/../config/application.yml'
|
15
28
|
$config = YAML::load(File.open(configfile))
|
@@ -27,53 +40,53 @@ class EchiDaemon < Daemon
|
|
27
40
|
|
28
41
|
#Open the logfile with appropriate output level
|
29
42
|
initiate_logger
|
30
|
-
|
43
|
+
@log.info "ECHI-Converter service initializing"
|
44
|
+
|
31
45
|
#If configured for database insertion, connect to the database
|
32
46
|
if $config["export_type"] == 'database' || $config["export_type"] == 'both'
|
33
47
|
connect_database
|
34
48
|
end
|
35
|
-
|
36
|
-
@log.info "Running..."
|
37
49
|
end
|
38
50
|
|
39
51
|
def service_main
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
52
|
+
@log.info "ECHI-Converter service started"
|
53
|
+
while running?
|
54
|
+
if state == RUNNING
|
55
|
+
#Process the files
|
56
|
+
fetch_ftp_files
|
57
|
+
#Grab filenames from the to_process directory after an FTP fetch, so if the
|
58
|
+
#system fails it may pick up where it left off
|
59
|
+
to_process_dir = $workingdir + "/../files/to_process/"
|
46
60
|
|
47
|
-
|
48
|
-
|
61
|
+
#Establish where to copy the processed files to
|
62
|
+
@processeddirectory = set_directory($workingdir)
|
49
63
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
Dir.entries(to_process_dir).each do | file |
|
65
|
+
if file.slice(0,3) == 'chr'
|
66
|
+
if $config["echi_format"] == 'BINARY'
|
67
|
+
record_cnt = convert_binary_file file
|
68
|
+
elsif $config["echi_format"] == 'ASCII'
|
69
|
+
record_cnt = process_ascii file
|
70
|
+
end
|
71
|
+
@log.info "Processed file #{file} with #{record_cnt.to_s} records"
|
56
72
|
end
|
57
|
-
@log.info "Processed file #{file} with #{record_cnt.to_s} records"
|
58
73
|
end
|
59
|
-
end
|
60
74
|
|
61
|
-
|
75
|
+
sleep $config["fetch_interval"]
|
62
76
|
|
63
|
-
|
64
|
-
|
65
|
-
|
77
|
+
#Make sure we did not lose our database connection while we slept
|
78
|
+
if ActiveRecord::Base.connected? == 'FALSE'
|
79
|
+
connect_database
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
if state == PAUSED
|
84
|
+
@log.info "ECHI-Converter service paused"
|
85
|
+
sleep $config["fetch_interval"]
|
66
86
|
end
|
67
87
|
end
|
68
88
|
end
|
69
|
-
|
70
|
-
def service_cleanup
|
71
|
-
#Close the logfile
|
72
|
-
@log.info "Shutdown..."
|
73
|
-
@log.close
|
74
|
-
end
|
75
89
|
end
|
76
90
|
|
77
91
|
d = EchiDaemon.new
|
78
|
-
d.mainloop
|
79
|
-
d.service_cleanup
|
92
|
+
d.mainloop
|
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.1</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘echi-converter’</h1>
|
39
39
|
|
@@ -87,7 +87,7 @@
|
|
87
87
|
<li><a href="http://daemons.rubyforge.org/">Daemons v1.0.7+</a></li>
|
88
88
|
<li><a href="http://fastercsv.rubyforge.org/">FasterCSV v1.2.0+</a></li>
|
89
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.
|
90
|
+
# <a href="http://win32utils.rubyforge.org/">Win32-service v.0.5.0+</a> (Manual install for Windows only)</li>
|
91
91
|
<li><a href="http://rubyforge.org/projects/seattlerb/">Hoe v1.2.2+</a></li>
|
92
92
|
</ol>
|
93
93
|
|
@@ -161,11 +161,12 @@
|
|
161
161
|
|
162
162
|
|
163
163
|
<ol>
|
164
|
-
<li>echi-converter install myproject – install the service (must specify complete path such as c:\path\to\my\project )</li>
|
164
|
+
<li>echi-converter install myproject – install the service (must specify complete path such as c:\path\to\my\project – if the directory name or path has any spaces, please enclose the ‘myproject’ in double quotes )</li>
|
165
165
|
<li>echi-converter start – start the service</li>
|
166
166
|
<li>echi-converter stop – stop the service</li>
|
167
167
|
<li>echi-converter pause – pause the service</li>
|
168
168
|
<li>echi-converter resume – resume the service</li>
|
169
|
+
<li>echi-converter status – returns the status of a configured service</li>
|
169
170
|
<li>echi-converter uninstall – uninstall the service</li>
|
170
171
|
<li>echi-converter delete – delete the service”</li>
|
171
172
|
</ol>
|
@@ -184,21 +185,6 @@
|
|
184
185
|
|
185
186
|
<pre syntax="ruby">echi-converter stop myproject</pre>
|
186
187
|
|
187
|
-
<h2>Limitations</h2>
|
188
|
-
|
189
|
-
|
190
|
-
<p>Items to be done to move this out of alpha stage:</p>
|
191
|
-
|
192
|
-
|
193
|
-
<ol>
|
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>
|
199
|
-
</ol>
|
200
|
-
|
201
|
-
|
202
188
|
<h2>Screencast</h2>
|
203
189
|
|
204
190
|
|
@@ -231,7 +217,7 @@
|
|
231
217
|
|
232
218
|
<p>Comments are welcome. Send an email to <a href="mailto:jason@goecke.net">jason [at] goecke.net</a>.</p>
|
233
219
|
<p class="coda">
|
234
|
-
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>,
|
220
|
+
<a href="mailto:drnicwilliams@gmail.com">Dr Nic</a>, 4th November 2007<br>
|
235
221
|
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
|
236
222
|
</p>
|
237
223
|
</div>
|
data/website/index.txt
CHANGED
@@ -38,8 +38,8 @@ h2. Requirements
|
|
38
38
|
# "Daemons v1.0.7+":http://daemons.rubyforge.org/
|
39
39
|
# "FasterCSV v1.2.0+":http://fastercsv.rubyforge.org/
|
40
40
|
# "Rake v0.7.3+":http://rake.rubyforge.org/
|
41
|
-
# "Win32-service v.0.5.
|
42
|
-
|
41
|
+
# "Win32-service v.0.5.0+":http://win32utils.rubyforge.org/ (Manual install for Windows only)
|
42
|
+
# "Hoe v1.2.2+":http://rubyforge.org/projects/seattlerb/
|
43
43
|
|
44
44
|
|
45
45
|
h2. Installing
|
@@ -86,11 +86,12 @@ For *NIX:
|
|
86
86
|
|
87
87
|
For Windows:
|
88
88
|
|
89
|
-
# echi-converter install myproject - install the service (must specify complete path such as c:\path\to\my\project )
|
89
|
+
# echi-converter install myproject - install the service (must specify complete path such as c:\path\to\my\project - if the directory name or path has any spaces, please enclose the 'myproject' in double quotes )
|
90
90
|
# echi-converter start - start the service
|
91
91
|
# echi-converter stop - stop the service
|
92
92
|
# echi-converter pause - pause the service
|
93
93
|
# echi-converter resume - resume the service
|
94
|
+
# echi-converter status - returns the status of a configured service
|
94
95
|
# echi-converter uninstall - uninstall the service
|
95
96
|
# echi-converter delete - delete the service"
|
96
97
|
|
@@ -104,15 +105,6 @@ Stop the daemon/service:
|
|
104
105
|
|
105
106
|
<pre syntax="ruby">echi-converter stop myproject</pre>
|
106
107
|
|
107
|
-
|
108
|
-
h2. Limitations
|
109
|
-
|
110
|
-
Items to be done to move this out of alpha stage:
|
111
|
-
|
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
|
115
|
-
|
116
108
|
h2. Screencast
|
117
109
|
|
118
110
|
You may view the screencast on howto install and use the ECHI-Converter "here":http://www.screencast.com/t/lQQkIVkUZMr.
|
@@ -121,7 +113,6 @@ h2. Forum
|
|
121
113
|
|
122
114
|
"Google Groups - ECHI Converter":http://groups.google.com/group/echi-converter
|
123
115
|
|
124
|
-
|
125
116
|
h2. How to submit patches
|
126
117
|
|
127
118
|
Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
|
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.1
|
7
|
+
date: 2007-11-04 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
|