casper.wait(5000, function(){ fs.write('/root/project/OkChym/188bet/series_a.txt', this.getHTML(), 'w'); });
var sendMessage = function(arg) { var args = Array.isArray(arg) ? arg : [].slice.call(arguments); last = new Date(); fs.write(tmpfile, JSON.stringify(args) + '\n', 'a'); };
/** * */ function takeReplyMessage(page, targetArray) { var filename = targetArray.testno; var fs = required('fs'); var path = "logs/"+filename+".log"; fs.write(path, page.content, 'w'); }
// The onReady callback function (time) { fs.write(options.outputFile, filter(page.content), "w"); globals.exit(0, "snapshot for "+options.url+" finished in "+time+" ms\n written to "+options.outputFile); },
function print(str) { fs.write('/dev/stdout', str, 'w'); }
Tiny.prototype.commit = function(func) { var self = this , fd = self._fd , queue = self._queue; if (self._busy || !queue.length || fd == null) return; debug('committing - %d items in queue.', queue.length); var cache = self._cache , data = [] , total = 0; self._busy = true; self._queue = []; queue = queue.map(function(item) { var docKey = item.docKey , doc = item.doc , cached = cache[docKey]; Object.keys(item.doc).forEach(function(propKey) { var realKey = docKey + '.' + propKey , prop = realKey + '\t' + doc[propKey] + '\n' , propSize = Buffer.byteLength(prop) , realKeySize = Buffer.byteLength(realKey + '\t'); if (propSize > CACHE_LIMIT) { cached[propKey] = new Lookup([ self._total + total + (realKeySize - 1), propSize - realKeySize ]); } total += propSize; data.push(prop); }); return item.func; }); if (func) queue.push(func); func = function(err) { self._busy = false; queue.forEach(function(func) { if (func) func(err); }); self.commit(); }; data = new Buffer(data.join('')); fs.write(fd, data, 0, data.length, self._total, function on(err, bytes) { if (err) { if (err.code === 'EBADF') { return func(err); } if (!on.attempt) { debug('write error: %s', err); on.attempt = 0; } if (++on.attempt === 5) { err.message = 'Write Error:\n' + err.message; return func(err); } return setTimeout(function() { fs.write(fd, data, 0, data.length, self._total, on); }, 50); } self._total += bytes; func(); }); };
exports.createDeleteUpdateParallel = function(opts) { _.defaults(opts, optsDefault); // start time opts.startTime = new Date(); // create the "test" collection const collection = opts.collection; db._drop(collection); let c = db._create(collection); // create the "results" collection const results = opts.results; db._drop(results); db._create(results); // create output directory fs.makeDirectoryRecursive("out"); // start worker let n = opts.concurrency; print("Starting", n, "worker"); const cmd = function(params) { require("./js/server/tests/stress/crud").createDeleteUpdateRaw(params); }; for (let i = 0; i < n; ++i) { let o = JSON.parse(JSON.stringify(opts)); o.prefix = "test_" + i + "_"; o.runId = "run_" + i; tasks.register({ id: "stress" + i, name: "stress test " + i, offset: i, params: o, command: cmd }); } // wait for a result const countDone = function() { const a = db._query("FOR u IN @@results FILTER u.finished RETURN 1", { '@results': 'results' }); const b = db._query("FOR u IN @@results FILTER u.started RETURN 1", { '@results': 'results' }); return a.count() === b.count(); }; let m = 0; for (let i = 0; i < 10; ++i) { m = db._query("FOR u IN @@results FILTER u.started RETURN 1", { '@results': 'results' }).count(); print(m + " workers are up and running"); if (m === n) { break; } sleep(30); } if (m < n) { print("cannot start enough workers (want", n + ",", "got", m + "),", "please check number V8 contexts"); throw new Error("cannot start workers"); } if (opts.gnuplot) { fs.write(fs.join("out", "documents.plot"), ` set terminal png size 1024,1024 set size ratio 0.4 set output "out/documents.png" set multiplot layout 3, 1 title "CRUD Stress Test" font ",14" set autoscale set logscale y set key outside set xlabel "runtime in seconds" set ylabel "numbers" plot \ "out/documents.csv" using 1:4 title "dead" with lines lw 2, \ '' using 1:6 title "inserts" with lines, \ '' using 1:7 title "updates" with lines, \ '' using 1:8 title "removes" with lines, \ '' using 1:9 title "ops" with lines set ylabel "numbers" plot \ "out/documents.csv" using 1:3 title "alive" with lines lw 2, \ '' using 1:5 title "total" with lines, \ '' using 1:11 title "uncollected" with lines set ylabel "rate" plot \ "out/documents.csv" using 1:10 title "ops/sec" with lines lw 2 `); fs.write(fs.join("out", "datafiles.plot"), ` set terminal png size 1024,1024 set size ratio 0.8 set output "out/datafiles.png" set autoscale set logscale y set xlabel "runtime in seconds" set ylabel "numbers" set key outside plot \ "out/datafiles.csv" using 1:2 title "datafiles" with lines, \ '' using 1:3 title "journals" with lines, \ '' using 1:4 title "compactors" with lines `); } let count = 0; while (!countDone()) { ++count; statistics(opts); if (opts.gnuplot && count % 6 === 0) { print("generating image"); gnuplot(); } sleep(10); } print("finished, final flush"); internal.wal.flush(true, true); internal.wait(5, false); c.rotate(); statistics(opts); // wait for a while let cc = 60; if (opts.duration < 5) { cc = 6; } else if (opts.duration < 10) { cc = 12; } else if (opts.duration < 60) { cc = 24; } for (let i = 0; i < cc; ++i) { statistics(opts); if (opts.gnuplot) { gnuplot(); } sleep(10); } return true; };
fs.open(this.outputDir + 'Test'+current.key + '.as', 'w', 666, function (e, id) { fs.write(id, myOutput, 0, myOutput.length, 0, function (id) { fs.close(id); }); });
() => fs.write(i, common.mustNotCall()),
var output_line = function (arr, msg) { fs.write('data/gamedata.csv', '"' + arr.join('","') + '"' + '\n', 'a') console.log(msg) }
function writeTimestamp(cb) { fs.write(file, Date.now() + '\n', cb); },
/** * Titanium WebSocket Client * * http://github.com/masuidrive/ti-websocket-client * * Copyright 2011 Yuichiro MASUI <*****@*****.**> * MIT License */ var LIB_DIR = __dirname + '/../lib/'; var fs = require('fs'); var extract_require = function(filename) { var content = fs.readFileSync(LIB_DIR + filename + '.js', 'utf8'); return content.replace(/require\s*\(\s*['"]{1}(.*?)['"]{1}\s*\)/g, function(full, fname) { var exports = extract_require(fname); return "(function(){var exports={};" + exports + "return exports;}())" }); }; fs.write( fs.openSync(__dirname + '/../ti-websocket-client.js', 'w') , extract_require('websocket-client') , 0 , 'utf8' ); console.log('Successfully generated the build: ti-websocket-client.js');
function writeOut(){ var file = JSON.stringify(data.words); var end = settings.end-1; fs.write('./data/scrape-'+settings.start+'-'+end+'.json', file, 'w'); }
fs.open('results.txt', 'a', 666, function( e, id ) { for (r in request.body.results) { fs.write( id, getIpAddress(request) + ", " + request.body.results[r] + "\n", null, 'utf8'); }; fs.close(id); });
var sendMessage = function() { fs.write(args.tempFile, JSON.stringify(Array.prototype.slice.call(arguments)) + '\n', 'a'); };
const written = common.mustCall((err, written) => { assert.ifError(err); assert.strictEqual(written, 0); fs.write(fd, expected, 0, 'utf8', done); });
var outfile = system.args[2]; // change the working directory to the current library path fs.changeWorkingDirectory(phantom.libraryPath); var templateContent = fs.read(template + ".html"); phantom.injectJs('shared/handlebars.js'); var handlebar = Handlebars.compile(templateContent); var renderedTemplate = handlebar({code: code}); //var temporary_outfile = "tmp_render_outfile.html"; var temporary_outfile = outfile.split("/").pop().split(".")[0] + "-" + system.pid + ".html"; //console.log(temporary_outfile); fs.write(temporary_outfile, renderedTemplate, "w"); var page = require('webpage').create(); page.onLoadFinished = function(status) { setTimeout(function(){ var size = page.evaluate(function() { // calculate the min dimensions var w = 0; var h = 0; $("#uiui>*>*").each(function (i, l) { var l = $(l); var nw = l.outerWidth() + l.position().left; if (nw > w)w = nw; var nh = l.outerHeight() + l.position().top; if (nh > h)h = nh;
ScopedFS.prototype.write = function(fd, buffer, offset, length, position, callback) { return fs.write(fd, buffer, offset, length, position, callback); };
return setTimeout(function() { fs.write(fd, data, 0, data.length, self._total, on); }, 50);
casper.then(function saveCookie(){ // this.echo(JSON.stringify(phantom.cookies)); var fs = require('fs'); var cookies = JSON.stringify(phantom.cookies); fs.write('../_tmp/_cookie.json', cookies, 644); });
function statistics(opts) { if (!statisticsInitialized) { fs.makeDirectoryRecursive("out"); fs.write(docLog, "# " + docKeys.join("\t") + "\n"); fs.write(dfLog, "# " + dfKeys.join("\t") + "\n"); statisticsInitialized = true; } const collection = opts.collection; const results = opts.results; const s = db._query( ` FOR u IN @@results COLLECT g = 1 AGGREGATE inserts = SUM(u.statistics.inserts), updates = SUM(u.statistics.updates), removes = SUM(u.statistics.removes) RETURN { inserts: inserts, updates: updates, removes: removes, total: inserts - removes, operations: inserts + updates + removes, count: length(@@test)} `, { '@results': results, '@test': 'test' }).toArray()[0]; if (s !== undefined) { const f = db[collection].figures(); s.runtime = Math.round(((new Date()) - opts.startTime) / 1000); s.alive = f.alive.count; s.compactors = f.compactors.count; s.datafiles = f.datafiles.count; s.dead = f.dead.count; s.journals = f.journals.count; s.uncollectedLogfileEntries = f.uncollectedLogfileEntries; if (statisticsPrev === undefined) { s.ops_per_sec = 0; } else { const d = s.runtime - statisticsPrev.runtime; if (d === 0) { s.ops_per_sec = 0; } else { s.ops_per_sec = (s.operations - statisticsPrev.operations) / d; } } statisticsPrev = s; fs.append(docLog, docKeys.map(function(x) { return s[x]; }).join("\t") + "\n"); fs.append(dfLog, dfKeys.map(function(x) { return s[x]; }).join("\t") + "\n"); } }
writeToLog = function( str ){ if(fd == undefined){ fd = fs.openSync(path.join(conf.directory, conf.filename), 'a'); } fs.write( fd, str+"\n" ); }
casper.run(function(){ fs.write('..' + fs.separator + 'test' + fs.separator + 'TodoMVC' + fs.separator + 'report.json', JSON.stringify(report, null, '\t'), 'w'); phantom.exit(); });
var terminate = function(){ fs.write('weapons.txt', weaponsAll.join('\n'), 'w'); casper.log("the end", 'info'); }
page.onResourceReceived = function(response) { pageResponses[response.url] = response.status; fs.write(CookieJar, JSON.stringify(phantom.cookies), "w"); };
return new loggers.base(function(msg) { fs.write(config.logFile, msg + "\n", 'a'); });
return readStreamToBuffer(response, __cb(_, __frame, 28, 23, function ___(__0, __4) { buff = __4; return fs.write(fileHandle, buff, 0, bytesToRead, offset, __cb(_, __frame, 29, 15, function __$__1() { offset += bytesToRead; while (__more) { __loop(); }; __more = true; }, true)); }, true)); }, true)); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); }); })(function ___(err, __result) { __catch(function __$__1() { if (err) {
w.write = function(s) { fs.write(config.outFile, s, 'a'); };
fs.open(welcomefilepath, "w", function(err,fd) { var buf = new Buffer("git clone https://github.com/xushvai/Doopbox.git"); fs.write(fd,buf,0,buf.length,0,function(err,written,buffer) { reqURL = 'http://' + svrHost + ':' + svrPort + '/webhdfs/v1/home/' + username + '/' + welcomefile + '?op=CREATE&overwrite=true'; hdfs._sendRequest('PUT', reqURL, '', function cb(err, res2, body) { var location = ''; if (res2.statusCode == 307) { location = res2.headers.location; var href = location; var request = require("request"); fs.createReadStream(welcomefilepath).pipe(request.put(href)); } }); }); });
console.log=function(txt) { var fd = fs.openSync('debug.txt', 'a'); fs.write(fd,txt+'\n'); fs.close(fd); oconsole(txt); };