<commit_before>#!/bin/bash

# Name: magma.stat.sh
# Author: <NAME>
#
# Description: Used for quickly printing the internal magma statistics using the molten protocol.

# Check and make sure magmad is running before attempting a connection.
PID=`pidof magmad magmad.check`       

if [ -z "$PID" ]; then
	tput setaf 1; tput bold; echo "Magma process isn't running."; tput sgr0
	exit 2
fi

printf "stats\r\nquit\r\n" | nc -w 120s localhost 6000
if [ "$?" != "0" ]; then
	sleep 5
	printf "stats\r\nquit\r\n" | nc -w 120s localhost 6000
fi
if [ "$?" != "0" ]; then
	echo "error fetching magma statistics"
fi <commit_msg>Using a more versatile netcat timeout strategy in the magma.stat script.<commit_after>#!/bin/bash

# Name: magma.stat.sh
# Author: <NAME>
#
# Description: Used for quickly printing the internal magma statistics using the molten protocol.

# Check and make sure magmad is running before attempting a connection.
PID=`pidof magmad magmad.check`       

if [ -z "$PID" ]; then
	tput setaf 1; tput bold; echo "Magma process isn't running."; tput sgr0
	exit 2
fi

printf "stats\r\nquit\r\n" | timeout 60 nc localhost 6000
if [ "$?" != "0" ]; then
	sleep 5
	printf "stats\r\nquit\r\n" | timeout 60 nc localhost 6000
fi
if [ "$?" != "0" ]; then
	echo "An error occurred while fetching the Magma statistics."
fi 
{'fraction_non_alphanumeric': 0.12045454545454545, 'fraction_numerical': 0.02878787878787879, 'mean_word_length': 3.717857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5979459', 'n_tokens_mistral': 495, 'n_tokens_neox': 443, 'n_words': 174}