Class: Kpigen::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/kpigen/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Message

Returns a new instance of Message.



7
8
9
# File 'lib/kpigen/message.rb', line 7

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



5
6
7
# File 'lib/kpigen/message.rb', line 5

def app
  @app
end

#messageObject

Returns the value of attribute message.



5
6
7
# File 'lib/kpigen/message.rb', line 5

def message
  @message
end

Instance Method Details



175
176
177
# File 'lib/kpigen/message.rb', line 175

def print_about_to_fetch_source(source)
  print "Looking for files in: #{source.storage_path}\n"
end


199
200
201
# File 'lib/kpigen/message.rb', line 199

def print_already_accessed_source(source,last_accessed,next_access)
  print "Last checked #{source.storage_path} at #{last_accessed} will check again after #{next_access}.\n"
end


191
192
193
# File 'lib/kpigen/message.rb', line 191

def print_archive_deleted(archive)
  print "Removed archive #{archive.storage_path}.\n"
end


156
157
158
159
160
161
162
163
164
165
# File 'lib/kpigen/message.rb', line 156

def print_archives(archives,show_password)
  if archives.empty?
    print_no_archives
  else
    msg = archives.size == 1 ? "The following archive is available:\n" : "The following #{archives.size} archives are available:\n"
    msg += archives.each_with_index.collect { |s,i| "  -- [#{i}] #{s.storage_path(show_password)} (#{s.mode})" }.join("\n")
    msg += "\n"
    print msg
  end
end


11
12
13
# File 'lib/kpigen/message.rb', line 11

def print_error(msg,e = nil)
  @app.message.print_error(msg,e)
end


86
87
88
# File 'lib/kpigen/message.rb', line 86

def print_file_downloaded(source, source_filename, dest_filename)
  print "  -- downloaded #{source_filename} (#{source.storage_server}) => #{dest_filename}\n"
end


82
83
84
# File 'lib/kpigen/message.rb', line 82

def print_file_not_downloaded(source, source_filename, dest_filename)
  print "Cannot find downloaded file #{dest_filename} (from #{source_filename} on #{source.storage_server})\n"
end


108
109
110
# File 'lib/kpigen/message.rb', line 108

def print_file_not_uploaded(target, source_filename, dest_filename)
  print "Cannot find uploaded file #{dest_filename} (from #{source_filename} on #{target.storage_server})\n"
end


37
38
39
40
41
42
# File 'lib/kpigen/message.rb', line 37

def print_found_source(source,last_accessed,show_password)
  msg = "The following source was found:\n"
  msg += "  -- #{source.storage_path(show_password)} (#{source.mode}, #{source.update_frequency})#{last_accessed_to_s(last_accessed)}"
  msg += "\n"
  print msg
end


171
172
173
# File 'lib/kpigen/message.rb', line 171

def print_get_big_t(big_t)
  print "Big T is #{big_t}"
end


148
149
150
# File 'lib/kpigen/message.rb', line 148

def print_new_archive(archive)
  print "Added #{archive.mode} archive #{archive.storage_path}\n"
end


29
30
31
# File 'lib/kpigen/message.rb', line 29

def print_new_source(source)
  print "Added #{source.mode} source #{source.storage_path} to be checked every #{source.update_frequency}\n"
end


125
126
127
# File 'lib/kpigen/message.rb', line 125

def print_new_target(target)
  print "Added #{target.mode} target #{target.storage_path}\n"
end


215
216
217
# File 'lib/kpigen/message.rb', line 215

def print_no_archive_format(archive,index)
  print "No format associated with #{archive.storage_path}.  To add a format, run 'archive format #{index} <path-to-format-csv>'\n"
end


112
113
114
# File 'lib/kpigen/message.rb', line 112

def print_no_archives
  print "No archives available.  For example, 'archive add /a/b/c'\n"
end


121
122
123
# File 'lib/kpigen/message.rb', line 121

def print_no_archives_for_gather
  print "No archive provided -- nowhere to put collected files\nFor example, 'archive add /a/b/c'\n"
end


90
91
92
93
94
95
96
# File 'lib/kpigen/message.rb', line 90

def print_no_files_to_download(next_check_time)
  if next_check_time.nil?
    print "  -- Nothing found.\n"
  else
    print "  -- Nothing found, will check again at #{next_check_time}.\n"
  end
end


55
56
57
# File 'lib/kpigen/message.rb', line 55

def print_no_sources
  print "No sources available.  For example, 'source add ftp deployer:[email protected]:/a/b/c 5minutes'\n"
end


219
220
221
# File 'lib/kpigen/message.rb', line 219

def print_no_target_format(target,index)
  print "No format associated with #{target.storage_path}.  To add a format, run 'target format #{index} <path-to-format-csv>'\n"
end


133
134
135
# File 'lib/kpigen/message.rb', line 133

def print_no_targets
  print "No targets available.  For example, 'target add ftp deployer:[email protected]:/a/b/c'\n"
end


59
60
61
# File 'lib/kpigen/message.rb', line 59

def print_no_targets_for_gather
  print "No targets available -- nowhere to place collected files.  For example, 'target add ftp deployer:[email protected]:/a/b/c'\n"
end


68
69
70
# File 'lib/kpigen/message.rb', line 68

def print_nothing_to_gather
  print "No sources provided -- nothing to gather\nFor example, 'source add ftp deployer:[email protected]:/a/b/c 5minutes'\n"
end


167
168
169
# File 'lib/kpigen/message.rb', line 167

