<commit_before>#!/usr/bin/env bash

### Setup a Marlin zone to render Minecraft maps


#set -x trace


OS=$(uname -s)
MINECRAFT_VERSION="1.7.2"

echo $OS
case $(uname -s) in
  "Darwin" )
    echo "OS X"
    pip install numpy
    DEST="./minecraft/versions/${MINECRAFT_VERSION}"
    ;;
  "SunOS" )
    echo "Solaris";
    DEST="./minecraft/versions/${MINECRAFT_VERSION}"
    if [ -z "$MANTA_USER" ]; then
      # Not on Manta
      pkgin -y install numpy
    fi
    ;;
  * )
    echo "Unknown OS"
    exit 1
    ;;
esac

if [ ! -d "$DEST" ]; then
  wget --no-check-certificate https://s3.amazonaws.com/Minecraft.Download/versions/${MINECRAFT_VERSION}/${MINECRAFT_VERSION}.jar -P $DEST
fi

git clone git://github.com/overviewer/Minecraft-Overviewer.git overviewer

cd overviewer

# Python Image Tools
#
# get PIL (may already exist in OS and Manta)
if [ ! -d "`pwd`/Imaging-1.1.7/libImaging" ]; then
  /usr/bin/curl -o imaging.tgz http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
  tar xzf imaging.tgz
  rm imaging.tgz
fi
export PIL_INCLUDE_DIR="`pwd`/Imaging-1.1.7/libImaging"

# start with a clean place to work
python ./setup.py clean > /dev/null

# build MCO
python ./setup.py build #> /dev/null

cd ..

# Create config.py
cat > ./minecraft/cfg.py <<EOCONFIG
worlds['world1'] = './minecraft/worlds/world1/world'
outputdir = "./minecraft/render/world1"
# Try "smooth_lighting" over "lighting" for even better looking maps!
rendermode = "smooth_lighting"
texturepath = "./minecraft/versions/${MINECRAFT_VERSION}/${MINECRAFT_VERSION}.jar"
renders["render1"] = {
  'world': 'world1',
  'title': 'The world',
}
EOCONFIG

cat > ./render.sh <<EOF
mkdir -p ./minecraft/worlds/world1
mkdir -p ./minecraft/render/world1
tar xzf \$MANTA_INPUT_FILE --directory ./minecraft/worlds/world1
ls -l ./minecraft/worlds/world1
./overviewer/overviewer.py --config=./minecraft/cfg.py

# TODO:DM
# output path could be defined in our metadata inside game data
OUTPUT_PATH="/$MANTA_USER/public/minecraft/filip/map/view"

./mputr ./minecraft/render/world1 "\${OUTPUT_PATH}"<commit_msg>TODO: upload<commit_after>#!/usr/bin/env bash

### Setup a Marlin zone to render Minecraft maps


#set -x trace


OS=$(uname -s)
MINECRAFT_VERSION="1.7.2"

echo $OS
case $(uname -s) in
  "Darwin" )
    echo "OS X"
    pip install numpy
    DEST="./minecraft/versions/${MINECRAFT_VERSION}"
    ;;
  "SunOS" )
    echo "Solaris";
    DEST="./minecraft/versions/${MINECRAFT_VERSION}"
    if [ -z "$MANTA_USER" ]; then
      # Not on Manta
      pkgin -y install numpy
    fi
    ;;
  * )
    echo "Unknown OS"
    exit 1
    ;;
esac

if [ ! -d "$DEST" ]; then
  wget --no-check-certificate https://s3.amazonaws.com/Minecraft.Download/versions/${MINECRAFT_VERSION}/${MINECRAFT_VERSION}.jar -P $DEST
fi

git clone git://github.com/overviewer/Minecraft-Overviewer.git overviewer

cd overviewer

# Python Image Tools
#
# get PIL (may already exist in OS and Manta)
if [ ! -d "`pwd`/Imaging-1.1.7/libImaging" ]; then
  /usr/bin/curl -o imaging.tgz http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
  tar xzf imaging.tgz
  rm imaging.tgz
fi
export PIL_INCLUDE_DIR="`pwd`/Imaging-1.1.7/libImaging"

# start with a clean place to work
python ./setup.py clean > /dev/null

# build MCO
python ./setup.py build #> /dev/null

cd ..

# Create config.py
cat > ./minecraft/cfg.py <<EOCONFIG
worlds['world1'] = './minecraft/worlds/world1/world'
outputdir = "./minecraft/render/world1"
# Try "smooth_lighting" over "lighting" for even better looking maps!
rendermode = "smooth_lighting"
texturepath = "./minecraft/versions/${MINECRAFT_VERSION}/${MINECRAFT_VERSION}.jar"
renders["render1"] = {
  'world': 'world1',
  'title': 'The world',
}
EOCONFIG

cat > ./render.sh <<EOF
mkdir -p ./minecraft/worlds/world1
mkdir -p ./minecraft/render/world1
tar xzf \$MANTA_INPUT_FILE --directory ./minecraft/worlds/world1
ls -l ./minecraft/worlds/world1
./overviewer/overviewer.py --config=./minecraft/cfg.py

# TODO:DM
# output path could be defined in our metadata inside game data
# dirname dirname MANTA_INPUT_FILE
OUTPUT_PATH="/$MANTA_USER/public/minecraft/filip/map/view"

./mputr ./minecraft/render/world1 "\${OUTPUT_PATH}"
{'fraction_non_alphanumeric': 0.15299760191846523, 'fraction_numerical': 0.011510791366906475, 'mean_word_length': 3.5043196544276456, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '782314', 'n_tokens_mistral': 1591, 'n_tokens_neox': 1566, 'n_words': 359}