https://circleci.com/docs/2.0/collect-test-data/
976271
function circleReportPath () {
	const CIRCLE_JOB = process.env.CIRCLE_JOB;
	const CIRCLE_WORKING_DIRECTORY = process.env.CIRCLE_WORKING_DIRECTORY;
	if (!(ci.CIRCLE && CIRCLE_JOB && CIRCLE_WORKING_DIRECTORY)) {
		return;
	}
	const cwd = resolveHomePath(CIRCLE_WORKING_DIRECTORY);
	let config = path.join(
		cwd,
		'.circleci/config.yml'
	);
	config = fs.readFileSync(
		config,
		'utf-8'
	);
	config = yaml.safeLoad(config);

	config = config.jobs[CIRCLE_JOB].steps.reduce((results, step) => {
		step = step.store_test_results;
		if (step) {
			step = step.paths || step.path;
			if (step) {
				results = results.concat(step);
			}
		}
		return results;
	}, []);

	config = config.find(path => !/\w+\.\w+$/.test(path)) || config[0];

	if (config) {
		return path.resolve(
			cwd,
			resolveHomePath(config)
		);
	}
}
1298706
public void getData(String path, boolean watch, DataCallback cb, Object ctx) {
        getData(path, watch ? watchManager.defaultWatcher : null, cb, ctx);
    }
519968
def collect(self):
        
        if ((os.access(self.PROC, os.R_OK) and
             self.config.get('force_psutil') != 'True')):
            file = open(self.PROC)
            data = file.read()
            file.close()

            memory_total = None
            memory_available = None
            for line in data.splitlines():
                try:
                    name, value, units = line.split()
                    name = name.rstrip(':')
                    value = int(value)

                    if ((name not in _KEY_MAPPING and
                         'detailed' not in self.config)):
                        continue

                    if name in 'MemTotal':
                        memory_total = value
                    elif name in 'MemAvailable':
                        memory_available = value

                    for unit in self.config['byte_unit']:
                        value = diamond.convertor.binary.convert(value=value,
                                                                 oldUnit=units,
                                                                 newUnit=unit)
                        self.publish(name, value, metric_type='GAUGE')

                        # TODO: We only support one unit node here. Fix it!
                        break

                except ValueError:
                    continue

            if memory_total is not None and memory_available is not None:
                memory_used = memory_total - memory_available
                memory_used_percent = Decimal(str(100.0 *
                                              memory_used /
                                              memory_total))
                self.publish('MemUsedPercentage',
                             round(memory_used_percent, 2),
                             metric_type='GAUGE')
            return True
        else:
            if not psutil:
                self.log.error('Unable to import psutil')
                self.log.error('No memory metrics retrieved')
                return None

            # psutil.phymem_usage() and psutil.virtmem_usage() are deprecated.
            if hasattr(psutil, "phymem_usage"):
                phymem_usage = psutil.phymem_usage()
                virtmem_usage = psutil.virtmem_usage()
            else:
                phymem_usage = psutil.virtual_memory()
                virtmem_usage = psutil.swap_memory()

            units = 'B'

            for unit in self.config['byte_unit']:
                memory_total = value = diamond.convertor.binary.convert(
                    value=phymem_usage.total, oldUnit=units, newUnit=unit)
                self.publish('MemTotal', value, metric_type='GAUGE')

                memory_available = value = diamond.convertor.binary.convert(
                    value=phymem_usage.available, oldUnit=units, newUnit=unit)
                self.publish('MemAvailable', value, metric_type='GAUGE')

                memory_used = memory_total - memory_available

                memory_used_percent = Decimal(str(100.0 *
                                              memory_used /
                                              memory_total))
                self.publish('MemUsedPercentage',
                             round(memory_used_percent, 2),
                             metric_type='GAUGE')

                value = diamond.convertor.binary.convert(
                    value=phymem_usage.free, oldUnit=units, newUnit=unit)
                self.publish('MemFree', value, metric_type='GAUGE')

                value = diamond.convertor.binary.convert(
                    value=virtmem_usage.total, oldUnit=units, newUnit=unit)
                self.publish('SwapTotal', value, metric_type='GAUGE')

                value = diamond.convertor.binary.convert(
                    value=virtmem_usage.free, oldUnit=units, newUnit=unit)
                self.publish('SwapFree', value, metric_type='GAUGE')

                # TODO: We only support one unit node here. Fix it!
                break

            return True
