<commit_before>import logging
import socket
import json
import random
import os

class Spooler():
    def __init__(self, spooldir):
        try:
            os.chdir(spooldir)
        except OSError as e:
            logging.debug("Could not chdir to spooldir: %s", e)
            logging.warning("Couldn't open spooler directory, trying to create...")
            try:
                os.mkdir(spooldir)
                logging.info("Successfully created spooler directory %s", spooldir)
                os.chdir(spooldir)
            except OSError as e:
                logging.error("Could not use specified spooling directory: %s", e)
        logging.info("Spooler successfully initialized")

    def rndSpoolFile(self):
        num = random.random()
        num *= 10000
        return str(int(num))

    def spoolJob(self, jobToSpool):
        job = {}
        logging.debug("Locking job")
        job["locked"] = True
        logging.info("Spooling Job")
        job["postScript"] = jobToSpool
        jobFile = open(self.rndSpoolFile(), 'w')
        json.dump(job, jobFile)

class Printer():
    def __init__(self, bindaddr, port, name):
        logging.info("Creating new printer %s on %s:%s", name, bindaddr, port)
        try:
            self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.s.bind((bindaddr, port))
        except Exception as e:
            logging.error("Failed to bind printer %s", name)
            logging.error(e)
        logging.info("Initializing new spooler for %s", name)
        self.spooler = Spooler(name)

    def listener(self):<commit_msg>detect duplex options in postscript<commit_after>import logging
import socket
import json
import random
import os

class Spooler():
    def __init__(self, spooldir):
        try:
            os.chdir(spooldir)
        except OSError as e:
            logging.debug("Could not chdir to spooldir: %s", e)
            logging.warning("Couldn't open spooler directory, trying to create...")
            try:
                os.mkdir(spooldir)
                logging.info("Successfully created spooler directory %s", spooldir)
                os.chdir(spooldir)
            except OSError as e:
                logging.error("Could not use specified spooling directory: %s", e)
        logging.info("Spooler successfully initialized")

    def rndSpoolFile(self):
        num = random.random()
        num *= 10000
        return str(int(num))

    def spoolJob(self, jobToSpool):
        job = {}
        logging.debug("Locking job")
        job["locked"] = True
        logging.info("Spooling Job")
        if "/Duplex true" in jobToSpool:
            job["duplex"] = True
        else:
            job["duplex"] = False
        job["postScript"] = jobToSpool
        jobFile = open(self.rndSpoolFile(), 'w')
        json.dump(job, jobFile)

class Printer():
    def __init__(self, bindaddr, port, name):
        logging.info("Creating new printer %s on %s:%s", name, bindaddr, port)
        try:
            self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.s.bind((bindaddr, port))
        except Exception as e:
            logging.error("Failed to bind printer %s", name)
            logging.error(e)
        logging.info("Initializing new spooler for %s", name)
        self.spooler = Spooler(name)

    def listener(self):
{'fraction_non_alphanumeric': 0.10922619047619048, 'fraction_numerical': 0.002976190476190476, 'mean_word_length': 2.1588345864661656, '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': '2517487', 'n_tokens_mistral': 1020, 'n_tokens_neox': 982, 'n_words': 267}