It seems like the GWT code involved in this problem is very minimal. If you want to eliminate the GWT component, I would suggest you write a very small JavaScript driver for your class and see if your second query works.
-Eric. On Jan 21, 11:30 am, Craig Schroeder <[email protected]> wrote: > Hey VizBoy, > Not sure if you were referring to me here but I am going to paste in my code > below... > > Hopefully someone can help me figure out if this is an issue in GWT or the > GWT API, or some environmental issue on my end. I don't see any errors in > application logic or system responses so I'm not sure why one request works > and then subsequent ones don't. > > Thanks, > Craig > > ##########python service############# > import gviz_api, mmap, re, os, timeit > from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer > > def getResults(args): > fname = "xxxxxxxxxxxx-" + args[0] > fname = os.path.join("../audit", fname) > try: > fileobj = open(fname) > except: > return "file not found" > queryID = args[1] > try: > filters = args[2:] > except: > pass > flag = False > > if len(filters) == 0: > try: > records[args[0]][args[1]] > description = {("key", "string"):("value", "number")} > data = records[args[0]][args[1]] > data_table = gviz_api.DataTable(description) > data_table.LoadData(data) > print > data_table.ToJSonResponse(columns_order=("key","value"),order_by=reports[args[1]]["sort"]) > return > data_table.ToJSonResponse(columns_order=("key","value"),order_by=reports[args[1]]["sort"]) > except KeyError: > print "KeyError" > if len(filters) == 0: > filemap = mmap.mmap(fileobj.fileno(), os.path.getsize(fname) , > access=mmap.ACCESS_READ) > else: > print "starting file filtering" > fileString = "" > fileList = [] > c=0 > for line in fileobj: > c+=1 > if c%1000 == 0: > print c > for f in filters: > if flag: > break > if f not in line: > flag = True > if not flag: > fileList.append(line) > flag = False > print "ending file filtering" > fileString = ''.join(fileList) > pat = re.compile(reports[queryID]["regex"]) > count = {} > if len(filters) == 0: > for m in pat.findall(filemap): > try: > count[m] +=1 > except KeyError: > count[m] = 1 > else: > for m in pat.findall(fileString): > try: > count[m] +=1 > except KeyError: > count[m] = 1 > if len(filters) == 0: > try: > records[args[0]][args[1]] = count > except: > records[args[0]] = {} > records[args[0]][args[1]] = count > print "just before returning" > try: > filemap.close() > except: > pass > fileString = "" > fileobj.close() > description = {("key", "string"):("value", "number")} > if len(filters) == 0: > data = records[args[0]][args[1]] > else: > data = count > data_table = gviz_api.DataTable(description) > data_table.LoadData(data) > print > data_table.ToJSonResponse(columns_order=("key","value"),order_by=reports[args[1]]["sort"]) > return > data_table.ToJSonResponse(columns_order=("key","value"),order_by=reports[args[1]]["sort"]) > > class MyHandler(BaseHTTPRequestHandler): > > def do_GET(self): > if self.path.find("?") != -1: > queryString = self.path.split("?")[1] > queryArgs = > queryString.split("tq=")[1].split("&")[0].split("%40") > urlargs = self.path.split("?")[0].split("/") > print urlargs > self.send_response(200) > self.send_header('Content-type', 'text/html') > self.end_headers() > if self.path == "/": > self.wfile.write("Don't know what you're trying to do") > return > if urlargs[1] == "gwt": > if urlargs[2] == "menu": > self.wfile.write() > else: > self.wfile.write(getResults(queryArgs)) > self.wfile.write(open(xxxxxxxx).read()) > return > reports = {} > reports["sessioncount"] = {} > reports["sessioncount"]["description"] = "Counts Product Session Starts" > reports["sessioncount"]["regex"] = r"ProductSessionStartAudit" > reports["sessioncount"]["sort"] = "value" > > reports["1pm"] = {} > reports["1pm"]["description"] = "Counts all activities during the 1pm hour" > reports["1pm"]["regex"] = r"(?<=\|\|\d\d/\d\d/\d\d\d\d )13:\d\d" > reports["1pm"]["sort"] = "key" > > reports["top-locids"] = {} > reports["top-locids"]["description"] = "Ranks locids" > reports["top-locids"]["regex"] = r"(?<=-)[-A-Za-z0-9_]*(?=-[^-|]{30,32})" > reports["top-locids"]["sort"] = "value" > > records = {} > > def main(): > try: > PORT = 8585 > server = HTTPServer(('', PORT), MyHandler) > print 'started server on %s...' % PORT > > server.serve_forever() > > except (KeyboardInterrupt, SystemExit): > print "closing..." > server.socket.close() > > if __name__ == '__main__': > main() > ################################### > > ##########dashboard.java############ > package com.xxxxxxx.client; > > import com.google.gwt.core.client.EntryPoint; > import com.google.gwt.user.client.Window; > import com.google.gwt.user.client.ui.ChangeListener; > import com.google.gwt.user.client.ui.ClickListener; > import com.google.gwt.user.client.ui.HorizontalPanel; > import com.google.gwt.user.client.ui.ListBox; > import com.google.gwt.user.client.ui.Panel; > import com.google.gwt.user.client.ui.RootPanel; > import com.google.gwt.user.client.ui.Widget; > import com.google.gwt.visualization.client.AjaxLoader; > import com.google.gwt.visualization.client.DataTable; > import com.google.gwt.visualization.client.Query; > import com.google.gwt.visualization.client.QueryResponse; > import com.google.gwt.visualization.client.Query.Callback; > import com.google.gwt.visualization.client.visualizations.ColumnChart; > import com.google.gwt.visualization.client.visualizations.Table; > > import org.gwtwidgets.client.ui.cal.CalendarDate; > import org.gwtwidgets.client.ui.cal.SimpleCalendar; > > public class dashboard implements EntryPoint { > public static class vizData { > public static String vizDate = ""; > public static String vizQuery = ""; > public static int vizID; > public static ColumnChart col; > public static Table tab; > public static int count = 0;} > > public void onModuleLoad() { > // Create a callback to be called when the visualization API > // has been loaded. > Runnable onLoadCallback = new Runnable() { > public void run() { > Panel panel = RootPanel.get(); > vizData.col = new ColumnChart(); > vizData.tab = new Table(); > panel.add(vizData.col); > panel.add(vizData.tab); > } > }; > > Panel panel = RootPanel.get(); > > HorizontalPanel top = new HorizontalPanel(); > > SimpleCalendar cal = new SimpleCalendar(); > cal.addClickListener(new ClickListener() { > @SuppressWarnings("deprecation") > public void onClick(Widget sender) { > CalendarDate date = ((SimpleCalendar) sender).getDateSelected(); > int y = date.getDate().getYear() + 1900; > int m = date.getDate().getMonth() + 1; > int d = date.getDate().getDate(); > String mm; > String dd; > if (m < 10) { > mm = "0" + Integer.toString(m); > } > else { > mm = Integer.toString(m); > } > if (d < 10) { > dd = "0" + Integer.toString(d); > } > else { > dd = Integer.toString(d); > } > vizData.vizDate = Integer.toString(y) + "-" + mm + "-" + dd; > updateData();} > > }); > top.add(cal); > > ListBox query = new ListBox(); > query.setTitle("Select a base query"); > query.addItem("sessioncount"); > vizData.vizQuery = "sessioncount"; > query.addItem("1pm"); > query.addChangeListener(new ChangeListener() { > public void onChange(Widget sender) { > vizData.vizQuery = ((ListBox) sender).getValue(((ListBox) > sender).getSelectedIndex()); > if (vizData.vizDate != ""){ > updateData();} > } > > }); > top.add(query); > > panel.add(top); > > // Load the visualization api, passing the onLoadCallback to be called > // when loading is done. > AjaxLoader.loadVisualizationApi(onLoadCallback, ColumnChart.PACKAGE, > Table.PACKAGE); > } > > private ColumnChart.Options colOptions(String title) { > ColumnChart.Options options = ColumnChart.Options.create(); > options.setWidth(500); > options.setHeight(330); > options.set3D(true); > options.setTitle(title); > > return options; > } > > private Table.Options tabOptions() { > Table.Options options = Table.Options.create(); > options.setPageSize(10); > return options; > } > > private void updateData() { > Query query = Query.create("http://xxxxxxxx.com:8585/gwt/"); > query.setQuery(vizData.vizDate+"@"+vizData.vizQuery); > query.send(new Callback(){ > public void onResponse(QueryResponse response) { > if (response.isError()) { > Window.alert("An error occured: Please try again."); > } > DataTable data = response.getDataTable(); > vizData.col.draw(data, colOptions(vizData.vizQuery)); > vizData.tab.draw(data, tabOptions()); > } > }); > } > > } > > ################################################################# > > ######################dashboard.gwt.xml########################### > <module> > > <!-- Inherit the core Web Toolkit stuff. --> > <inherits name='com.google.gwt.user.User'/> > <!-- Inherit the default GWT style sheet. You can change --> > <!-- the theme of your GWT application by uncommenting --> > <!-- any one of the following lines. --> > <inherits name='com.google.gwt.user.theme.standard.Standard'/> > <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> --> > <!-- <inherits > ... > > read more » --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en -~----------~----~----~----~------~----~------~--~---