def print_set_big_t(big_t)
  print "Setting Big T to #{big_t}"
end


208
209
210
211
212
213
# File 'lib/kpigen/message.rb', line 208

def print_sorted_file(index,inputfilename, outputfilename, duration)
  msg = "Sorted #{inputfilename} (column index #{index}) "
  msg += "into #{outputfilename} " if inputfilename != outputfilename
  msg += "in #{duration}\n"
  print msg
end


183
184
185
# File 'lib/kpigen/message.rb', line 183

def print_source_deleted(source)
  print "Removed source #{source.storage_path}.\n"
end


195
196
197
# File 'lib/kpigen/message.rb', line 195

def print_source_touched(source,time)
  print "Source #{source.storage_path} last checked at #{Eve::Message.friendly_now(time)}.\n"
end


44
45
46
47
48
49
50
51
52
53
# File 'lib/kpigen/message.rb', line 44

def print_sources(sources,all_accesses,show_password)
  if sources.empty?
    print_no_sources
  else
    msg = sources.size == 1 ? "The following source is available:\n" : "The following #{sources.size} sources are available:\n"
    msg += sources.each_with_index.collect { |s,i| "  -- [#{i}] #{s.storage_path(show_password)} (#{s.mode}, #{s.update_frequency})#{last_accessed_to_s(all_accesses[i])}" }.join("\n")
    msg += "\n"
    print msg
  end
end


19
20
21
22
23
24
25
26
27
# File 'lib/kpigen/message.rb', line 19

def print_storage_files(storage,files)
  if files.empty?
    print "No files available at #{storage.storage_path}.\n"
  else
    msg = "The following files are available at #{storage.storage_path}:\n"
    files.each { |f| msg += "  -- #{f}\n" }
    print msg
  end
end


187
188
189
# File 'lib/kpigen/message.rb', line 187

def print_target_deleted(target)
  print "Removed target #{target.storage_path}.\n"
end


137
138
139
140
141
142
143
144
145
146
# File 'lib/kpigen/message.rb', line 137

def print_targets(targets,show_password)
  if targets.empty?
    print_no_targets
  else
    msg = targets.size == 1 ? "The following target is available:\n" : "The following #{targets.size} targets are available:\n"
    msg += targets.each_with_index.collect { |s,i| "  -- [#{i}] #{s.storage_path(show_password)} (#{s.mode})" }.join("\n")
    msg += "\n"
    print msg
  end
end


152
153
154
# File 'lib/kpigen/message.rb', line 152

def print_unable_create_archive(input)
  print "Unable to add archive [#{input}]\n"
end


33
34
35
# File 'lib/kpigen/message.rb', line 33

def print_unable_create_source(input)
  print "Unable to add source [#{input}]\n"
end


129
130
131
# File 'lib/kpigen/message.rb', line 129

def print_unable_create_target(input)
  print "Unable to add target [#{input}]\n"
end


72
73
74
75
# File 'lib/kpigen/message.rb', line 72

def print_unable_to_access_data_storage(source,e = nil)
  msg = "Unable to access #{source.storage_path}"
  e.nil? ? print("#{msg}\n") : print_error(msg,e)
end


116
117
118
119
# File 'lib/kpigen/message.rb', line 116

def print_unable_to_clean_file(source,target,e = nil)
  msg = "Unable to clean #{source} (to be stored at #{target})."
  e.nil? ? print("#{msg}\n") : print_error(msg,e)
end


77
78
79
80
# File 'lib/kpigen/message.rb', line 77

def print_unable_to_download_file(source, source_filename, dest_filename, e = nil)
  msg = "Unable to download #{source_filename} on #{source.storage_server} to #{dest_filename}"
  e.nil? ? print("#{msg}\n") : print_error(msg,e)
end


63
64
65
66
# File 'lib/kpigen/message.rb', line 63

def print_unable_to_process_file(filename,e = nil)
  msg = "Unable to process #{filename}"
  e.nil? ? print("#{msg}\n") : print_error(msg,e)
end


203
204
205
206
# File 'lib/kpigen/message.rb', line 203

def print_unable_to_sort_file(filename, e = nil)
  msg = "Unable to sort #{filename}"
  e.nil? ? print("#{msg}\n") : print_error(msg,e)
end


98
99
100
101
# File 'lib/kpigen/message.rb', line 98

def print_unable_to_upload_file(target, source_filename, dest_filename, e = nil)
  msg = "Unable to upload #{source_filename} on #{target.storage_server} to #{dest_filename}"
  e.nil? ? print("#{msg}\n") : print_error(msg,e)
end


103
104
105
106
# File 'lib/kpigen/message.rb', line 103

def print_unable_to_upload_text(target, source_text, dest_filename, e = nil)
  msg = "Unable to upload '#{source_text}' on #{target.storage_server} to #{dest_filename}"
  e.nil? ? print("#{msg}\n") : print_error(msg,e)
end


223
224
225
# File 'lib/kpigen/message.rb', line 223

def print_unknown_format_file(storage,filename)
  print "Unable to set format #{filename} to #{storage}.\n"
end


179
180
181
# File 'lib/kpigen/message.rb', line 179

def print_unknown_storage_lookup(cmd, index)
  print "Invalid index (#{index}), ignoring '#{cmd}' command.\n"
end


15
16
17
# File 'lib/kpigen/message.rb', line 15

def print_version
  print "kpigen, version #{Kpigen::VERSION}\n"
end