<commit_before># -*- coding: utf-8 -*-

import subprocess


class SessionExists(Exception):
    description = "Session already exists."
    pass


class ServerConnectionError(Exception):
    description = "tmux server is not currently running."
    pass


class SessionDoesNotExist(Exception):
    description = "Session does not exist."
    pass


def kill(session):
    p = subprocess.Popen("tmux kill-session -t {}".format(session),
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)
    out, err = p.communicate()
    if "session not found" in err:
        raise SessionDoesNotExist(session)
    if "failed to connect to server" in err:
        raise ServerConnectionError()


def list():
    p = subprocess.Popen("tmux ls",
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)
    out, err = p.communicate()
    if "failed to connect to server" in err:
        raise ServerConnectionError()
    return out

def create(session):
    p = subprocess.Popen("tmux new -s {}".format(session),
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)
    out, err = p.communicate()

    if "duplicate session" in err:
        raise SessionExists(session)


def attach(session):
    p = subprocess.Popen("tmux a -t {}".format(session),
                     stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     shell=True)
    out, err = p.communicate()

    if "no sessions" in err:
        raise SessionDoesNotExist(session)

def create_or_attach(session):
    try:
        create(session)
    except SessionExists:
        attach(session)<commit_msg>Add raw tmux command method<commit_after># -*- coding: utf-8 -*-

import subprocess


class SessionExists(Exception):
    description = "Session already exists."
    pass


class ServerConnectionError(Exception):
    description = "tmux server is not currently running."
    pass


class SessionDoesNotExist(Exception):
    description = "Session does not exist."
    pass


def command(command):
    p = subprocess.Popen("tmux " + command,
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)
    return p.communicate()

def kill(session):
    p = subprocess.Popen("tmux kill-session -t {}".format(session),
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)
    out, err = p.communicate()

    if "session not found" in err:
        raise SessionDoesNotExist(session)
    if "failed to connect to server" in err:
        raise ServerConnectionError()


def list():
    p = subprocess.Popen("tmux ls",
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)
    out, err = p.communicate()

    if "failed to connect to server" in err:
        raise ServerConnectionError()
    return out

def create(session):
    p = subprocess.Popen("tmux new -s {}".format(session),
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE,
                         shell=True)
    out, err = p.communicate()

    if "duplicate session" in err:
        raise SessionExists(session)


def attach(session):
    p = subprocess.Popen("tmux attach-session -t {}".format(session),
                     stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     shell=True)
    out, err = p.communicate()

    if "no sessions" in err:
        raise SessionDoesNotExist(session)


def create_or_attach(session):

        create(session)
    except SessionExists:
        attach(session)

{'fraction_non_alphanumeric': 0.09432515337423313, 'fraction_numerical': 0.0005112474437627812, 'mean_word_length': 1.8920916481892092, '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': '2313329', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1038, 'n_words': 274}