/* This function saves a device's info to the scannedData object.
335686
function saveDeviceInfo(deviceInfo) {
            debugDC('in saveDeviceInfo');
            var key = getDeviceKey(deviceInfo);
            var connectionTypes = [];
            var newConnectionTypes = getDeviceConnectionTypesData(deviceInfo);

            if(scannedData[key]) {
                // The data has already been added.
                connectionTypes = scannedData[key].connectionTypes;
            } else {
                // The data has not been added.  Object needs to be initialized.
                scannedData[key] = {};
            }

            // Append new connection types to the connectionTypes array.
            debugDC('Initial CTS', connectionTypes.length, newConnectionTypes.length);
            connectionTypes = appendDeviceConnectionTypesData(
                connectionTypes,
                newConnectionTypes,
                deviceInfo
            );
            debugDC('Appended CTS', connectionTypes.length);

            // Parse the connectionTypes array to populate a few remaining
            // variables.
            scannedData[key].numConnectionTypes = connectionTypes.length;
            scannedData[key].connectionTypeNames = connectionTypes.map(function(ct) {
                return ct.connectionTypeName;
            });

            // Determine what connections are and aren't verified.
            scannedData[key].unverifiedConnectionTypes = [];
            scannedData[key].unverifiedConnectionTypeNames = [];
            scannedData[key].verifiedConnectionTypeNames = [];
            connectionTypes.forEach(function(ct) {
                var ctn = ct.connectionTypeName;
                if(ct.isVerified) {
                    scannedData[key].verifiedConnectionTypeNames.push(ctn);
                } else {
                    scannedData[key].unverifiedConnectionTypes.push(ct);
                    scannedData[key].unverifiedConnectionTypeNames.push(ctn);
                }
            });

            // Save the connectionTypes array.
            scannedData[key].connectionTypes = connectionTypes;

            // Save the deviceInfo object to the scannedData object.
            var iKeys = Object.keys(deviceInfo);
            iKeys.forEach(function(iKey) {
                if(typeof(scannedData[key][iKey]) === 'undefined') {
                    scannedData[key][iKey] = deviceInfo[iKey];
                }
            });
        }
1125038
protected function storeData()
    {
        if ($this->currentCellIsDirty && !empty($this->currentObjectID)) {
            $this->currentObject->detach();

            $this->cellCache[$this->currentObjectID] = gzdeflate(serialize($this->currentObject));
            $this->currentCellIsDirty = false;
        }
        $this->currentObjectID = $this->currentObject = null;
    }
570630
function debugPrintFlatScannedData(data, printer) {
        var pInfo = [
            'numConnectionTypes',
            'connectionTypeNames',
            'verifiedConnectionTypeNames',
            'connectionTypes',
            'unverifiedConnectionTypeNames',
        ];

        if(DEBUG_MARKING_ACTIVE_CONNECTION_TYPES) {
            pInfo.push('handle');
            pInfo.push('dt');
            pInfo.push('deviceType');
            pInfo.push('deviceTypeStr');
            pInfo.push('deviceTypeString');
            pInfo.push('deviceTypeName');
            pInfo.push('handleConnectionType');
            pInfo.push('handleConnectionTypeStr');
            pInfo.push('handleConnectionTypeName');
            pInfo.push('ct');
            pInfo.push('connectionType');
            pInfo.push('connectionTypeStr');
            pInfo.push('connectionTypeName');
            pInfo.push('serialNumber');
            pInfo.push('ip');
            pInfo.push('port');
            pInfo.push('maxBytesPerMB');
            pInfo.push('maxBytesPerMB');
            pInfo.push('isActive');
        }
        var pData = {};
        var keys = Object.keys(data);
        keys.forEach(function(key) {
            var dData = data[key];
            var dKeys = Object.keys(dData);
            pData[key] = {};
            var otherKeys = [];
            // loop through each available device.
            dKeys.forEach(function(dKey) {
                // Save the requested key's info.
                if(pInfo.indexOf(dKey) >= 0) {
                    pData[key][dKey] = dData[dKey];
                } else {
                    otherKeys.push(dKey);
                }
            });
            // pData[key].keys = otherKeys;
        });
        if(printer) {
            printer('Scanned Data', pData);
        } else {
            console.log('Scanned Data', pData);
        }
    }
802602
function() {
                /**
                 * Initialize Cache Databases
                 */
                startCacheDatabases();

                if (grantDeviceIdFromSSO) {
                    var getDeviceIdWithTokenTime = new Date().getTime();
                    getDeviceIdWithToken(function(retrievedDeviceId) {

                        if (actualTimingLog) {
                            Utility.chatStepLogger('Get Device ID ', new Date().getTime() - getDeviceIdWithTokenTime);
                        }

                        deviceId = retrievedDeviceId;

                        initAsync();
                    });
                }
                else {
                    initAsync();
                }
            }
