<commit_before>import child_process from 'child_process';
import util from 'util';

const exec = util.promisify(child_process.exec);

export default async function curl(args) {
  const { proxyMethod = 'socks5', proxyHost, proxyPort, targetHost, targetPort } = args;
  const { username, password } = args;
  const proxy = {
    'http': '-x',
    'http_connect': '-px',
    'socks': '--socks5',
    'socks4': '--socks4',
    'socks4a': '--socks4a',
    'socks5': '--socks5-hostname',
  }[proxyMethod];

  try {
    let command = `curl `;
    if (username && password) {
      command += `-U ${username}:${password} `;
    }
    if (proxy) {
      command += `-L ${proxy} ${proxyHost}:${proxyPort} `;
    }
    if (proxyMethod === 'https') {
      command += `--proxy-insecure -Lx https://${proxyHost}:${proxyPort} `;
    }
    command += `${targetHost}:${targetPort} `;
    // console.log(command);
    const { stdout } = await exec(command, { encoding: 'utf-8', timeout: 5e3 });
    return stdout;
  } catch (err) {
    // console.log(err);
    return '';
  }
}<commit_msg>ci: log curl error message<commit_after>import child_process from 'child_process';
import util from 'util';

const exec = util.promisify(child_process.exec);

export default async function curl(args) {
  const { proxyMethod = 'socks5', proxyHost, proxyPort, targetHost, targetPort } = args;
  const { username, password } = args;
  const proxy = {
    'http': '-x',
    'http_connect': '-px',
    'socks': '--socks5',
    'socks4': '--socks4',
    'socks4a': '--socks4a',
    'socks5': '--socks5-hostname',
  }[proxyMethod];

  try {
    let command = `curl `;
    if (username && password) {
      command += `-U ${username}:${password} `;
    }
    if (proxy) {
      command += `-L ${proxy} ${proxyHost}:${proxyPort} `;
    }
    if (proxyMethod === 'https') {
      command += `--proxy-insecure -Lx https://${proxyHost}:${proxyPort} `;
    }
    command += `${targetHost}:${targetPort} `;
    // console.log(command);
    const { stdout } = await exec(command, { encoding: 'utf-8', timeout: 5e3 });
    return stdout;
  } catch (err) {
    console.log(err);
    return '';
  }
}
{'fraction_non_alphanumeric': 0.1926648096564531, 'fraction_numerical': 0.01021355617455896, 'mean_word_length': 3.081439393939394, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3667624', 'n_tokens_mistral': 747, 'n_tokens_neox': 733, 'n_words': 170}