.then(function(data) { var parser = new (less.Parser)({ paths: [path.dirname(file)], filename: path.basename(file) }); return Q.ninvoke(parser, "parse", data); }, function(z) {
it("createrequest", function(done) { var protocol = new Protocol(); _.extend(protocol, server.getOptions()); var req = new fakes.Request("/"); Q.ninvoke(protocol, "createrequest", req, new fakes.Response()) .should.be.fulfilled.then(function(tequilaResult) { assert(tequilaResult.key); }) .should.notify(done); });
MongoClient.connect("mongodb://localhost:27017/mylsf", function (err, db) { /* * Upsert functions */ function upsertDegree (degree) { return Q.ninvoke(db.collection('degrees'), 'update', {lsf_num: degree.lsf_num}, { $set: degree }, {upsert: true}); } function upsertMajor (major) { return Q.ninvoke(db.collection('majors'), 'update', {lsf_num: major.lsf_num}, { $set: major, }, {upsert: true}); } function upsertCourse (course) { // sets to be appended, delete from object containing the properties to set var lsf_modules = course.lsf_modules || []; var lsf_lectures = course.lsf_lectures || []; delete course.lsf_modules; delete course.lsf_lectures; // actual upsert return Q.ninvoke(db.collection('courses'), 'update', {lsf_id: course.lsf_id}, { $addToSet: { lsf_modules: { $each: lsf_modules }, lsf_lectures: { $each: lsf_lectures }, }, $set: course }, {upsert: true}); } function upsertModule (module) { // sets to be appended, delete from object containing the properties to set var lsf_courses = module.lsf_courses || []; var lsf_lectures = module.lsf_lectures || []; delete module.lsf_courses; delete module.lsf_lectures; // actual upsert return Q.ninvoke(db.collection('modules'), 'update', {lsf_id: module.lsf_id}, { $addToSet: { lsf_courses: { $each: lsf_courses }, lsf_lectures: { $each: lsf_lectures }, }, $set: module, }, {upsert: true}); } function upsertLecture (lecture) { // sets to be appended, delete from object containing the properties to set var lsf_courses = lecture.lsf_courses || []; var lsf_modules = lecture.lsf_modules || []; delete lecture.lsf_courses; delete lecture.lsf_modules; // actual upsert return Q.ninvoke(db.collection('lectures'), 'update', {lsf_id: lecture.lsf_id}, { $addToSet: { lsf_courses: { $each: lsf_courses }, lsf_modules: { $each: lsf_modules }, }, $set: lecture }, {upsert: true}); } function upsertEvent (event) { return Q.ninvoke(db.collection('events'), 'update', event, event, {upsert: true}); } function upsertLocation (location) { return Q.ninvoke(db.collection('locations'), 'update', {lsf_id: location.lsf_id}, { $set: location }, {upsert: true}); } function insertEvents (events) { if (events.length) return Q.ninvoke(db.collection('events'), 'insert', events); } function updateCourse(course) { var courses_col = db.collection('courses'); return [ harvester.courseFetchById.bind(null, course.lsf_id), function (courseData) { return Q.all([ upsertCourse(courseData), upsertDegree({ lsf_num: courseData.degreeNum, name: courseData.degreeName, timeHarvest: courseData.timeHarvest, }), upsertMajor({ lsf_num: courseData.majorNum, name: courseData.majorName, timeHarvest: courseData.timeHarvest, }) ]).thenResolve(courseData); } ].reduce(Q.when, Q()) .then(function (course) { }, function (err) { if (err.type) { return Q.ninvoke(courses_col, 'remove', course).then(function () { log.warn('import', 'removed', course, 'due to error', err); }); } else { throw err; } }) } function updateModule(module) { var col = db.collection('modules'); return harvester.moduleFetchById(module.lsf_id) .then(function (moduleData) { return Q.all([].concat( // Update references in other collections moduleData.lsf_lectures.map(function (lecture_id) { return upsertLecture({ lsf_id: lecture_id, lsf_modules: [module.lsf_id], }); }), upsertModule(moduleData) )).thenResolve(moduleData); }) .then(function (moduleData) { }); } function updateLecture(lecture) { var col = db.collection('lectures'); return harvester.lectureFetchById(lecture.lsf_id) .then(function (lectureData) { var events = lectureData.events; // events should not go to lectures collection delete lectureData.events; return Q.all([].concat( // Update references in other collections lectureData.lsf_courses.map(function (course_id) { return upsertCourse({ lsf_id: course_id, lsf_lectures: [lecture.lsf_id], }); }), lectureData.lsf_modules.map(function (module_id) { return upsertModule({ lsf_id: module_id, lsf_lectures: [lecture.lsf_id], }); }), upsertLecture(lectureData), insertEvents(events) // insert events for this lecture )).thenResolve({ lecture: lectureData, events: events, }); }) .then(function (res) { //log.info('import', 'Added %d events for this lecture', res.events.length); return res.lecture; }); } function updateLocation(location) { return harvester.locationFetchById(location.lsf_id) .then(function (locationData) { return upsertLocation(locationData); }) } switch (argv._[0]) { case 'courseList': var col = db.collection('courses'); log.info('import', 'Fetching course ids …'); harvester.courseFetchIds() .then(function (courses) { return Q.all(courses.map(upsertCourse)).thenResolve(courses); }).done(function (courses) { log.info('import', '%d course ids imported', courses.length); process.exit(); }); break; case 'courseData': var col = db.collection('courses'); log.info('import', 'Fetching course data …'); Q.ninvoke(col.find().sort({lsf_id: 1}), 'toArray').then(function (res) { var jobs = res.map(function (course) { return updateCourse.bind(null, course); }); var bar = new ProgressBar('ETA :etas [:bar] :percent', { total: jobs.length, }) return runJobs(jobs, bar); }).done(function () { log.info('import', 'course data updated!'); process.exit(); }); break; case 'moduleList': var col = db.collection('modules'); log.info('import', 'Fetching module ids …'); harvester.moduleFetchIds() .then(function (modules) { return Q.all(modules.map(upsertModule)).thenResolve(modules); }) .done(function (modules) { log.info('import', '%d module ids imported', modules.length); process.exit(); }); break; case 'moduleData': var col = db.collection('modules'); log.info('import', 'Fetching module data …'); Q.ninvoke(col.find().sort({'lsf_id': 1}), 'toArray').then(function (modules) { var jobs = modules.map(function (module) { return updateModule.bind(null, module); }); var bar = new ProgressBar('ETA :etas [:bar] :percent', { total: jobs.length, }); return runJobs(jobs, bar); }).done(function () { log.info('import', 'module data updated!'); process.exit(); }); break; case 'lectureList': var col = db.collection('lectures'); log.info('import', 'Fetching lecture ids …'); harvester.lectureFetchCount() .then(function (count) { var p_size = 100; // lsf allows max 100 var jobs = Array.apply(null, Array(parseInt(count / p_size) + 1)).map(function (v, i) { return function () { return harvester.lectureFetchIdsByRange(i * p_size, p_size) .then(function (lectures) { return Q.all(lectures.map(upsertLecture)).thenResolve(lectures); }); } }); var bar = new ProgressBar('ETA :etas [:bar] :percent', { total: jobs.length, }); return runJobs(jobs, bar) .then(function (lecture_chunks) { return [].concat.apply([], lecture_chunks); }); }) .done(function (res) { log.info('import', '%d lecture ids imported!', res.length); process.exit(); }); break; case 'lectureData': var col = db.collection('lectures'); log.info('import', 'Fetching lecture data …'); Q.ninvoke(col.find().sort({lsf_id: 1}), 'toArray').then(function (lectures) { var jobs = lectures.map(function (lecture) { return updateLecture.bind(null, lecture); }); var bar = new ProgressBar('ETA :etas [:bar] :percent', { total: jobs.length, }); return runJobs(jobs, bar); }).done(function () { log.info('import', 'lecture data updated'); process.exit(); }); break; case 'locationData': var col = db.collection('lectures'); log.info('import', 'Fetching location data …'); Q.ninvoke(db.collection('events'), 'distinct', 'lsf_location').then( function (res) { var jobs = res.filter(function (v) { return v; }).map(function (lsf_id) { return updateLocation.bind(null, {lsf_id: lsf_id}); }); var bar = new ProgressBar('ETA :etas [:bar] :percent', { total: jobs.length, }); return runJobs(jobs, bar); }).done(function (res) { log.info('import', '%d rooms imported!', res.length); process.exit(); }); break; case 'courseDrop': Q.ninvoke(db.collection('courses'), 'drop') .then(Q.nbind(db.collection('majors').drop, db.collection('majors'))) .then(Q.nbind(db.collection('degrees').drop, db.collection('degrees'))) .then(Q, Q) .done(function () { log.info('import', 'courses/majors/degrees dropped'); process.exit(); }); break; case 'moduleDrop': Q.ninvoke(db.collection('modules').drop()).then(Q, Q).done(function () { log.info('import', 'modules dropped'); process.exit(); }); break; case 'lectureDrop': Q.ninvoke(db.collection('lectures').drop()).then(Q, Q).done(function () { log.info('import', 'lectures dropped'); process.exit(); }); break; case 'clear': Q.all([].concat( Q.ninvoke(db.collection('majors'), 'drop'), Q.ninvoke(db.collection('degrees'), 'drop'), Q.ninvoke(db.collection('courses'), 'drop'), Q.ninvoke(db.collection('modules'), 'drop'), Q.ninvoke(db.collection('lectures'), 'drop'), Q.ninvoke(db.collection('locations'), 'drop'), Q.ninvoke(db.collection('events'), 'drop') )).then(Q, Q).done(function () { log.info('import', 'cleared database'); process.exit(); }); break; case 'test': harvester.locationFetchById(2308).done(function (res) { console.log(res); process.exit(); }); break; default: log.info('import', 'Nothing to be done'); process.exit(); } });
}).then(function() { return Q.ninvoke(npm.commands, 'cache', ["clean"]); });
// Internal function called potentially multiple times to cover all platforms. function postPrepareInternal(platform) { var root = assetDirForPlatform(platform); /* Android asset packager ignores, by default, directories beginning with underscores. This can be fixed with an update to the project.properties file, but only when compiling with ant. There is a bug outstanding to fix this behaviour in Eclipse/ADT as well. References: https://code.google.com/p/android/issues/detail?id=5343 https://code.google.com/p/android/issues/detail?id=41237 */ var badPath = path.join(assetDirForPlatform(platform), '_locales'); var betterPath = path.join(assetDirForPlatform(platform), 'CCA_locales'); var promise = Q(); if (fs.existsSync(badPath)) { console.log('## Pre-processing _locales for ' + platform); fs.renameSync(badPath, betterPath); promise = Q.ninvoke(fs, 'readdir', betterPath) .then(function(files) { for (var i=0; i<files.length; i++) { var fullName = path.join(betterPath, files[i]); var adjustedFilename= files[i].replace('-', '_').toLowerCase(); if (files[i] !== adjustedFilename) { stats = fs.statSync(fullName); if (stats.isDirectory()) { fs.renameSync(fullName, path.join(betterPath, adjustedFilename)); } } } }); } return promise.then(function() { return getManifest('www'); }).then(function(manifest) { if (!manifest || !manifest.icons) return; var iconMap = {}; var iPhoneFiles = { 'icon-40': true, 'icon-small': true, 'icon.png': true, 'icon@2x': true, 'icon-72': true, 'icon-72@2x': true }; var iPadFiles = { 'icon-small': true, 'icon-40': true, 'icon-50': true, 'icon-76': true, 'icon': true, 'icon@2x': true, 'icon-72': true, 'icon-72@2x': true }; var infoPlistXml = null; var infoPlistPath = null; var iosIconDir = null; if (platform === "android") { iconMap = { "36": [path.join('res','drawable-ldpi','icon.png')], "48": [path.join('res','drawable-mdpi','icon.png')], "72": [path.join('res','drawable-hdpi','icon.png')], "96": [path.join('res','drawable-xhdpi','icon.png')], "144": [path.join('res','drawable-xxhdpi','icon.png')], "192": [path.join('res','drawable-xxxhdpi','icon.png')] }; } else if (platform === "ios") { var platforms = require('cordova/platforms'); var parser = new platforms.ios.parser(path.join('platforms','ios')); iconMap = { "-1": [path.join(parser.originalName, 'Resources','icons','icon-60.png')], // this file exists in the template but isn't used. "29": [path.join(parser.originalName, 'Resources','icons','icon-small.png')], "40": [path.join(parser.originalName, 'Resources','icons','icon-40.png')], "50": [path.join(parser.originalName, 'Resources','icons','icon-50.png')], "57": [path.join(parser.originalName, 'Resources','icons','icon.png')], "58": [path.join(parser.originalName, 'Resources','icons','*****@*****.**')], "72": [path.join(parser.originalName, 'Resources','icons','icon-72.png')], "76": [path.join(parser.originalName, 'Resources','icons','icon-76.png')], "80": [path.join(parser.originalName, 'Resources','icons','*****@*****.**')], "100": [path.join(parser.originalName, 'Resources','icons','*****@*****.**')], "114": [path.join(parser.originalName, 'Resources','icons','*****@*****.**')], "120": [path.join(parser.originalName, 'Resources','icons','*****@*****.**')], "144": [path.join(parser.originalName, 'Resources','icons','*****@*****.**')], "152": [path.join(parser.originalName, 'Resources','icons','*****@*****.**')] }; infoPlistPath = path.join('platforms', 'ios', parser.originalName, parser.originalName + '-Info.plist'); infoPlistXml = et.parse(fs.readFileSync(infoPlistPath, 'utf-8')); iosIconDir = path.join(parser.originalName, 'Resources', 'icons'); } function copyIcon(size, dstPath) { shelljs.mkdir('-p', path.dirname(dstPath)); shelljs.cp('-f', path.join('www', fixPathSlashes(manifest.icons[size])), dstPath); if (shelljs.error()) { console.log("Error copying " + size + "px icon file: " + shelljs.error()); } } var missingIcons = []; if (iconMap) { //console.log('## Copying icons for ' + platform); for (var size in iconMap) { for (var i=0; i < iconMap[size].length; i++) { var dstPath = path.join('platforms', platform, iconMap[size][i]); if (manifest.icons[size]) { //console.log("Copying " + size + "px icon file"); copyIcon(size, dstPath); } else { missingIcons.push(dstPath); } } } // Find the largest icon. var bestSize = '0'; for (size in manifest.icons) { bestSize = +size > +bestSize ? size : bestSize; } missingIcons.forEach(function(dstPath) { var imgName = path.basename(dstPath).replace(/\..*?$/, ''); // Leave at least one icon. if (imgName != 'icon') { delete iPadFiles[imgName]; delete iPhoneFiles[imgName]; } // TODO: need to remove the iOS assets from the Xcode project file (ugh). if (platform == 'android') { shelljs.rm('-f', dstPath); } else if (platform == 'ios') { // Fill in all missing iOS icons with the largest resolution we have. copyIcon(bestSize, dstPath); } }); // Use the largest icon as the default Android one. if (platform == 'android') { var dstPath = path.join('platforms', platform, 'res', 'drawable', 'icon.png'); copyIcon(bestSize, dstPath); } if (infoPlistXml) { function findArrayNode(key) { var foundNode = null; var foundKey = 0; infoPlistXml.iter('*', function(e) { if (foundKey === 0) { if (e.text == key) { foundKey = 1; } } else if (foundKey == 1) { if (e.text == 'CFBundleIconFiles') { foundKey = 2; } } else if (foundKey == 2) { if (e.tag == 'array') { foundNode = e; foundKey = 3; } } }); return foundNode; } function setValues(key, vals) { var node = findArrayNode(key); node.clear(); for (var imgName in vals) { et.SubElement(node, 'string').text = imgName; } } setValues('CFBundleIcons', iPhoneFiles); setValues('CFBundleIcons~ipad', iPadFiles); fs.writeFileSync(infoPlistPath, et.tostring(infoPlistXml.getroot(), {indent: 8}), 'utf8'); } } }) // Merge the manifests. .then(function() { return getManifest(root, platform); }).then(function(manifest) { return Q.ninvoke(fs, 'writeFile', path.join(root, 'manifest.json'), JSON.stringify(manifest)); }) // Set the "other" version values if defined in the manifest. // CFBundleVersion on iOS and versionCode on Android. .then(function() { return getManifest(root); }).then(function(manifest) { // Android if (platform === 'android' && manifest && manifest.versionCode) { var androidManifestPath = path.join('platforms', 'android', 'AndroidManifest.xml'); var androidManifest = et.parse(fs.readFileSync(androidManifestPath, 'utf-8')); androidManifest.getroot().attrib["android:versionCode"] = manifest.versionCode; fs.writeFileSync(androidManifestPath, androidManifest.write({indent: 4}), 'utf-8'); } // On iOS it is customary to set CFBundleVersion = CFBundleShortVersionString // so if manifest.CFBundleVersion is not specifically set, we'll default to manifest.version if (platform === 'ios' && manifest && (manifest.version || manifest.CFBundleVersion)) { var platforms = require('cordova/platforms'); var parser = new platforms.ios.parser(path.join('platforms','ios')); var infoPlistPath = path.join('platforms', 'ios', parser.originalName, parser.originalName + '-Info.plist'); var infoPlistXml = et.parse(fs.readFileSync(infoPlistPath, 'utf-8')); var theNode; var isFound = 0; // plist file format is pretty strange, we need the <string> node // immediately following <key>CFBundleVersion</key> // iterating over all the nodes. infoPlistXml.iter('*', function(e) { if (isFound === 0) { if (e.text == 'CFBundleVersion') { isFound = 1; } } else if (isFound == 1) { theNode = e; isFound = 2; } }); theNode.text = manifest.CFBundleVersion || manifest.version; fs.writeFileSync(infoPlistPath, infoPlistXml.write({indent: 4}), 'utf-8'); } }); }
}).then(function() { return Q.ninvoke(npm.commands, 'publish', args) }).fin(function() {
.then(function(settings) { return Q.ninvoke(npm, 'load', settings); }).then(function() {
.then(function (user) { if (!user) return next(); // 404 user = _.extend(user, req.body); return Q.ninvoke(user, 'save'); })
return initSettings().then(function(settings) { return Q.ninvoke(npm, 'load', settings) })
.then(function () { return Q.ninvoke(fs, 'readdir', srcDir); })
return logAndTime("Save router => '" + dst + "'", function () { var content = JSON.stringify(router.routerInfos(ctx)); return Q.ninvoke(fs, 'writeFile', dst, content, "utf8"); }, ctx).thenResolve(router);
return createPath(dst, ctx).then(function () { return Q.ninvoke(fs, 'writeFile', dst, result, "utf8"); });
return logAndTime("copy file '" + src + "' => '" + dst + "'", function () { return Q.ninvoke(fs, 'writeFile', dst, content, encoding); }, ctx);
.then(function(seqNodeInfo){ // Next line for logging purpose var seqNodeInfoSum = that_.sequenceNodeProvider.getSequenceNodeInfoSummary(data.sequenceNodeKey, seqNodeInfo); // Stub the initial cePayload: {sequenceNodeKey, answerKey, studentSubmission, isLastAttempt}. var cePayload = {}; var numAttemptsAllowed = seqNodeInfo.sequenceNodeContent.targetActivity.maxAttempts; // Calculate isLastAttempt //var remainingAttempts = calculateRemainingAttempts_(numAttemptsAllowed, seqNodeInfo.sequenceNodeContent); var attemptsMade = calculateAttemptsMade_(seqNodeInfo.sequenceNodeContent); var remainingAttempts = numAttemptsAllowed - attemptsMade; if (remainingAttempts > 0) { cePayload.isLastAttempt = false; } else if (remainingAttempts === 0) { cePayload.isLastAttempt = true; } else { callback('You have already used all of your submit attempts. Your submission was not accepted.', null); return; } // Build the rest of the cePayload cePayload.sequenceNodeKey = sequenceNodeKey; cePayload.answerKey = obtainAnswerPart_(seqNodeInfo.sequenceNodeContent.targetActivity); cePayload.studentSubmission = studentSubmission; // We nest this handler so we can get at the ceProxy result and seqNodeInfo // Post it to the CorrectnessEngine Q.ninvoke(that_.ceProxy, "sendSubmission", cePayload) .then(function(result){ // Build the NodeResult from the CE result var nodeResult = buildSubmissionNodeResult_(result, studentSubmission, seqNodeInfo.itemCorrelationToken, cePayload.isLastAttempt); // Start building the return value we'd like to send back to the IPS. To start // this is just what the CE returned for data. var ipsReturn = result.data; // Add attempts made ipsReturn.attemptsMade = attemptsMade; // If we have a nonRecordable problem we create the cached NodeResult and return if ('nonRecordable' in cePayload.answerKey && cePayload.answerKey.nonRecordable === true) { // Append our new nodeResult to the sequenceNode and update the cache var updatedSeqNodeInfo = appendResultToSequenceNode_(seqNodeInfo, nodeResult); updateCache_(sequenceNodeKey, updatedSeqNodeInfo); // Return, via the controller, to the IPC callback(null, ipsReturn); // In most cases we'll have a recordable problem and will want to send the NodeResult to the AMS. } else { // Send the NodeResult off to the AMS var amsSubmissionParam = { nodeResult: nodeResult, hubSession: seqNodeInfo.hubSession }; that_.amsProxy.sendSubmission(amsSubmissionParam, function(error, result) { // There nothing to do with the result returned from AMS. // @todo - if we have anything of substance returned back from the AMS // like assignment-related info deal with that here or in appendResultToSequenceNode_ if (error) { logger.error('AmsProxy.sendSubmission with sequenceNodeInfo: ', seqNodeInfoSum, ' returned ERROR:', error); callback(error, null); return; } logger.debug('AmsProxy.sendSubmission with sequenceNodeInfo ', seqNodeInfoSum, ' returned:', result); // Append our new nodeResult to the sequenceNode and update the cache var updatedSeqNodeInfo = appendResultToSequenceNode_(seqNodeInfo, nodeResult); updateCache_(sequenceNodeKey, updatedSeqNodeInfo); // Return, via the controller, to the IPC callback(error, ipsReturn); }); } }) .catch(function (error) { logger.error('CEProxy.sendSubmission with sequenceNodeInfo:', seqNodeInfoSum, ' returned ERROR:', error); callback(error, null); }) .done(); })
helper.runInTransaction(agent, function transactionWrapper(transaction) { q.ninvoke(function() { qContext.assertTransaction(transaction) secondTest.resolve() }) })
}).then(function(manifest) { return Q.ninvoke(fs, 'writeFile', path.join(root, 'manifest.json'), JSON.stringify(manifest)); })
function upsertDegree (degree) { return Q.ninvoke(db.collection('degrees'), 'update', {lsf_num: degree.lsf_num}, { $set: degree }, {upsert: true}); }
CWPPPaymentModel.prototype.send = function (cb) { var self = this if (self.readOnly) { return cb(new errors.PaymentAlreadyCommitedError()) } if (self.state !== 'fresh') { return cb(new errors.PaymentWasNotProperlyInitializedError()) } if (self.recipients.length === 0) { return cb(new errors.ZeroArrayLengthError('CWPPPaymentModel.send: recipients list is empty')) } if (self.seed === null) { return cb(new errors.MnemonicIsUndefinedError('CWPPPaymentModel.send')) } self.readOnly = true self.status = 'sending' /** * @param {Object} message * @return {Q.Promise<Object>} */ function cwppProcess (message) { var requestOpts = { method: 'POST', uri: cwpp.processURL(self.paymentURI), body: JSON.stringify(message), json: true } return Q.nfcall(request, requestOpts) .spread(function (response, body) { if (response.statusCode !== 200) { var error = response.statusMessage if (_.isObject(body) && body.error !== undefined) { error = body.error } throw new errors.RequestError('CWPPPaymentModel: ' + error) } return body }) } var wallet = self.walletEngine.getWallet() var blockchain = wallet.getBlockchain() var getTxFn = blockchain.getTx.bind(blockchain) console.log('CWPP: selectCoins') Q.ninvoke(self, 'selectCoins') .spread(function (cinputs, change, in_colordef) { // service build transaction console.log('CWPP: sending inputs') var msg = cwpp.make_cinputs_proc_req_1(in_colordef.getDesc(), cinputs, change) return getColorDef(self.assetModel) .then(function (out_colordef) { return cwppProcess(msg) .then(function (response) { console.log('CWPP: check tx') // restore tx (with prev scripts) var tx = new bitcore.Transaction(response.tx_data) var ftx = new cclib.tx.FilledInputs(tx, getTxFn) return Q.all(tx.inputs.map(function (input, inputIndex) { return ftx.getInputTx(inputIndex) .then(function (inputTx) { var newInput = bitcore.Transaction() .from({ txId: input.prevTxId.toString('hex'), outputIndex: input.outputIndex, script: inputTx.outputs[input.outputIndex].script, satoshis: inputTx.outputs[input.outputIndex].satoshis }) .inputs[0] newInput.sequenceNumber = tx.inputs[inputIndex].sequenceNumber tx.inputs[inputIndex] = newInput }) })) .then(function () { return tx }) }) .then(function (tx) { var rawTx = new cccore.tx.RawTx(tx) // check inputs and outputs return self._checkRawTx(rawTx, cinputs, change, out_colordef) .then(function () { return rawTx }) }) }) .then(function (rawTx) { console.log('CWPP: sign tx') // we signing transaction var tx = rawTx.toTransaction(true) var txInputs = _.zipObject(tx.inputs.map(function (input, inputIndex) { return [input.prevTxId.toString('hex') + input.outputIndex, inputIndex] })) var indexes = _.chain(cinputs) .map(function (input) { return txInputs[input.txId + input.outIndex] }) .value() var opts = {seedHex: self.seed, signingOnly: indexes} return Q.ninvoke(wallet, 'transformTx', rawTx, 'partially-signed', opts) }) }) .then(function (tx) { console.log('CWPP: sending partially-signed transaction') // service signing transaction var msg = cwpp.make_cinputs_proc_req_2(tx.toString()) return cwppProcess(msg) }) .then(function (response) { console.log('CWPP: sending fully signed transaction to the network') // build transaction and send var tx = new bitcore.Transaction(response.tx_data) self.txId = tx.id return Q.ninvoke(wallet, 'sendTx', tx) }) .then( function () { self.status = 'send' cb(null, self.txId) }, function (err) { self.status = 'failed' cb(err) } ) }
function upsertMajor (major) { return Q.ninvoke(db.collection('majors'), 'update', {lsf_num: major.lsf_num}, { $set: major, }, {upsert: true}); }
.then(function() { return Q.ninvoke(npm.commands, 'cache', ['add', pkg]); }).then(function(info) {
.then(function() { return Q.ninvoke(npm.commands, 'config', args); });
var getCurrentUserData = function () { return q.ninvoke(User, 'find', {}); };
.then(function() { return Q.ninvoke(npm.commands, 'adduser', args); });
function upsertEvent (event) { return Q.ninvoke(db.collection('events'), 'update', event, event, {upsert: true}); }
}).then(function() { return Q.ninvoke(npm.commands, 'search', args, true); });
}).then(function() { chdir(path.join(origDir, destAppDir)); console.log("Generating config.xml from manifest.json"); return Q.ninvoke(fs, 'readFile', path.join(ccaRoot, 'templates', 'config.xml'), {encoding: 'utf-8'}); }).then(function(data) {
}).then(function() { return Q.ninvoke(npm.commands, 'unpublish', args); }).then(function() {
function insertEvents (events) { if (events.length) return Q.ninvoke(db.collection('events'), 'insert', events); }
function upsertLocation (location) { return Q.ninvoke(db.collection('locations'), 'update', {lsf_id: location.lsf_id}, { $set: location }, {upsert: true}); }
}).then(function(manifestData) { plugins = manifestData.plugins; whitelist = manifestData.whitelist; console.log('## Updating config.xml from manifest.json'); return Q.ninvoke(fs, 'readFile', 'config.xml', {encoding: 'utf-8'}); }).then(function(data) {