435576
function storeFileToDisk(i_oFile, i_sOutput) {
    var l_sDirname = path.dirname(i_oFile.filename),
        l_sFilename;

    console.log("File name: ", i_oFile.filename, " size: ", i_oFile.header.unpackedSize);
    console.log("Saving content of file ");

    l_sDirname = path.join(i_sOutput, path.dirname(i_oFile.filename));
    l_sFilename = path.join(l_sDirname, path.basename(i_oFile.filename));
    return new Promise(function(i_oResolve) {
        mkdirp(l_sDirname, function (err) {
            if (err) console.error(err);
            _writeFile(l_sFilename, i_oFile, i_oResolve);
        });
    });
}
310773
function innerCollectDeviceData(infoToCache) {
        var defered = q.defer();
        self.dataCollectionDefered = defered;

        self.log('Collecting Data from a handle', self.handle);
        
        // Indicate that this device was opened by the device scanner.
        self.openedByScanner = true;

        var deviceHandle = self.handle;
        var dt = self.openParameters.deviceType;
        var ct = self.openParameters.connectionType;
        var id = self.openParameters.identifier;

        // Initialize a curated device object.
        self.curatedDevice = new device_curator.device();

        // Link the device handle to the curated device object.
        self.curatedDevice.linkToHandle(deviceHandle, dt, ct, id)
        .then(function finishedLinkingHandle(res) {
            self.log(
                'Finished linking to a handle',
                deviceHandle,
                self.curatedDevice.savedAttributes.connectionTypeName
            );
            
            // Create a data collection timeout.
            var collectionTimeout = setTimeout(
                deviceHandleDataCollectionTimeout,
                DEVICE_DATA_COLLECTION_TIMEOUT
            );

            // Attach event listeners to the curated device.
            linkToCuratedDeviceEvents();
            console.log('reading multiple...', deviceHandle);
            // Collect information from the curated device.
            self.curatedDevice.iReadMultiple(infoToCache)
            .then(function finishedCollectingData(results) {
                // Clear the data collection timeout
                clearTimeout(collectionTimeout);

                self.log('Collecting data from a handle', deviceHandle);
                printCollectedDeviceData(results);
                saveCollectedDeviceData(results);

                // Report that the device is finished collecting data.
                stopCollectingDeviceData();
            }, function(err) {
                self.log('Error collecting data from a handle', deviceHandle, err);

                // Report that the device is finished collecting data.
                stopCollectingDeviceData();
            });
        }, function errorLinkingHandle(err) {
            console.error('Error linking to handle...');
            defered.resolve();
        });
        return defered.promise;
    }
1104316
function doSaveDocument() {
    var presenter = new mindmaps.SaveDocumentPresenter(eventBus,
        mindmapModel, new mindmaps.SaveDocumentView(), autosaveController, filePicker);
    presenter.go();
  }
644210
function printScannedDataConnectionTypes(scannedData) {
        var keys = Object.keys(scannedData);
        keys.forEach(function(key) {
            var dev = scannedData[key];
            var cts = dev.connectionTypes;
            debugLFDS(key, cts);
        });
    }
