// start an NV test with the "3G Busy" network scenario function startBusyTest() { // create an NV test logDebugMessage("Creating the NV test object"); var testConfig = { testManager: testManager, testName: "adv_realtime_update Sample Test", networkScenario: "3G Busy", testMode: Test.MODE.CUSTOM }; siteTest = new Test(testConfig); // add a flow to the test logDebugMessage("Adding a flow to the NV test"); var flowConfig = { flowId: "Flow1", latency: 200, packetloss: 0.5, bandwidthIn: 384, bandwidthOut: 128 }; var flow = new Flow(flowConfig); siteTest.addFlow(flow); // start the test if (!debug) { spinner.stop(true); } console.log("Starting the NV test with the \"3G Busy\" network scenario"); if (!debug) { spinner.start(); } return siteTest.start(); }
// handle errors and stop currently running tests and transactions function handleError(errorMessage) { // stop spinner if (!debug) { spinner.stop(true); } console.error("Error occurred: " + errorMessage); if (driver) { driver.close(); driver.quit(); driver = null; } if (siteTest1 || siteTest2) { try { testManager.stopAllTests(). then(function () { return setObjectToNull("siteTest1").then(function() { return setObjectToNull("siteTest2");}); }). then(null, function(error) { console.error("Stop tests failed with error: " + error); }); } catch(error) { console.error("Stop tests failed with error: " + error); } } // stop spinner if (!debug) { spinner.stop(true); } }
module.exports = function () { let bundleStart = null; const compiler = Webpack(webpackConfig); const spinner = new Spinner('processing.. %s'); spinner.setSpinnerString('/-\\'); compiler.plugin('compile', () => { console.info(`==> 💻 Webpack Dev Server listening on port ${devPort}`); spinner.start(); bundleStart = Date.now(); }); compiler.plugin('done', () => { console.log(`Bundled in ${Date.now() - bundleStart} ms!`); spinner.stop(); }); const bundler = new WebpackDevServer(compiler, { publicPath: '/build/', hot: true, quiet: false, noInfo: true, stats: { colors: true } }); bundler.listen(devPort, devHost, () => { console.log('Bundling project, please wait...'); }); };
// Upgrade Functions /** * Attempts a simple upgrade, eventually calling npm install -g npm * @param {string} version - Version that should be installed */ async function simpleUpgrade(version) { let spinner; if (program.prompt) { spinner = new Spinner('Upgrading (fallback method)... %s'); spinner.start(); } else { console.log('Starting upgrade (fallback method)...'); } powershell.runSimpleUpgrade(version).then(async function handleOutput(output) { if (spinner) spinner.stop(); if (output.error) { // Something went wrong - again :( return logError([output.error]); } const installedVersion = await versions.getInstalledNPMVersion(); if (installedVersion === version) { // Awesome, the upgrade worked! const info = 'Upgrade finished. Your new npm version is ' + installedVersion + '. Have a nice day!'; return console.log(chalk.bold.green(info)); } // Well, we're giving up here return logError([], version, installedVersion); }); }
listDevices: function () { var spinner = new Spinner('Retrieving devices...'); spinner.start(); var that = this; var prom = when.promise(function(resolve, reject) { that.request({ uri: '/v1/devices?access_token=' + that._access_token, method: 'GET', json: true }, function (error, response, body) { if (error) { return reject(error); } if (that.hasBadToken(body)) { return reject('Invalid token'); } if (body.error) { console.error('listDevices got error: ', body.error); reject(body.error); } else { that._devices = body; resolve(body); } }); }); prom.finally(function () { spinner.stop(true); }); return prom; },
client.on('listening', function () { var msg = new Buffer('hi') var spinner = new Spinner('Looking for netbeasts... %s') spinner.setSpinnerString('|/-\\') spinner.start() // Poll N times for Netbeast router's in subnet // ===================================== const N = 3 for (var i = 0; i < N; i++) { setTimeout(function () { client.send(msg, 0, msg.length, MCAST_PORT, MCAST_IP, function (err, bytes) { if (err) throw err }) }, i * 1000) } // Close client after N attempts setTimeout(function () { client.close() spinner.stop() if (result.length === 0) { console.log('No Netbeast routers found in subnet.') } console.log('\nDone.\n') if (typeof done === 'function') return done(result) }, N * 1000) })
// handle errors and stop currently running tests and transactions function handleError(errorMessage) { //stop spinner if (!debug) { spinner.stop(true); } console.error("Error occurred: " + errorMessage); if (driver) { driver.close(); driver.quit(); driver = null; } if (testRunning) { try { stopTest(). then(function () { return setTestRunning(false); }). then(null, function(error) { console.error("Stop test failed with error: " + error); }); } catch(error) { console.error("Stop test failed with error: " + error); } } // stop spinner if (!debug) { spinner.stop(true); } }
var getDocumentUrl = function(packageName, cb) { var docUrl = "https://www.npmjs.com/package/" + packageName; var registryUrl = "http://registry.npmjs.org/" + packageName; var spinner = new Spinner('%s'); spinner.setSpinnerString('|/-\\'); spinner.start(); request(registryUrl, function(err, res, body) { spinner.stop('clean'); if (err) return cb(err); if (body == '') { return cb('Can not found package: ' + packageName); } var npmObj = JSON.parse(body); if (npmObj.error) { return cb(npmObj.error); } if (npmObj.homepage && npmObj.homepage.match(/^https?:\/\//)) { docUrl = npmObj.homepage; } cb(null, docUrl); }); };
// analyze the specified .shunra file function analyzeShunra() { if (shunraFilePath) { if (!debug) { spinner.stop(true); } console.log("Analyzing the specified .shunra file"); if (!debug) { spinner.start(); } var analyzeParams; if (zipResultFilePath) { analyzeParams = { ports: analysisPorts, zipResultFilePath: zipResultFilePath, shunraFilePath: shunraFilePath }; return testManager.analyzeShunraFile(analyzeParams).then(printZipLocation); } else { analyzeParams = { ports: analysisPorts, useJsonFormat: true, shunraFilePath: shunraFilePath }; return testManager.analyzeShunraFile(analyzeParams).then(printNetworkTime); } } else { new Promise(function(resolve, reject) { resolve();}); } }
function launchSpinner() { utils.log('Launched installers, now waiting for them to finish.') utils.log('This will likely take some time - please be patient!') spinner = new Spinner(`Waiting for installers... %s`) spinner.setSpinnerDelay(180) spinner.start() }
var spin = function (message) { // Create Spinner var spinner = new Spinner([ message, '%s' ].join(' ')); spinner.setSpinnerString('|/-\\'); // return spinner return spinner; };
.then(() => { // Provision template spinner.stop(); console.log(chalk.green('DONE!')); spinner = new Spinner(chalk.cyan('Executing ARM template... %s')); spinner.setSpinnerString('|/-\\'); spinner.start(); return client.deployments.createOrUpdateAsync(resourceGroup, deploymentName, deploymentParameters); })
function logProgress(message) { if (spinner) { spinner.stop(); } currentLine = message; spinner = new Spinner(message + "... ".grey + "%s "); spinner.setSpinnerString(10); spinner.start(); }
.then(() => { // Create/Update Resource Group spinner.stop(); console.log(chalk.green('DONE!')); spinner = new Spinner(chalk.cyan('Creating/Updating Resource Group... %s')); spinner.setSpinnerString('|/-\\'); spinner.start(); return client.resourceGroups.createOrUpdateAsync(resourceGroup, { location: location }); })
.fail(function () { var revertSpinner = new Spinner(('NPM tests failed restoring to old versions ' + previousPackages.toString().replace(',', ', ') + ' %s').red); revertSpinner.setSpinnerString(5); revertSpinner.start(); return npm.install(previousPackages, installOptions).fail(function (err) { revertSpinner.stop(); throw err; }); });
return regeneratorRuntime.async(function simpleUpgrade$(context$1$0) { while (1) switch (context$1$0.prev = context$1$0.next) { case 0: spinner = undefined; if (program.prompt) { spinner = new Spinner('Upgrading (fallback method)... %s'); spinner.start(); } else { console.log('Starting upgrade (fallback method)...'); } powershell.runSimpleUpgrade(version).then(function handleOutput(output) { var installedVersion, info; return regeneratorRuntime.async(function handleOutput$(context$2$0) { while (1) switch (context$2$0.prev = context$2$0.next) { case 0: if (spinner) spinner.stop(); if (!output.error) { context$2$0.next = 3; break; } return context$2$0.abrupt('return', logError([output.error])); case 3: context$2$0.next = 5; return regeneratorRuntime.awrap(versions.getInstalledNPMVersion()); case 5: installedVersion = context$2$0.sent; if (!(installedVersion === version)) { context$2$0.next = 9; break; } info = 'Upgrade finished. Your new npm version is ' + installedVersion + '. Have a nice day!'; return context$2$0.abrupt('return', console.log(chalk.bold.green(info))); case 9: return context$2$0.abrupt('return', logError([], version, installedVersion)); case 10: case 'end': return context$2$0.stop(); } }, null, this); }); case 3: case 'end': return context$1$0.stop(); } }, null, this);
// stop the "Home Page" NV transaction in the second NV test function stopTransaction2() { if (!debug) { spinner.stop(true); } console.log("Stopping the \"Home Page\" transaction of the \"" + siteTest2.testMetadata.testName + "\" test"); if (!debug) { spinner.start(); } return siteTransaction2.stop(); }
webpack(config, function (err, stats) { var jsonStats = stats.toJson() spinner.setSpinnerString(stats.endTime - stats.startTime) spinner.stop() if (err) { throw err } else { next() } })
return new Promise(function(resolve, reject) { if (!debug) { spinner.stop(true); } console.log(); if (!debug) { spinner.start(); } resolve(); });
var promise = new Promise(function(resolve, reject) { if (!debug) { spinner.stop(true); } console.log("Analysis result .zip file path: " + zipLocation); if (!debug) { spinner.start(); } resolve(); });
// stop the NV test function stopTest() { if (!debug) { spinner.stop(true); } console.log("Stopping the NV test"); if (!debug) { spinner.start(); } return siteTest.stop(); }
// stop the "Home Page" NV transaction function stopTransaction() { if (!debug) { spinner.stop(true); } console.log("Stopping the \"Home Page\" transaction"); if (!debug) { spinner.start(); } return pageTransaction.stop(); }
// rerun the NV transaction after real-time update function startTransactionAfterRTU() { if (!debug) { spinner.stop(true); } console.log("Starting the \"Home Page\" transaction after real-time update"); if (!debug) { spinner.start(); } return pageTransaction.start(); }
// stop all running tests function stopAllTests() { if (!debug) { spinner.stop(true); } console.log("Stop all running tests"); if (!debug) { spinner.start(); } return testManager.stopAllTests(); }
.then( ( bPathIsOK ) => { if ( !bPathIsOK ) { console.log( chalk.bold.red( "✘ given folder doesn't exists, use current path instead." ) ); } sRootPath = sFolder; oSpinner.setSpinnerTitle( `Checking repos within ${ chalk.cyan( sRootPath ) }…` ); oSpinner.start(); return Promise.map( fGetSubPaths( sRootPath ), fCheckPath ); } )
(async () => { try { if (program.jsTranslations) { Gettext.getInstance(); js_translation.build(); js_translation.generate(); return; } const pages_filtered = getFilteredPages(); const pages_count = pages_filtered.length; if (!pages_count) { console.error(color.red('No page matched your request.')); return; } const sections = Array.from(new Set(pages_filtered.map(page => page.section))); sections.forEach(createDirectories); Gettext.getInstance(); // initialize before starting the compilation const start = Date.now(); const message = common.messageStart(`${is_translation ? 'Parsing' : 'Compiling'} ${pages_count} page${pages_count > 1 ? 's' : ''}`); const spinner = new Spinner(`${message} ${color.cyan('%s')}`); spinner.setSpinnerString(18); spinner.start(); if (pages_count <= 10 || program.verbose) { console.log(common.messageStart('Output list:', true)); pages_filtered .sort((a, b) => a.save_as > b.save_as) .forEach((p) => { console.log(color.green(' - '), p.save_as, p.section ? `(${p.section})` : ''); }); } context_builder = await createContextBuilder(sections); await Promise.all( pages_filtered.map(compile) ); spinner.stop(); process.stdout.write(`\b\b${common.messageEnd(Date.now() - start)}`); if (program.translations) { const gettext = Gettext.getInstance(); js_translation.build(); gettext.update_translations(); } } catch (e) { console.error(e); } })();
.then(() => { let armTemplate = require(env.ARMTemplate); this._modARMTemplate(armTemplate); deploymentParameters.properties.template = armTemplate; // Validation spinner.stop(); spinner = new Spinner(chalk.cyan('Validating ARM template... %s')); spinner.setSpinnerString('|/-\\'); spinner.start(); return client.deployments.validateAsync(resourceGroup, deploymentName, deploymentParameters) })
then(function() { // start the NV transaction if (!debug) { spinner.stop(true); } console.log("Starting the \"Home Page\" transaction in the \"" + siteTest2.testMetadata.testName + "\" test"); if (!debug) { spinner.start(); } return siteTransaction2.start(); });
async function returnMany(sqs, queueUrl, handles) { const spinner = new Spinner(`Returning ${handles.length} jobs to the queue...`); spinner.setSpinnerString('⠄⠆⠇⠋⠙⠸⠰⠠⠰⠸⠙⠋⠇⠆'); spinner.start(); const queue = new Queue({ concurrency: 10 }); const returns = handles.map((handle) => queue.add(() => returnOne(sqs, queueUrl, handle))); const returnManyResult = await Promise.all(returns); spinner.stop(true); return returnManyResult; }
then(function() { // start the NV transaction if (!debug) { spinner.stop(true); } console.log("Starting the \"Home Page\" transaction"); if (!debug) { spinner.start(); } return pageTransaction.start(); });