Example #1
0
File: main.js Project: jdNash/tepl
         exec(command, function(error, stdout, stderr){
        
            sys.print('stdout: ' + stdout);
            sys.print('stderr: ' + stderr);
                if (error !== null) {
                    console.log('exec error: ' + error);
                } else { console.log('No error');}
                console.log("On to readfile callback");
                callback(makeGet, caller.number, inFile);

            });
Example #2
0
function test() {
  var red = {
    equals: function(o){ return ''+o === this.toString(); },
    toString:function(){return 'red';}};
  var c1 = Circle(0, 1, red);
  var c2 = Circle(1, 2, red);
  print('c1.area: ' + c1.area());
  print('\nc1 < c2? ' + c1.smaller(c2));
  print('\nc1 !== c2?' + c1.differs(c2));
  print('\nc1 equalColors c2? '+c1.equalColors(c2));
}
 child = exec("/usr/local/bin/haproxy_reload", function(error, stdout, stderr) {
   sys.print('stdout: ' + stdout + "\n");
   sys.print('stderr: ' + stderr + "\n");
   if (error !== null) {
     console.log('exec error: ' + error);
     res.status(500).end();
   } 
   else {
     res.status(202).end();
   }   
 });
Example #4
0
 testDone: function (name, assertions) {
     if (!assertions.failures()) {
         sys.print('.');
     }
     else {
         sys.print(red('F'));
         assertions.forEach(function (assertion) {
             assertion.testname = name;
         });
     }
 },
Example #5
0
  function print_nibbles(reg_name, value) {
    var bits = device.fields[reg_name],
      field_name,
      bit,
      slice,
      shift,
      len,
      bin;

    //sys.print(bits + ' ' + reg_name + ' ' + value);
    sys.print("\n");
    sys.print(leadWith('', 22, ' ') + leadWith('-', 12+8+8, '-') + "\n");
    for (field_name in bits) {
      if (!bits.hasOwnProperty(field_name)) return;

      len = 0;
      slice = bits[field_name];
      // interpret correctly no matter the order [0:2] or [3:1] or [4]
      if ('undefined' !== typeof slice[1]) {
        if (slice[1] > slice[0]) {
    shift = slice[1];
    len = slice[1] - slice[0];
        } else {
    shift = slice[0];
    len = slice[0] - slice[1];
        }
      } else {
        shift = slice[0];
      }
      len += 1;

      // TODO allow other byte orders?
      // Because most systems are LSB, if we want to
      // read bit 31:29, from a 32-bit register
      //  we must substr char 0:2
      if (true /* == lsb */) {
        shift = global_msb - shift;
      }

      field_name = trailWith(field_name + ' [' + slice.join(':') + '] ', 20);

      bin = leadWith(value.toString(2), 32, '0');
      nibble = bin.substr(shift, len);

      //sys.print('  ' + field_name + ' bin' + bin + 'slice:' + slice.join(',') + ' ' + len + ' nib:' + nibble + "\n");

      hex = leadWith(parseInt(nibble, 2).toString(16), 8, '0');
      dec = parseInt(nibble, 2).toString(10);

      sys.print('  ' + field_name + " 0x" + hex + " == " + dec + "\n");
    }
    sys.print(leadWith('', 22, ' ') + leadWith('-', 12+8+8, '-') + "\n");
    sys.print("\n\n");
  }
Example #6
0
client.addListener('success', function(method, response) {
  sys.puts(method);
  if (response) {
    if (response.constructor.name == 'Date') {
      sys.print(response);
    } else {
      sys.print(sys.inspect(response));
    }
  }
  sys.puts("\n");
});
Example #7
0
	child = exec(command, function(error, stdout, stderr){
		sys.print('stdout: ' + stdout);
		sys.print('stderr: ' + stderr);		
		if(error !== null){
			console.log("exec command: "  + command + " failed with error: "+ error);
			res.end('stdout:\n' + stdout + '\n\nstderr:\n' + stderr + ' \n\n error: \n' + error);
		}else{
			console.log('exec command: ' + command + " worked")
			res.end('stdout:\n' + stdout + '\n\nstderr:\n' + stderr);
		}
	});	
