def handle(self, *args, **options): source = options.get('source') target = options.get('target') records = int( options.get('records') ) start = int( options.get('start') ) dm_source = DatazillaModel(source) dm_target = DatazillaModel(target) data_iter = dm_source.getAllTestData(start) iterations = 0 for d in data_iter: for data in d: deserialized_data = json.loads( data['data'] ) if options['debug']: self.stdout.write(data['data'] + "\n") else: if options['show']: self.stdout.write(data['data'] + "\n") dm_target.loadTestData(deserialized_data, data['data']) iterations += 1 if iterations == records: dm_source.disconnect() dm_target.disconnect() return
def graphs(request, project=""): #### #Load any signals provided in the page #### signals = [] timeRanges = utils.get_time_ranges() for s in SIGNALS: if s in request.POST: signals.append( { 'value':urllib.unquote( request.POST[s] ), 'name':s } ) ### #Get reference data ### cacheKey = str(project) + '_reference_data' jsonData = '{}' mc = memcache.Client([settings.DATAZILLA_MEMCACHED], debug=0) compressedJsonData = mc.get(cacheKey) timeKey = 'days_30' ##reference data found in the cache: decompress## if compressedJsonData: jsonData = zlib.decompress( compressedJsonData ) else: #### #reference data has not been cached: #serialize, compress, and cache #### dm = DatazillaModel(project) refData = dm.getTestReferenceData() dm.disconnect() refData['time_ranges'] = timeRanges jsonData = json.dumps(refData) mc.set(str(project) + '_reference_data', zlib.compress( jsonData ) ) data = { 'time_key':timeKey, 'reference_json':jsonData, 'signals':signals } #### #Caller has provided the view parent of the signals, load in page. #This occurs when a data view is in its Pane form and is detached #to exist on it's own page. #### parentIndexKey = 'dv_parent_dview_index' if parentIndexKey in request.POST: data[parentIndexKey] = request.POST[parentIndexKey] return render_to_response('graphs.views.html', data)
def dataview(request, project="", method=""): procPath = "graphs.views." ##Full proc name including base path in json file## fullProcPath = "%s%s" % (procPath, method) if settings.DEBUG: ### #Write IP address and datetime to log ### print "Client IP:%s" % (request.META['REMOTE_ADDR']) print "Request Datetime:%s" % (str(datetime.datetime.now())) json = "" if method in DATAVIEW_ADAPTERS: dm = DatazillaModel(project) if 'adapter' in DATAVIEW_ADAPTERS[method]: json = DATAVIEW_ADAPTERS[method]['adapter'](project, method, request, dm) else: if 'fields' in DATAVIEW_ADAPTERS[method]: fields = [] for f in DATAVIEW_ADAPTERS[method]['fields']: if f in request.POST: fields.append( dm.dhub.escapeString( request.POST[f] ) ) elif f in request.GET: fields.append( dm.dhub.escapeString( request.GET[f] ) ) if len(fields) == len(DATAVIEW_ADAPTERS[method]['fields']): json = dm.dhub.execute(proc=fullProcPath, debug_show=settings.DEBUG, placeholders=fields, return_type='table_json') else: json = '{ "error":"%s fields required, %s provided" }' % (str(len(DATAVIEW_ADAPTERS[method]['fields'])), str(len(fields))) else: json = dm.dhub.execute(proc=fullProcPath, debug_show=settings.DEBUG, return_type='table_json') dm.disconnect(); else: json = '{ "error":"Data view name %s not recognized" }' % method return HttpResponse(json, mimetype=APP_JS)
def setTestData(request): jsonData = '{"error":"No POST data found"}' if 'data' in request.POST: jsonData = request.POST['data'] unquotedJsonData = urllib.unquote(jsonData) data = json.loads( unquotedJsonData ) dm = DatazillaModel(project) dm.loadTestData( data, unquotedJsonData ) dm.disconnect() jsonData = json.dumps( { 'loaded_test_pages':len(data['results']) } ) return HttpResponse(jsonData, mimetype=APP_JS)
def loadTestCollection(project): gm = DatazillaModel(project) products = gm.getProducts('id') for productName in products: if products[ productName ]['product'] and \ products[ productName ]['version'] and \ products[ productName ]['branch']: name = "%s %s %s" % (products[ productName ]['product'], products[ productName ]['version'], products[ productName ]['branch']) id = gm.set_data('set_test_collection', [ name, "", name ]) gm.set_data('set_test_collection_map', [ id, products[ productName ]['id'] ]) gm.disconnect()
def cacheTestSummaries(project): gm = DatazillaModel(project) dataIter = gm.getAllSummaryCache() mc = memcache.Client([settings.DATAZILLA_MEMCACHED], debug=0) for d in dataIter: for data in d: key = utils.get_cache_key( project, data['item_id'], data['item_data'], ) rv = mc.set(key, zlib.compress( data['value'] )) if not rv: sys.stderr.write("ERROR: Failed to store object in memcache: %s, %s\n" % ( str(data['item_id']), data['item_data'] ) ) gm.disconnect()
def buildTestSummaries(project): gm = DatazillaModel(project) timeRanges = utils.get_time_ranges() products = gm.getProducts() for productName in products: for tr in ['days_7', 'days_30']: table = gm.getTestRunSummary(str( timeRanges[tr]['start']), str( timeRanges[tr]['stop']), [ products[ productName ] ], [], []) jsonData = json.dumps( table ) gm.setSummaryCache( products[ productName ], tr, jsonData ) gm.disconnect()