1332701
def save_formatted_data(self, data):
        
        self.data = data
        self._timestamps['process'] = time.time()
        self._stage = STAGE_DONE_DATA_FORMATTED
258409
function saveIndexInfo() {

    // reset the cache
    var tmpCache = cache.idxInfo;
    cache.idxInfo = {};

    var promises = [];

    // add promise for each things being saved/updated
    _.each(tmpCache, function (idxInfo, key) {
        var where = { str: key };
        var select = '_id count';

        var promise = IdxInfoModel.findOne(where, select).exec()
            .then(function (savedItem) {
                if (savedItem) {
                    return IdxInfoModel.findOneAndUpdate(where, { $inc: { count: idxInfo.count }});
                }
                else {
                    var model = new IdxInfoModel(idxInfo);
                    var deferred = Q.defer();
                    model.save(function (modelErr) {
                        modelErr ? deferred.reject(modelErr) : deferred.resolve(model.toObject());
                    });
                    return deferred.promise;
                }
            });

        promises.push(promise);
    });

    return Q.all(promises);
}
1262053
function saveTransformedData(uri) {
  return function (data) {
    return db.put(uri, JSON.stringify(data))
      .then(function () {
        // If the Promise resolves it means we saved,
        // so let's return the data
        return data;
      });
  };
}
639009
public function persistData()
    {
        // we sort the array first, useful for doing ris match
        if (!empty($this->userAgentsWithDeviceID)) {
            ksort($this->userAgentsWithDeviceID);

            $this->persistenceProvider->save($this->getPrefix(), $this->userAgentsWithDeviceID);
            $this->persistenceProvider->save($this->getPrefix(self::PREFIX_OVERWRITTEN), $this->overwritten_devices);
            $this->persistenceProvider->save($this->getPrefix(self::PREFIX_UA_BUCKET), array_keys($this->userAgentsWithDeviceID));
        }
    }
115517
public synchronized void save() {
		if( bestImage != null ) {
			File path = new File(outputDirectory, String.format("image%04d.png",imageNumber));
			UtilImageIO.saveImage(bestImage,path.getAbsolutePath());
			imageNumber++;
		}
		clearHistory();
	}
698678
function readSensorValue() {
    if ( touch.isPressed() ) {
        console.log(touch.name() + " is pressed");
    } else {
        console.log(touch.name() + " is not pressed");
    }
}
825691
function (successCallback) {

			// If the caller told us to stop scanning since our last scan, or all devices have been removed from the list, nothing to do
			if (!winble.deviceManager.isScanning || (winble.deviceManager.reportList.length == 0)) {
				winble.deviceManager.isReporting = false;
				return;
			}

			// Report the next device in our list
			var device = winble.deviceManager.getNextReportableDevice();
			if (device != null) {
				winble.logger.logDebug("reportNextDevice", "Reporting scan for " + device.gattDevice.name);
				var deviceOut = {
					"address": device.gattDevice.id,
					"name": device.gattDevice.name,
					"rssi": device.rssi,
					"scanRecord": "" // Base64 string, iOS only
				};
				successCallback(deviceOut, { keepCallback: true });
			}

			// Set up the next report
			setTimeout(function () {
				winble.deviceManager.reportNextDevice(successCallback);
			}, winble.deviceManager.REPORT_INTERVAL);
		}
1349175
def _on_scan(self, info):
        

        device_id = info['uuid']
        expiration_time = info.get('validity_period', 60)
        infocopy = deepcopy(info)

        infocopy['expiration_time'] = monotonic() + expiration_time

        with self._scan_lock:
            self._scanned_devices[device_id] = infocopy
240040
function gotData() {
  var currentString = serial.readLine();  // read the incoming string
  trim(currentString);                    // remove any trailing whitespace
  if (!currentString) return;             // if the string is empty, do no more
  console.log(currentString);             // println the string
  latestData = currentString;            // save it for the draw method
}