Example #8
0
 files.forEach(function(file) {
     log('parsing ' + file);
     str = fs.readFileSync(file, 'utf8');
     if (first) {
         if (desc) desc = markdown.parse(desc);
         sys.print('<tr><td><h1>' + title + '</h1>' + desc + '</td><td></td></tr>');
         first = false;
     }
     sys.print(render(str, file));
     --pending || sys.print(foot, '</tbody></table>');
 });
    exec(command, function(error, stdout, stderr) {
      if (stderr) {
        sys.print(stderr + EOL);
      }

      if (error) {
        sys.print(stdout + EOL);
        reject(error);
      } else {
        resolve(cssDir);
      }
    });
Example #10
0
 fs.readFile(file, 'utf8', function(err, str){
     if (err) throw err;
     if (first) {
         if (desc) desc = markdown.toHTML(desc);
         sys.print('<tr><td><h1>' + title + '</h1>' + desc + '</td><td></td></tr>');
         first = false;
     }
     sys.print('<tr class="filename"><td><h2 id="' + file + '"><a href="#">'
         + path.basename(file, '.js') + '</a></h2></td><td>'
         + file + '</td></tr>');
     sys.print(render(str, file));
     --pending || sys.print(foot, '</tbody></table>');
 });
Example #11
0
		function (error, stdout, stderr) {
			console.log('stdout: ' + stdout);
			console.log('stderr: ' + stderr);
			console.log('db server started');
			sys.print('stdout: ' + stdout);
			sys.print('stderr: ' + stderr);

			if (error != null ){
				throw new Error("could not excecute db server init command")
				console.log("ERROR!: " + error );
				return
			}
		}
  startLine: function(name) {
    var winners = Benchmark.map(this.winners(this.currentBenches), function(bench) {
      return bench.name.split(": ")[1];
    });

    this.currentBenches = [];

    print(winners.join(", "));
    print("\n");
    var padding = Math.max(this.benchSize - name.length + 1, 0);
    name = name + new Array(padding).join(" ");
    print(name);
  },
Example #13
0
ansiColor = function(color) {
  var colors = {
    green: "32",
    red: "31",
    yellow: "33"
  };

  if (color) {
    sys.print("\u001B[" + colors[color] + "m")
  } else {
    sys.print("\u001B[0m")
  }
};
Example #14
0
pcap_session.findalldevs().forEach(function (dev) {
    if (pcap_session.device_name === dev.name) {
        sys.print(dev.name + " ");
        if (dev.addresses.length > 0) {
            dev.addresses.forEach(function (address) {
                sys.print(address.addr + "/" + address.netmask);
            });
            sys.print("\n");
        } else {
            sys.print("no address\n");
        }
    }
});
Example #15
0
					exec("cd ./src && grunt", function (error, stdout, stderr) {
						var status = 'build complete';

						sys.print( 'stdout: ' + stdout);
						sys.print( 'stderr: ' + stderr);

						socket.emit( 'step', {
							id: 'build',
							status: status
						});

						callback( null );
					});
Example #16
0
					exec("git clone " + url + " src", function (error, stdout, stderr) {
						var status = 'clone complete';

						sys.print( 'stdout: ' + stdout);
						sys.print( 'stderr: ' + stderr);

						socket.emit( 'step', {
							id: 'clone',
							status: status
						});

						callback( null );
					});
Example #17
0
  bench: function() {
    var benchSize = 0, names = this.names, self = this, i, l;

    for(i=0, l=names.length; i<l; i++) {
      var name = names[i];

      if(benchSize < name.length) { benchSize = name.length; }
    }

    this.nameSize = benchSize + 2;
    this.benchSize = 20;
    var horSize = 0;

    this.startLine("ops/msec");
    horSize = horSize + "ops/msec    ".length;
    for(i=0, l=names.length; i<l; i++) {
      print(names[i] + new Array(this.benchSize - names[i].length + 1).join(" "));
      horSize = horSize + this.benchSize;
    }

    print("WINNER(S)");
    horSize = horSize + "WINNER(S)".length;

    print("\n" + new Array(horSize + 1).join("-"));

    Benchmark.invoke(this.benchmarks, {
      name: "run",
      onComplete: function() {
        var errors = false, prop, bench;
        for(prop in self.errors) { if(self.errors.hasOwnProperty(prop)) { errors = true; break; } }

        if(errors) {
          print("\n\nErrors:\n");
          for(prop in self.errors) {
            if(self.errors.hasOwnProperty(prop)) {
              bench = self.errors[prop];
              print("\n" + bench.name + ":\n");
              print(bench.error.message);
              if(bench.error.stack) {
                print(bench.error.stack.join("\n"));
              }
              print("\n");
            }
          }
        }
      }
    });

    print("\n");
  },
