Browse files

Some fixes to make dynamic reports work.

Still many issues left.
  • Loading branch information...
1 parent 7a8dc70 commit a39d026a3f289df90eac61f11c7015cb51a7c94a @scrapper scrapper committed Jul 1, 2013
View
2 lib/taskjuggler/ProjectFileParser.rb
@@ -105,7 +105,7 @@ def parseReportAttributes(report, attributes)
open(attributes, false, true)
@property = report
@project = report.project
- parse(:reportAttributes)
+ parse(:dynamicAttributes)
end
private
View
2 lib/taskjuggler/TextParser/Scanner.rb
@@ -193,7 +193,7 @@ class BufferStreamHandle < StreamHandle
def initialize(buffer, log, textScanner)
super(log, textScanner)
begin
- @stream = StringIO.new(buffer.forceUTF8Encoding)
+ @stream = StringIO.new(buffer)
rescue
error('bufferEncoding', $!.message)
end
View
4 lib/taskjuggler/TjpSyntaxRules.rb
@@ -1030,6 +1030,10 @@ def rule_durationUnitOrPercent
descr('days')
end
+ def rule_dynamicAttributes
+ pattern(%w( !reportAttributes . ))
+ end
+
def rule_export
pattern(%w( !exportHeader !exportBody ), lambda {
@property = @property.parent
View
3 lib/taskjuggler/daemon/ProcessIntercom.rb
@@ -103,8 +103,9 @@ def connect(stdout, stderr, stdin, silent)
$stdout = stdout if stdout
$stderr = stderr if stdout
$stdin = stdin if stdin
- debug('', 'IO is now routed to the client')
Log.silent = silent
+ Term::ANSIColor.coloring = !silent
+ debug('', 'IO is now routed to the client')
true
end
View
29 lib/taskjuggler/daemon/ReportServlet.rb
@@ -15,6 +15,7 @@
require 'taskjuggler/MessageHandler'
require 'taskjuggler/RichText'
require 'taskjuggler/HTMLDocument'
+require 'taskjuggler/URLParameter'
require 'taskjuggler/daemon/DaemonConnector'
class TaskJuggler
@@ -50,10 +51,14 @@ def do_GET(req, res)
else
debug('', "Report #{reportId} of project #{projectId} requested")
attributes = req.query['attributes'] || ''
- attributes = URLParameter.decode(attributes) unless attributes.empty?
+ unless attributes.empty?
+ attributes = URLParameter.decode(attributes)
+ end
+ debug('', "Attributes: #{attributes}")
generateReport(projectId, reportId, attributes)
end
rescue
+ error('get_req_failed', "Cannot serve GET request: #{req}\n#{$!}")
end
end
@@ -116,9 +121,10 @@ def generateReport(projectId, reportId, attributes)
end
# Ask the ReportServer to generate the reports with the provided ID.
+ retVal = true
begin
- @reportServer.generateReport(@rs_authKey, reportId, false, nil,
- attributes)
+ retVal = @reportServer.generateReport(@rs_authKey, reportId, false, nil,
+ attributes)
rescue
stdOut.rewind
stdErr.rewind
@@ -142,12 +148,17 @@ def generateReport(projectId, reportId, attributes)
broker.disconnect
@res['content-type'] = 'text/html'
- stdErr.rewind
- $stderr.puts stdErr.read
- # To read the $stdout of the ReportServer we need to rewind the buffer
- # and then read the full text.
- stdOut.rewind
- @res.body = stdOut.read
+ if retVal
+ # To read the $stdout of the ReportServer we need to rewind the buffer
+ # and then read the full text.
+ stdOut.rewind
+ @res.body = stdOut.read
+ else
+ stdErr.rewind
+ error('get_req_stderr',
+ "Error while parsing attribute definition:\n-8<-\n" +
+ "#{attributes}\n->8-\n#{stdErr.read}")
+ end
end
def generateWelcomePage(projectId)

0 comments on commit a39d026

Please sign in to comment.