1142369
function suiteComplete(result) {
		if (result.coverage) {
			coverageCollector.addCoverage(result.coverage);
		}

		// Have all suites completed?
		let completedSuites = suitesWithState('complete');
		if(Object.keys(completedSuites).length < Object.keys(suites).length) {
			return;
		}
		// All suites have completed, send the “complete” message to karma
		if(isDebug) {
			let [total, finished] = countTests();
			console.debug(`All ${Object.keys(suites).length} suites have completed, ran ${finished} of ${total} tests`);
		}
		if (result.coverage) {
			result.coverage = coverageCollector.getFinalCoverage();
		}
		karma.complete(result);
	}
529274
async function getStudySetup() {
  // shallow copy
  const studySetup = Object.assign({}, baseStudySetup);

  studySetup.allowEnroll = await cachingFirstRunShouldAllowEnroll(studySetup);

  const testingOverrides = await browser.study.getTestingOverrides();
  studySetup.testing = {
    variationName: testingOverrides.variationName,
    firstRunTimestamp: testingOverrides.firstRunTimestamp,
    expired: testingOverrides.expired,
  };

  return studySetup;
}
1279082
private void generateTCBasedData(List<TestCaseResult> allTestsList) {
        logger.entering(allTestsList);
        SummarizedData tempClass;
        SummarizedData tempGroupClass;
        Map<String, SummarizedData> mpClassData = new HashMap<String, SummarizedData>();
        int outputSheetRowCounter = 3;

        for (TestCaseResult tcResult : allTestsList) {

            // Segregating for class data
            String sTempClassName = tcResult.getClassName();

            // If class not already added to Class data, then create new ClassObject exists
            if (!mpClassData.containsKey(sTempClassName)) {
                tempClass = new SummarizedData();
                tempClass.setsName(sTempClassName);

            } else {
                tempClass = mpClassData.get(sTempClassName);
            }

            // Adding test to total count
            tempClass.incrementiTotal();

            // Adding all groups to map
            for (String sGroup : tcResult.getGroup()) {

                // Forming a key for the GroupClass map which is <GroupName><ClassName>
                String sGroupClassName = sGroup + sTempClassName;
                if (!mpGroupClassData.containsKey(sGroupClassName)) {
                    tempGroupClass = new SummarizedData();
                    tempGroupClass.setsName(sTempClassName);
                } else {
                    tempGroupClass = mpGroupClassData.get(sGroupClassName);
                }

                tempGroupClass.incrementiTotal();
                tempGroupClass.incrementCount(tcResult.getStatus());
                tempGroupClass.incrementDuration(tcResult.getDurationTaken());
                mpGroupClassData.put(sGroupClassName, tempGroupClass);
            }

            // Segregating for detailed Testcase Status wise data
            List<String> str = new ArrayList<String>();
            str.add(tcResult.getClassName());
            str.add(tcResult.getMethodName());
            str.add(tcResult.getTestDesc());
            str.add(tcResult.getGroup().toString());
            str.add(String.valueOf(tcResult.getDurationTaken()));
            str.add("'" + ReportSheetNames.TESTOUTPUTDETAILSREPORT.getName() + "'!B"
                    + Integer.toString(outputSheetRowCounter));

            List<String> outputStr = new ArrayList<String>();
            outputStr.add("Class Name:" + tcResult.getClassName());
            outputStr.add("Method/Testcase id:" + tcResult.getMethodName());
            outputStr.addAll(tcResult.getssmsg());

            // Based on status, incrementing class count and adding str to correct
            // list for TC detailed report
            switch (tcResult.getStatus()) {
                case ITestResult.FAILURE: {
                    tcFailedData.add(str);
                    // For failed cases adding data for defect description sheet
                    for (int iErrorCount = 0; iErrorCount < tcResult.getError().size(); iErrorCount++) {
                        List<String> tmpList = new ArrayList<String>();
                        tmpList.addAll(0, str);
                        tmpList.add(tcResult.getDefect().get(iErrorCount));
                        tmpList.add(tcResult.getError().get(iErrorCount));
                        outputStr.add("Stacktrace:" + tcResult.getError().get(iErrorCount));
                        tcDefectData.add(tmpList);
                    }
                    break;
                }
                case ITestResult.SUCCESS: {
                    tcPassedData.add(str);
                    break;
                }
                case ITestResult.SKIP: {
                    tcSkippedData.add(str);
                    break;
                }
                default: {
                    break;
                }
            }
            tcOutputData.add(outputStr);
            outputSheetRowCounter = outputSheetRowCounter + 1 + outputStr.size();

            tempClass.incrementCount(tcResult.getStatus());
            // Add to the total runtime of the class
            tempClass.setlRuntime(tempClass.getlRuntime() + tcResult.getDurationTaken());
            mpClassData.put(sTempClassName, tempClass);
        }
        lClasses.addAll(mpClassData.values());
        Collections.sort(lClasses);
        logger.exiting();
    }
