<commit_before>#!/bin/bash 

#############################
# A fairly basic wrapper around modulecmd to allow actions on loading or unloading a module.
#
# <NAME>, 2013


# Params to edit
PathToModuleCmd=/shared/ucl/apps/modules-3.2.10-modlog
RealModuleCommand=$PathToModuleCmd/modulecmd
ExternalLogger=$PathToModuleCmd/mysql_injector


LogMode="external"
# LogMode="file"

# Obviously if you're logging to files, you'll want to 
#   put them somewhere you can gather/access them.
# This is our Lustre file system, for example.
# Only used if LogMode = "file"
LogFilesDirectory=/scratch/scratch/.modusage


# End of params
#############################

Date=`date +%s`

## Create log file name
# For Logging Messages in files rather than using an external tool

SessionPID=$1 # This is added by our altered module shell function
TimeCode=${Date:0:6} 
# ^--- This gives a 10000 window on things being considered the same session - 
#        to let us track the same session, but also allow for PID recycling
#      It's hardly perfect, but it at least does something.
shift

UsageFile=${LogFilesDirectory}/$SessionPID.$TimeCode.`whoami`.`hostname`.${JOB_ID:=undefined}.${TASK_ID:=undefined}
umask 0077 # Thus files should be 0600


## Run actual module command

$RealModuleCommand $*

ModuleCommandReturnValue=$?


## Skip out sharpish without doing anything if there aren't any arguments to the module command
if [[ -z "$2" ]]; then # The command source is the first argument at this point
  exit
fi


## Copy the original arguments so we can use 'shift' later without screwing everything up
declare -a OriginalArguments

# I'm a little worried about this with arguments with spaces in
i=0
for Argument; do
  OriginalArguments[$i]=$Argument 
  let i=$i+1
done


## Gather information

CurrentUser=`whoami`
CurrentHost=`hostname`
CommandSource=$1 #(almost certainly 'bash')
shift<commit_msg>Fixed hostname calls to always get the short name<commit_after>#!/bin/bash 

#############################
# A fairly basic wrapper around modulecmd to allow actions on loading or unloading a module.
#
# <NAME>, 2013


# Params to edit
PathToModuleCmd=/shared/ucl/apps/modules-3.2.10-modlog
RealModuleCommand=$PathToModuleCmd/modulecmd
ExternalLogger=$PathToModuleCmd/mysql_injector


LogMode="external"
# LogMode="file"

# Obviously if you're logging to files, you'll want to 
#   put them somewhere you can gather/access them.
# This is our Lustre file system, for example.
# Only used if LogMode = "file"
LogFilesDirectory=/scratch/scratch/.modusage


# End of params
#############################

Date=`date +%s`

## Create log file name
# For Logging Messages in files rather than using an external tool

SessionPID=$1 # This is added by our altered module shell function
TimeCode=${Date:0:6} 
# ^--- This gives a 10000 window on things being considered the same session - 
#        to let us track the same session, but also allow for PID recycling
#      It's hardly perfect, but it at least does something.
shift

UsageFile=${LogFilesDirectory}/$SessionPID.$TimeCode.`whoami`.`hostname -s`.${JOB_ID:=undefined}.${TASK_ID:=undefined}
umask 0077 # Thus files should be 0600


## Run actual module command

$RealModuleCommand $*

ModuleCommandReturnValue=$?


## Skip out sharpish without doing anything if there aren't any arguments to the module command
if [[ -z "$2" ]]; then # The command source is the first argument at this point
  exit
fi


## Copy the original arguments so we can use 'shift' later without screwing everything up
declare -a OriginalArguments

# I'm a little worried about this with arguments with spaces in
i=0
for Argument; do
  OriginalArguments[$i]=$Argument 
  let i=$i+1
done


## Gather information

CurrentUser=`whoami`
CurrentHost=`hostname -s`
CommandSource=$1 #(almost certainly 'bash')
shift
{'fraction_non_alphanumeric': 0.11767782426778242, 'fraction_numerical': 0.014644351464435146, 'mean_word_length': 4.786686838124054, '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': '6457044', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1069, 'n_words': 433}