Example #18
0
 failures.forEach(function(failure, index) {
   sys.puts('')
   sys.puts('  ' + (index + 1) + ') ' + failure.description )
   sys.puts("    " + ansi.yellow + ' ' + failure.message + ansi.none)
   var stacktrace = failure.stacktrace
   stacktrace.shift()
   if (stacktrace[0] && !failure.pending) 
     reporter.extractFailureLine(stacktrace[0])
   sys.print(ansi.grey)
   stacktrace.forEach(function(line) {
     sys.puts("     # " + line.replace(process.cwd() + '/', ''))
   })
   sys.print(ansi.none)
 })
Example #19
0
	term = exec(cmd, function (error, stdout, stderr) {
        sys.print('stdout: ' + stdout);
        sys.print('stderr: ' + stderr);
        if (error !== null) {
        	console.log('exec error: ' + error);
        	if (res)
        	{
        		res.send({"status": "KO", "comment": "links cannot added to donwload !","stderr":stderr, "error":error});
        	}
        }
        else if (res)
        {
        	res.send({"status": "OK", "comment": "links added to download !", "stdout":stdout});
        }
      });
Example #20
0
    child = exec('if [ -x "./node_modules/pegjs/bin/pegjs" ] ; then PEGJS="./node_modules/pegjs/bin/pegjs"; else PEGJS="pegjs" ; fi && $PEGJS -e JsSIP.Grammar src/Grammar/src/Grammar.pegjs src/Grammar/dist/Grammar.js', function(error, stdout, stderr) {
      if (error) {
        sys.print('ERROR: ' + stderr);
        done(false);  // Tell grunt that async task has failed.
      }
      console.log('OK');

      // Then modify the generated Grammar.js file with custom changes.
      console.log('"grammar" task: applying custom changes to Grammar.js ...');
      var fs = require('fs');
      var grammar = fs.readFileSync('src/Grammar/dist/Grammar.js').toString();
      var modified_grammar = grammar.replace(/throw new this\.SyntaxError\(([\s\S]*?)\);([\s\S]*?)}([\s\S]*?)return result;/, 'new this.SyntaxError($1);\n        return -1;$2}$3return data;');
      fs.writeFileSync('src/Grammar/dist/Grammar.js', modified_grammar);
      console.log('OK');

      // Then minify Grammar.js.
      console.log('"grammar" task: minifying Grammar.js ...');
      child = exec('cd src/Grammar/ && node minify.js', function(error, stdout, stderr) {
        if (error) {
          sys.print('ERROR: ' + stderr);
          done(false);  // Tell grunt that async task has failed.
        }
        console.log('OK');
        done();  // Tell grunt that async task has succeeded.
      });
    });
Example #21
0
sendSocket.on('data', sip.makeStreamParser(function(m) {
  assert.deepEqual(m.headers, resp.headers);
  assert.deepEqual(m, resp);
  transport.destroy();
  sendSocket.end();
  sys.print('PASSED\n');
})) 
  writeBench: function(bench) {
    var out;

    if(!bench.error) {
      var count = bench.hz,
          moe   = count * bench.stats.rme / 100,
          minimum,
          maximum;

      count = Math.round(count / 1000);
      moe = Math.round(moe / 1000);
      minimum = count - moe;
      maximum = count + moe;

      out = count + " ±" + moe + " (" + bench.cycles + ")";

      this.times[bench.suiteName][bench.benchName] = count;
      this.minimum = Math.min(this.minimum, minimum);
      this.maximum = Math.max(this.maximum, maximum);
    } else {
      if (bench.error.message === 'EWOT') {
        out = 'NA';
      } else {
        out = 'E';
      }
    }

    var padding = this.benchSize - out.length + 1;
    out = out + new Array(padding).join(" ");
    print(out);
  }
