You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2019/11/29 16:56:09 UTC
[whimsy] branch master updated: Update parsing for list messages
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git
The following commit(s) were added to refs/heads/master by this push:
new 5b01493 Update parsing for list messages
5b01493 is described below
commit 5b0149391e50ddb624c100d5f16efce5c261a73b
Author: Sebb <se...@apache.org>
AuthorDate: Fri Nov 29 16:56:00 2019 +0000
Update parsing for list messages
---
www/status/monitors/svn.rb | 94 ++++++++++++++++++++++++++++------------------
1 file changed, 58 insertions(+), 36 deletions(-)
diff --git a/www/status/monitors/svn.rb b/www/status/monitors/svn.rb
index 1fef172..b57d101 100644
--- a/www/status/monitors/svn.rb
+++ b/www/status/monitors/svn.rb
@@ -3,36 +3,7 @@
#
=begin
Sample input:
----- cut here ---
-
-/srv/svn/Meetings
-Updating '.':
-At revision 67610.
-
-/srv/svn/site-root
-Updating '.':
-U index.html
-Updated to revision 1797393.
-
-/srv/svn/site-root
-A site-root/extpaths.txt
- U site-root
-Checked out revision 1797381.
-
-/x1/srv/svn/personnel-duties
-Updating '.':
-svn: E175002: Unexpected HTTP status 400 'Bad Request' on '/repos/private/!svn/rvr/76960/foundation/officers/personnel-duties'
-
-/x1/srv/svn/personnel-duties
-#!: failed!
-#!: Updating '.':
-#!: svn: E175002: Unexpected HTTP status 400 'Bad Request' on '/repos/private/!svn/rvr/76960/foundation/officers/personnel-duties'
-#!: will retry in 10 seconds
-Updating '.':
-svn: E175002: Unexpected HTTP status 400 'Bad Request' on '/repos/private/!svn/rvr/76960/foundation/officers/personnel-duties'
-Updated to revision 1797393.
-
----- cut here ---
+See DATA section after __END__
Output status level can be:
Success - workspace is up to date
@@ -45,7 +16,7 @@ Danger - unexpected text in log file
require 'fileutils'
# Match revision messages
-REV_RE = %r{^(Checked out|Updated to|At) revision \d+\.$}
+REV_RE = %r{^(Checked out|Updated to|At|List updated from \d+ to|List is at) revision \d+\.$}
def Monitor.svn(previous_status)
logdir = File.expand_path('../../../logs', __FILE__)
@@ -53,8 +24,13 @@ def Monitor.svn(previous_status)
FileUtils.mkdir(archive) unless File.directory?(archive)
# read cron log
- log = File.expand_path('../../../logs/svn-update', __FILE__)
- fdata = File.open(log) {|file| file.flock(File::LOCK_EX); file.read}
+ if $0 == __FILE__ and ARGV.first == '__DATA__'
+ log = nil
+ fdata = DATA.read
+ else
+ log = File.expand_path('../../../logs/svn-update', __FILE__)
+ fdata = File.open(log) {|file| file.flock(File::LOCK_EX); file.read}
+ end
updates = fdata.split(%r{\n(?:/\w+)*/srv/svn/})[1..-1]
status = {}
@@ -109,7 +85,7 @@ def Monitor.svn(previous_status)
# save as the highest level seen
%w{danger warning}.each do |lvl|
- if seen_level[lvl]
+ if seen_level[lvl] and log
# Save a copy of the log; append the severity so can track more problems
file = File.basename(log)
FileUtils.copy log, File.join(archive, file + '.' + lvl), preserve: true
@@ -122,6 +98,52 @@ end
# for debugging purposes
if __FILE__ == $0
- require_relative 'unit_test'
- runtest('svn') # must agree with method name above
+ if ARGV.first == '__DATA__'
+ response = Monitor.svn(nil) # must agree with method name above
+ data = response[:data]
+ data.each do |k,v|
+ puts "#{k} #{data[k][:level]} #{data[k][:title]} #{data[k][:data]}"
+ end
+ else
+ require_relative 'unit_test'
+ runtest('svn') # must agree with method name above
+ end
end
+
+# test data
+__END__
+
+/srv/svn/cclas
+#!: Updating listing file
+List updated from 0 to revision 93888.
+
+/srv/svn/iclas
+#!: Updating listing file
+List is at revision 93865.
+
+/srv/svn/Meetings
+Updating '.':
+At revision 67610.
+
+/srv/svn/site-root
+Updating '.':
+U index.html
+Updated to revision 1797393.
+
+/srv/svn/site-root
+A site-root/extpaths.txt
+ U site-root
+Checked out revision 1797381.
+
+/x1/srv/svn/personnel-duties
+Updating '.':
+svn: E175002: Unexpected HTTP status 400 'Bad Request' on '/repos/private/!svn/rvr/76960/foundation/officers/personnel-duties'
+
+/x1/srv/svn/personnel-duties
+#!: failed!
+#!: Updating '.':
+#!: svn: E175002: Unexpected HTTP status 400 'Bad Request' on '/repos/private/!svn/rvr/76960/foundation/officers/personnel-duties'
+#!: will retry in 10 seconds
+Updating '.':
+svn: E175002: Unexpected HTTP status 400 'Bad Request' on '/repos/private/!svn/rvr/76960/foundation/officers/personnel-duties'
+Updated to revision 1797393.