<commit_before>var WebPage = require('webpage'),
    System = require('system'),
    address = System.args[1],
    index = 0;

// All the sizes to screenshot.
// Note: PhantomJs uses the heights specified here as a min-height criteria
var screenshots = [
  {'dimensions' : [970,300],
    'filename': './screenshots/screenshot_l.png'},
  {'dimensions' : [720,300],
    'filename': './screenshots/screenshot_m.png'},
  {'dimensions' : [400,200],
    'filename': './screenshots/screenshot_s.png'}
];

function capturescreen(){
  var processed = false;
  var page = WebPage.create();
  page.viewportSize = {
    width: screenshots[index].dimensions[0],
    height: screenshots[index].dimensions[1]
  };
  page.open(address);

  page.onError = function(){
    page.close();
    phantom.exit();
  };

  page.onLoadFinished = setTimeout(function() {
    if(processed) { return; }
    processed = true;
    page.render(screenshots[index].filename);
    page.close();
    index++;
    // Give it a second before calling next.
    // Phantom runs into some sort of race condition without this
    setTimeout(nextPage, 1000);
  }, 3000);
}

function nextPage(){
  if(!screenshots[index]){
    phantom.exit();
  }
  capturescreen();
}

nextPage();
//exit if not done after 20 seconds
setTimeout(function(){ phantom.exit(); }, 20000);<commit_msg>output and exit 1 for phantomjs script<commit_after>var WebPage = require('webpage'),
    System = require('system'),
    address = System.args[1],
    index = 0;

// All the sizes to screenshot.
// Note: PhantomJs uses the heights specified here as a min-height criteria
var screenshots = [
  {'dimensions' : [970,300],
    'filename': './screenshots/screenshot_l.png'},
  {'dimensions' : [720,300],
    'filename': './screenshots/screenshot_m.png'},
  {'dimensions' : [400,200],
    'filename': './screenshots/screenshot_s.png'}
];

function capturescreen(){
  var processed = false;
  var page = WebPage.create();
  page.viewportSize = {
    width: screenshots[index].dimensions[0],
    height: screenshots[index].dimensions[1]
  };
  console.log('Capture ' + screenshots[index].dimensions.join('x'));

  page.onError = function(msg, trace){
    var msgStack = ['ERROR: ' + msg];

    if (trace && trace.length) {
      msgStack.push('TRACE:');
      trace.forEach(function(t) {
        msgStack.push(' -> ' + t.file + ': ' + t.line + (t.function ? ' (in function "' + t.function +'")' : ''));
      });
    }

    console.error(msgStack.join('\n'));
    phantom.exit(1);
  };

  page.onLoadFinished = setTimeout(function() {
    console.log('Page loaded');
    if(processed) { return; }
    console.log('Saving image ' + screenshots[index].filename);
    processed = true;
    page.render(screenshots[index].filename);
    page.close();
    index++;
    // Give it a second before calling next.
    // Phantom runs into some sort of race condition without this
    setTimeout(nextPage, 1000);
  }, 3000);

  console.log('Open ' + address);
  page.open(address);
}

function nextPage(){
  if(!screenshots[index]){
    console.log('Finished');
    phantom.exit(0);
  }
  capturescreen();
}

nextPage();
//exit if not done after 20 seconds
setTimeout(function(){ phantom.exit(1); }, 20000);
{'fraction_non_alphanumeric': 0.1674937965260546, 'fraction_numerical': 0.024193548387096774, 'mean_word_length': 3.5615275813295617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6856746', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1026, 'n_words': 236}