<commit_before>#!/usr/bin/env python

# Build a bunch of SRPMs

import getopt
import sys
import os
import glob
import subprocess
import shutil
import rpm
import hashlib

from planex_globals import (BUILD_ROOT_DIR, SRPMS_DIR, RPMS_DIR, BUILD_DIR,
                            SPECS_GLOB)


TMP_RPM_PATH = "/tmp/RPMS"
RPM_TOP_DIR = os.path.join(os.getcwd(), BUILD_ROOT_DIR)
CACHE_DIR = "rpmcache"


def exists(path):
    return os.access(path, os.F_OK)


def doexec(args, inputtext=None):
    """Execute a subprocess, then return its return code, stdout and stderr"""
    print "Executing: %s" % " ".join(args)
    myenv = os.environ.copy()
    myenv['HOME'] = RPM_TOP_DIR
    proc = subprocess.Popen(args, env=myenv, stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                            close_fds=True)
    (stdout, stderr) = proc.communicate(inputtext)
    ret = proc.returncode
    return (ret, stdout, stderr)


def get_srpm_info(srpm):
    for spec_path in glob.glob(SPECS_GLOB):
        os.unlink(spec_path)
    (ret, _, _) = doexec(["rpm", "-i", srpm])
    assert ret == 0
    myspecfile = glob.glob(SPECS_GLOB)[0]
    spec = rpm.ts().parseSpec(myspecfile)
    info = {}
    info['deps'] = spec.sourceHeader["requires"]
    info['arch'] = "i686"
    info['packages'] = [{'name':p.header['name']} for p in spec.packages]
    info['srcrpm'] = srpm
    content_file = open(myspecfile,'r')
    info['spec'] = content_file.read()<commit_msg>build: Remove unused 'exists' function<commit_after>#!/usr/bin/env python

# Build a bunch of SRPMs

import getopt
import sys
import os
import glob
import subprocess
import shutil
import rpm
import hashlib

from planex_globals import (BUILD_ROOT_DIR, SRPMS_DIR, RPMS_DIR, BUILD_DIR,
                            SPECS_GLOB)


TMP_RPM_PATH = "/tmp/RPMS"
RPM_TOP_DIR = os.path.join(os.getcwd(), BUILD_ROOT_DIR)
CACHE_DIR = "rpmcache"


def doexec(args, inputtext=None):
    """Execute a subprocess, then return its return code, stdout and stderr"""
    print "Executing: %s" % " ".join(args)
    myenv = os.environ.copy()
    myenv['HOME'] = RPM_TOP_DIR
    proc = subprocess.Popen(args, env=myenv, stdin=subprocess.PIPE,
                            stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                            close_fds=True)
    (stdout, stderr) = proc.communicate(inputtext)
    ret = proc.returncode
    return (ret, stdout, stderr)


def get_srpm_info(srpm):
    for spec_path in glob.glob(SPECS_GLOB):
        os.unlink(spec_path)
    (ret, _, _) = doexec(["rpm", "-i", srpm])
    assert ret == 0
    myspecfile = glob.glob(SPECS_GLOB)[0]
    spec = rpm.ts().parseSpec(myspecfile)
    info = {}
    info['deps'] = spec.sourceHeader["requires"]
    info['arch'] = "i686"
    info['packages'] = [{'name':p.header['name']} for p in spec.packages]
    info['srcrpm'] = srpm
    content_file = open(myspecfile,'r')
    info['spec'] = content_file.read()
{'fraction_non_alphanumeric': 0.1339858251771853, 'fraction_numerical': 0.0033749578130273373, 'mean_word_length': 3.210227272727273, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '429026', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1045, 'n_words': 230}