835409
def get(self, id):
        
        ctx = self.context.copy()
        ctx['active_test'] = False
        results = self.rpc_model.search_read(
            [('id', '=', id)],
            None, None, None, self.fields,
            context=ctx
        )
        return results and results[0] or None
374020
def CollectData(self):
        
        while 1:  # loop until we get data or a timeout
            _bytes = self._ReadPacket()
            if not _bytes:
                return None
            if len(_bytes) < 4 + 8 + 1 or _bytes[0] < 0x20 or _bytes[0] > 0x2F:
                logging.warning("Wanted data, dropped type=0x%02x, len=%d",
                                _bytes[0], len(_bytes))
                continue

            seq, _type, x, y = struct.unpack("BBBB", _bytes[:4])
            data = [
                struct.unpack(">hhhh", _bytes[x:x + 8])
                for x in range(4,
                               len(_bytes) - 8, 8)
            ]

            if self._last_seq and seq & 0xF != (self._last_seq + 1) & 0xF:
                logging.warning("Data sequence skipped, lost packet?")
            self._last_seq = seq

            if _type == 0:
                if not self._coarse_scale or not self._fine_scale:
                    logging.warning(
                        "Waiting for calibration, dropped data packet.")
                    continue
                out = []
                for main, usb, aux, voltage in data:
                    if main & 1:
                        coarse = ((main & ~1) - self._coarse_zero)
                        out.append(coarse * self._coarse_scale)
                    else:
                        out.append((main - self._fine_zero) * self._fine_scale)
                return out
            elif _type == 1:
                self._fine_zero = data[0][0]
                self._coarse_zero = data[1][0]
            elif _type == 2:
                self._fine_ref = data[0][0]
                self._coarse_ref = data[1][0]
            else:
                logging.warning("Discarding data packet type=0x%02x", _type)
                continue

            # See http://wiki/Main/MonsoonProtocol for details on these values.
            if self._coarse_ref != self._coarse_zero:
                self._coarse_scale = 2.88 / (
                    self._coarse_ref - self._coarse_zero)
            if self._fine_ref != self._fine_zero:
                self._fine_scale = 0.0332 / (self._fine_ref - self._fine_zero)
1128531
def collect(self):
        
        stats_config = self.config['stats']
        if USE_PYTHON_BINDING:
            collect_metrics = self.collect_via_pynvml
        else:
            collect_metrics = self.collect_via_nvidia_smi

        collect_metrics(stats_config)
456105
function() {

            var self = this;
            var $element = $(this.element);

            // save this id attribute.
            self.attrId = $element.attr('id');

            //process the JSON data.
            // get the circle data from the data source.
            // check if the data source has different format.
            self.circleData = "data" in self.jsonData ?
                self.jsonData.data : self.jsonData;
            // the attributes in jsonData will overwrite options.
            if('attributes' in self.jsonData) {

                // the values in attributes will overwrite 
                // the same key in options. and the result will
                // store in options.
                $.extend(self.options, self.jsonData.attributes);
            }

            // draw circles.
            self.drawCircles();
        }
80343
function () {
				var oView = this.getView(),
					// Collect all possible items from all lists
					aItems = [].concat(
						oView.byId("allList").getItems(),
						oView.byId("apiList").getItems(),
						oView.byId("documentationList").getItems(),
						oView.byId("samplesList").getItems()
					),
					iLen = aItems.length,
					oItem;

				while (iLen--) {
					oItem = aItems[iLen];
					// Access control lazy loading method if available
					if (oItem._getLinkSender) {
						// Set link href to allow open in new window functionality
						oItem._getLinkSender().setHref("#/" + oItem.getCustomData()[0].getValue());
					}
				}
			}
722313
def __collect_fields(self):
        
        form = FormData()
        form.add_field(self.__username_field, required=True,
                       error=self.__username_error)
        form.add_field(self.__password_field, required=True,
                       error=self.__password_error)
        form.parse()
        self.username = form.values[self.__username_field]
        self.password = form.values[self.__password_field]
        return