Example #23
0
var sendFileResponse = function(res, fullPath, opt_prepFn) {
  debug("path: " + fullPath);
  if (g.cwd != fullPath.substring(0, g.cwd.length)) {
    sys.print("forbidden: " + fullPath + "\n");
    return send403(res);
  }
  var mimeType = mime.lookup(fullPath);
  if (mimeType) {
    fs.readFile(fullPath, function(err, data){
      if (err) {
        sys.print("unknown file: " + fullPath + "\n");
        return send404(res);
      }
      if (opt_prepFn) {
        data = opt_prepFn(data.toString());
      }
      if (strings.startsWith(mimeType, "text")) {
        res.writeHead(200, {
          'Content-Type':  mimeType + '; charset=utf-8',
          'Cache-Control': 'no-cache, no-store, must-revalidate', // HTTP 1.1.
          'Pragma':        'no-cache',                            // HTTP 1.0.
          'Expires':       '0',                                   // Proxies.
        });
        res.write(data, "utf8");
        res.end();
      } else {
        sendStringResponse(res, data, mimeType);
      }
    });
  } else {
    send404(res);
  }
};
Example #24
0
echo = function (text, nonl) {
  if (nonl === undefined) {
    sys.puts(text);
  } else {
    sys.print(text);
  }
};
Example #25
0
 (function nextTest () {
     var test = tests.pop();
     if (!test) {
         sys.puts(
             (ok + failed) + ' tests: '
             + ok + ' ok, ' + failed + ' failed'
         );
     }
     else {
         sys.print(test + ' ... ');
         proc.exec(__dirname + '/' + test, function (err, stdout, stderr) {
             if (err) {
                 sys.puts('failed');
                 sys.puts(err);
                 failed ++;
             }
             else if (stderr) {
                 sys.puts('failed');
                 sys.puts(stderr);
                 failed ++;
             }
             else {
                 sys.puts('ok');
                 ok ++;
             }
             nextTest();
         });
     }
 })();
Example #26
0
 function log(query) {
   var timestamp = +new Date();
   broadcaster.broadcast("share", { t: timestamp, q: query.q, l: query.lang, g: query.gender, c: query.count, u: query.userid });
   var message = [timestamp, query.q, query.lang, query.gender, query.count, query.userid, query.v].join('\t') + '\n';
   if (DEBUG>1) { sys.print(SHARE_LOG + ': '+message); }
   fs.write(share_file, message, null, 'utf-8' );
 }
Example #27
0
stdin.addListener('end', function(){
    sys.print(str.replace(/<code>([^]+?)<\/code>/g, function(_, code){
        return looksLikeJavaScript(code)
            ? '<code class="js">' + koala.render('.js', code) + '</code>'
            : '<code>' + code + '</code>';
    }));
});
Example #28
0
exports.reporter.prototype.printSummary = function(result) {
  sys.puts('')    
  sys.puts('Completed in ' + (result.duration / 1000) + ' seconds')
  if (result.failed > 0) {
    sys.print(ansi.red + result.total + " " + (result.total > 1 ? "examples" : "example") + ", " )      
    sys.print(result.failed + " " +  (result.failed > 1 ? "failures" : "failure") + "")      
    if (result.pending > 0) 
      sys.print(', ' + result.pending + " pending")      
    sys.puts(ansi.none)
  } else if (result.pending > 0) {
    sys.print(ansi.yellow + result.total + " " + (result.total > 1 ? "examples" : "example") + ", " )      
    sys.puts(result.pending + " pending" + ansi.none)      
  } else {
    sys.puts(ansi.green + result.total + " " +  (result.total > 1 ? "examples" : "example") + " " + ansi.none)
  }
};
Example #29
0
 exec('npm run build', function(err, stdout, stderr ) {
     sys.print(stdout);
     if (err !== null) {
         console.log(err);
     }
     done();
 });
Example #30
0
  this.die = function (str) {
	var len = str.length, i;
	for (i = 0; i < len; i+=25) {
		sys.print(str.slice(i,i+25));
	}
    process.exit();
  };