<commit_before>import socket, os
from subprocess import Popen, PIPE
from Websheet import record
import json

# we already checked for this error in php land
try:
    config_jo = json.loads(open('config.json').read())
except:
    config_jo = {} # empty dict

# if you are using safeexec, securely running java should be something like this:
def compute_java_prefix():
    jail = config_jo["java_jail-abspath"]
    safeexec = config_jo["safeexec-executable-abspath"]    

    java = "/java/bin/java -cp .:javax.json-1.0.jar -Xmx128M " # java within jail, using default java_jail config
    safeexec_args = " --chroot_dir "+ jail +" --exec_dir /cp --env_vars '' --nproc 50 --mem 2000000 --nfile 30 --gid 1001 --clock 5 --exec "
    return safeexec + safeexec_args + java

# at princeton, they use "sandbox" instead
if socket.gethostname().endswith("princeton.edu"):
    def compute_java_prefix():
        java = "/usr/bin/java -cp .:/n/fs/htdocs/cos126/java_jail/cp:/n/fs/htdocs/cos126/java_jail/cp/javax.json-1.0.jar -Xmx512M "<commit_msg>allow frontend loading without config<commit_after>import socket, os
from subprocess import Popen, PIPE
from Websheet import record
import json

# we already checked for this error in php land
try:
    config_jo = json.loads(open('config.json').read())
except:
    config_jo = {}

# if you are using safeexec, securely running java should be something like this:
def compute_java_prefix():
    if (config_jo == {}): return "error: config.json doesn't exist"
    jail = config_jo["java_jail-abspath"]
    safeexec = config_jo["safeexec-executable-abspath"]    

    java = "/java/bin/java -cp .:javax.json-1.0.jar -Xmx128M " # java within jail, using default java_jail config
    safeexec_args = " --chroot_dir "+ jail +" --exec_dir /cp --env_vars '' --nproc 50 --mem 2000000 --nfile 30 --gid 1001 --clock 5 --exec "
    return safeexec + safeexec_args + java

# at princeton, they use "sandbox" instead
if socket.gethostname().endswith("princeton.edu"):
    def compute_java_prefix():
        java = "/usr/bin/java -cp .:/n/fs/htdocs/cos126/java_jail/cp:/n/fs/htdocs/cos126/java_jail/cp/javax.json-1.0.jar -Xmx512M "
{'fraction_non_alphanumeric': 0.12958662331630283, 'fraction_numerical': 0.029725963771481654, 'mean_word_length': 3.5829787234042554, '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': '5337654', 'n_tokens_mistral': 776, 'n_tokens_neox': 728, 'n_words': 203}