794606
function (baseUrl, callback) {
    var self = this;
    var tests = [];

    // Export own request handler examples as test functions.
    for (var method in self.handlers) {
      var handler = self.handlers[method];
      if (!handler.examples) {
        throw (
          'Handler ' + method.toUpperCase() + ' ' + this.path +
            ' does not have examples!'
        );
      }
      handler.examples.forEach(function (example) {
        var test =
          self.testHandlerExample.bind(self, baseUrl, method, handler, example);
        tests.push(test);
      });
    }

    // Don't hang when there are no children.
    var pendingChildren = Object.keys(self.children).length;
    if (pendingChildren === 0) {
      callback(tests);
      return;
    }

    // Export children's request handler test functions recursively.
    var childBaseUrl = url.parse(String(baseUrl));
    childBaseUrl.pathname = normalizePath(self.path, childBaseUrl.pathname);
    childBaseUrl = url.format(childBaseUrl);
    for (var path in self.children) {
      self.children[path].exportAllTests(childBaseUrl, function (childTests) {
        tests = tests.concat(childTests);
        pendingChildren--;
        if (pendingChildren === 0) {
          callback(tests);
        }
      });
    }
  }
502349
function getAllActors() {
      try {
        storeBeingTested.getList(test.list, {}, function (list, error) {
          if (typeof error != 'undefined') {
            callback(error);
            return;
          }
          test.shouldBeTrue(list._items.length == 20, '20');
          getTomHanks();
        });
      }
      catch (err) {
        callback(err);
      }
    }
787203
def gather_data(registry):
    """"""

    # Get the host name of the machine
    host = socket.gethostname()

    # Create our collectors
    trig_metric = Gauge("trigonometry_example",
                        "Various trigonometry examples.",
                        {'host': host})

    # register the metric collectors
    registry.register(trig_metric)

    # Start gathering metrics every second
    counter = 0
    while True:
        time.sleep(1)

        sine = math.sin(math.radians(counter % 360))
        cosine = math.cos(math.radians(counter % 360))
        trig_metric.set({'type': "sine"}, sine)
        trig_metric.set({'type': "cosine"}, cosine)

        counter += 1
702971
def collect_data(self):
        
        #collect some measurements resolved per file and save to file
        for measure in ['LFP', 'CSD']:
            if measure in self.savelist:
                self.collectSingleContribs(measure)


        #calculate lfp from all cell contribs
        lfp = self.calc_signal_sum(measure='LFP')

        #calculate CSD in every lamina
        if self.calculateCSD:
            csd = self.calc_signal_sum(measure='CSD')

        if RANK == 0 and self.POPULATION_SIZE > 0:
            #saving LFPs
            if 'LFP' in self.savelist:
                fname = os.path.join(self.populations_path,
                                     self.output_file.format(self.y,
                                                             'LFP')+'.h5')
                f = h5py.File(fname, 'w')
                f['srate'] = 1E3 / self.dt_output
                f.create_dataset('data', data=lfp, compression=4)
                f.close()
                del lfp
                assert(os.path.isfile(fname))
                print('save lfp ok')


            #saving CSDs
            if 'CSD' in self.savelist and self.calculateCSD:
                fname = os.path.join(self.populations_path,
                                     self.output_file.format(self.y,
                                                             'CSD')+'.h5')
                f = h5py.File(fname, 'w')
                f['srate'] = 1E3 / self.dt_output
                f.create_dataset('data', data=csd, compression=4)
                f.close()
                del csd
                assert(os.path.isfile(fname))
                print('save CSD ok')


            #save the somatic placements:
            pop_soma_pos = np.zeros((self.POPULATION_SIZE, 3))
            keys = ['xpos', 'ypos', 'zpos']
            for i in range(self.POPULATION_SIZE):
                for j in range(3):
                    pop_soma_pos[i, j] = self.pop_soma_pos[i][keys[j]]
            fname = os.path.join(self.populations_path,
                                 self.output_file.format(self.y, 'somapos.gdf'))
            np.savetxt(fname, pop_soma_pos)
            assert(os.path.isfile(fname))
            print('save somapos ok')

            #save rotations using hdf5
            fname = os.path.join(self.populations_path,
                                    self.output_file.format(self.y, 'rotations.h5'))
            f = h5py.File(fname, 'w')
            f.create_dataset('x', (len(self.rotations),))
            f.create_dataset('y', (len(self.rotations),))
            f.create_dataset('z', (len(self.rotations),))

            for i, rot in enumerate(self.rotations):
                for key, value in list(rot.items()):
                    f[key][i] = value
            f.close()
            assert(os.path.isfile(fname))
            print('save rotations ok')


        #resync threads
        COMM.Barrier()
973915
def get_samples_data(self):
        
        for obj in self.get_samples_from_request():
            yield {
                "obj": obj,
                "id": api.get_id(obj),
                "uid": api.get_uid(obj),
                "title": api.get_title(obj),
                "path": api.get_path(obj),
                "url": api.get_url(obj),
                "sample_type": obj.getSampleTypeTitle(),
                "client_title": obj.getClientTitle(),
                "date": ulocalized_time(obj.created(), long_format=True),
            }