From 8f795b1d445441daab5ffb75060a6dbf8ed0934a Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 8 Sep 2017 01:28:21 +0200 Subject: Renaming scripts so that their names make sense --- bin/build-datafiles.sh | 11 ----------- bin/build-players.sh | 4 ---- bin/build-rankings.sh | 10 ---------- bin/cezar-db-fetch.sh | 13 +++++++++++++ bin/cezar-db-import.sh | 9 +++++++++ bin/convert-cezar-ranking-csv.py | 9 --------- bin/datafiles-build.sh | 11 +++++++++++ bin/fetch-cezar-db.sh | 13 ------------- bin/generate-json.sh | 5 ----- bin/generate-statics.sh | 16 ---------------- bin/group-tools-json.sh | 5 +++++ bin/import-cezar-db.sh | 9 --------- bin/import-rankings.sh | 16 ---------------- bin/menus-build.sh | 9 +++++++++ bin/players-build.sh | 4 ++++ bin/rankings-csv-import.sh | 16 ++++++++++++++++ bin/rankings-tables-build.sh | 10 ++++++++++ bin/rankings-target-files.sh | 3 +++ bin/statics-generate.sh | 16 ++++++++++++++++ bin/target-ranking-files.sh | 3 --- bin/write-menus.sh | 9 --------- 21 files changed, 96 insertions(+), 105 deletions(-) delete mode 100755 bin/build-datafiles.sh delete mode 100755 bin/build-players.sh delete mode 100755 bin/build-rankings.sh create mode 100755 bin/cezar-db-fetch.sh create mode 100755 bin/cezar-db-import.sh delete mode 100644 bin/convert-cezar-ranking-csv.py create mode 100755 bin/datafiles-build.sh delete mode 100755 bin/fetch-cezar-db.sh delete mode 100755 bin/generate-json.sh delete mode 100755 bin/generate-statics.sh create mode 100755 bin/group-tools-json.sh delete mode 100755 bin/import-cezar-db.sh delete mode 100755 bin/import-rankings.sh create mode 100755 bin/menus-build.sh create mode 100755 bin/players-build.sh create mode 100755 bin/rankings-csv-import.sh create mode 100755 bin/rankings-tables-build.sh create mode 100755 bin/rankings-target-files.sh create mode 100755 bin/statics-generate.sh delete mode 100755 bin/target-ranking-files.sh delete mode 100755 bin/write-menus.sh (limited to 'bin') diff --git a/bin/build-datafiles.sh b/bin/build-datafiles.sh deleted file mode 100755 index 82c2e9c..0000000 --- a/bin/build-datafiles.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -CONFIG=$1 -DIR=$2 -PREV_DATE="" -cat $CONFIG | - jq -r '.[] | .date' | - while read DATE - do - python scripts/datafile.py $DATE $PREV_DATE > "$DIR/$DATE.json" - PREV_DATE=$DATE - done diff --git a/bin/build-players.sh b/bin/build-players.sh deleted file mode 100755 index e1d099d..0000000 --- a/bin/build-players.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -DIR=$1 -mkdir -p $DIR/players -python scripts/players.py $DIR/players $DIR/players/.menu.html diff --git a/bin/build-rankings.sh b/bin/build-rankings.sh deleted file mode 100755 index c51fa1d..0000000 --- a/bin/build-rankings.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -CONFIG=$1 -DIR=$2 -cat $CONFIG | - jq '.[] | .date, .url, .index, .name' | - xargs -n4 | - while read DATE URL INDEX NAME - do - python scripts/ranking.py "$NAME" $INDEX $DIR/.menu.html $DATE > $DIR/$URL - done diff --git a/bin/cezar-db-fetch.sh b/bin/cezar-db-fetch.sh new file mode 100755 index 0000000..3af7357 --- /dev/null +++ b/bin/cezar-db-fetch.sh @@ -0,0 +1,13 @@ +#!/bin/bash +PAGEDIR=`dirname $0` +DATE=`date --date='yesterday' +%Y%m%d` +OUTPUTFILE=`realpath $PAGEDIR/../data/cezar/$DATE.csv` +TMPFILE=$PAGEDIR/temp +wget http://msc.com.pl/cezar/download/baza.csv -q -O - | iconv -f windows-1250 -t utf-8 > $TMPFILE +if [ -s $TMPFILE ]; then + tail -n +2 $TMPFILE | sort > $OUTPUTFILE + echo "Downloaded Cezar CSV into $OUTPUTFILE" +else + echo 'Cezar CSV fetch failed' +fi +rm $TMPFILE diff --git a/bin/cezar-db-import.sh b/bin/cezar-db-import.sh new file mode 100755 index 0000000..4db5261 --- /dev/null +++ b/bin/cezar-db-import.sh @@ -0,0 +1,9 @@ +#!/bin/bash +DBCONFIG=($(jq -r '.[]' config/import-db.json)) +mysql -h ${DBCONFIG[2]} -P ${DBCONFIG[3]} -u ${DBCONFIG[0]} --password=${DBCONFIG[1]} -e "SET foreign_key_checks = 0; +LOAD DATA LOCAL INFILE '$1' +REPLACE +INTO TABLE players +FIELDS TERMINATED BY ';' ENCLOSED BY '\"'; +SET foreign_key_checks = 1 +" ${DBCONFIG[4]} diff --git a/bin/convert-cezar-ranking-csv.py b/bin/convert-cezar-ranking-csv.py deleted file mode 100644 index 4dcee92..0000000 --- a/bin/convert-cezar-ranking-csv.py +++ /dev/null @@ -1,9 +0,0 @@ -import csv, sys - -data = list(csv.reader(file(sys.argv[1]), delimiter=";")) - -output = csv.writer(file(sys.argv[2], 'w')) - -date = data[1][3] -for row in data[4:-1]: - output.writerow([row[0], date, row[2], row[1]]) diff --git a/bin/datafiles-build.sh b/bin/datafiles-build.sh new file mode 100755 index 0000000..5c336ff --- /dev/null +++ b/bin/datafiles-build.sh @@ -0,0 +1,11 @@ +#!/bin/bash +CONFIG=$1 +DIR=$2 +PREV_DATE="" +cat $CONFIG | + jq -r '.[] | .date' | + while read DATE + do + python scripts/datafiles-generate.py $DATE $PREV_DATE > "$DIR/$DATE.json" + PREV_DATE=$DATE + done diff --git a/bin/fetch-cezar-db.sh b/bin/fetch-cezar-db.sh deleted file mode 100755 index 3af7357..0000000 --- a/bin/fetch-cezar-db.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -PAGEDIR=`dirname $0` -DATE=`date --date='yesterday' +%Y%m%d` -OUTPUTFILE=`realpath $PAGEDIR/../data/cezar/$DATE.csv` -TMPFILE=$PAGEDIR/temp -wget http://msc.com.pl/cezar/download/baza.csv -q -O - | iconv -f windows-1250 -t utf-8 > $TMPFILE -if [ -s $TMPFILE ]; then - tail -n +2 $TMPFILE | sort > $OUTPUTFILE - echo "Downloaded Cezar CSV into $OUTPUTFILE" -else - echo 'Cezar CSV fetch failed' -fi -rm $TMPFILE diff --git a/bin/generate-json.sh b/bin/generate-json.sh deleted file mode 100755 index d856a89..0000000 --- a/bin/generate-json.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -CONFIG=$1 -OUTPUT=$2 -LAST_DATE=`cat $CONFIG | jq -r '.[] | .date' | sort | tail -n1` -python scripts/generate-json.py $LAST_DATE > $OUTPUT/_data/group-data.json diff --git a/bin/generate-statics.sh b/bin/generate-statics.sh deleted file mode 100755 index 4369aa7..0000000 --- a/bin/generate-statics.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -CONFIG=$1 -CONTENT_DIR=$2 -OUTPUT_DIR=$3 -cat $1 | - jq -r '.[] | .content, .header, .url' | - while read CONTENT_FILE - do - read HEADER - read OUTPUT_FILE - if [ -n "$CONTENT_FILE" ] - then - python scripts/static.py $CONTENT_DIR/$CONTENT_FILE "$HEADER" > $OUTPUT_DIR/$OUTPUT_FILE - python scripts/static-menu.py $OUTPUT_DIR/$OUTPUT_FILE $OUTPUT_DIR/.menu.html - fi - done diff --git a/bin/group-tools-json.sh b/bin/group-tools-json.sh new file mode 100755 index 0000000..e6f04c8 --- /dev/null +++ b/bin/group-tools-json.sh @@ -0,0 +1,5 @@ +#!/bin/bash +CONFIG=$1 +OUTPUT=$2 +LAST_DATE=`cat $CONFIG | jq -r '.[] | .date' | sort | tail -n1` +python scripts/group-tools-json-generate.py $LAST_DATE > $OUTPUT/_data/group-data.json diff --git a/bin/import-cezar-db.sh b/bin/import-cezar-db.sh deleted file mode 100755 index 4db5261..0000000 --- a/bin/import-cezar-db.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -DBCONFIG=($(jq -r '.[]' config/import-db.json)) -mysql -h ${DBCONFIG[2]} -P ${DBCONFIG[3]} -u ${DBCONFIG[0]} --password=${DBCONFIG[1]} -e "SET foreign_key_checks = 0; -LOAD DATA LOCAL INFILE '$1' -REPLACE -INTO TABLE players -FIELDS TERMINATED BY ';' ENCLOSED BY '\"'; -SET foreign_key_checks = 1 -" ${DBCONFIG[4]} diff --git a/bin/import-rankings.sh b/bin/import-rankings.sh deleted file mode 100755 index 90ce6bc..0000000 --- a/bin/import-rankings.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -DBCONFIG=($(jq -r '.[]' config/import-db.json)) -mysql -h ${DBCONFIG[2]} -P ${DBCONFIG[3]} -u ${DBCONFIG[0]} --password=${DBCONFIG[1]} -e "SET foreign_key_checks = 0; -DELETE FROM temp_rankings; -LOAD DATA LOCAL INFILE '$1' -REPLACE -INTO TABLE temp_rankings -FIELDS TERMINATED BY ','; -INSERT INTO rankings ( - SELECT pid, \`date\`, place, score, region, flags, rank, club - FROM temp_rankings - JOIN players - ON players.id = temp_rankings.pid -); -SET foreign_key_checks = 1 -" ${DBCONFIG[4]} diff --git a/bin/menus-build.sh b/bin/menus-build.sh new file mode 100755 index 0000000..0ac3a92 --- /dev/null +++ b/bin/menus-build.sh @@ -0,0 +1,9 @@ +#!/bin/bash +CONFIG_FILE=$1 +DIRECTORY=$2 +mkdir -p $DIRECTORY/players +find $DIRECTORY -type d -not -name _\* | + while read HTMLDIR + do + python scripts/menus-compile.py $CONFIG_FILE $DIRECTORY $HTMLDIR > $HTMLDIR/.menu.html + done diff --git a/bin/players-build.sh b/bin/players-build.sh new file mode 100755 index 0000000..06fdf4f --- /dev/null +++ b/bin/players-build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +DIR=$1 +mkdir -p $DIR/players +python scripts/players-compile.py $DIR/players $DIR/players/.menu.html diff --git a/bin/rankings-csv-import.sh b/bin/rankings-csv-import.sh new file mode 100755 index 0000000..90ce6bc --- /dev/null +++ b/bin/rankings-csv-import.sh @@ -0,0 +1,16 @@ +#!/bin/bash +DBCONFIG=($(jq -r '.[]' config/import-db.json)) +mysql -h ${DBCONFIG[2]} -P ${DBCONFIG[3]} -u ${DBCONFIG[0]} --password=${DBCONFIG[1]} -e "SET foreign_key_checks = 0; +DELETE FROM temp_rankings; +LOAD DATA LOCAL INFILE '$1' +REPLACE +INTO TABLE temp_rankings +FIELDS TERMINATED BY ','; +INSERT INTO rankings ( + SELECT pid, \`date\`, place, score, region, flags, rank, club + FROM temp_rankings + JOIN players + ON players.id = temp_rankings.pid +); +SET foreign_key_checks = 1 +" ${DBCONFIG[4]} diff --git a/bin/rankings-tables-build.sh b/bin/rankings-tables-build.sh new file mode 100755 index 0000000..0d85972 --- /dev/null +++ b/bin/rankings-tables-build.sh @@ -0,0 +1,10 @@ +#!/bin/bash +CONFIG=$1 +DIR=$2 +cat $CONFIG | + jq '.[] | .date, .url, .index, .name' | + xargs -n4 | + while read DATE URL INDEX NAME + do + python scripts/rankings-tables-compile.py "$NAME" $INDEX $DIR/.menu.html $DATE > $DIR/$URL + done diff --git a/bin/rankings-target-files.sh b/bin/rankings-target-files.sh new file mode 100755 index 0000000..001834f --- /dev/null +++ b/bin/rankings-target-files.sh @@ -0,0 +1,3 @@ +#!/bin/bash +CONFIG=$1 +jq -jr '.[] | .url + " "' $CONFIG diff --git a/bin/statics-generate.sh b/bin/statics-generate.sh new file mode 100755 index 0000000..9c2fa92 --- /dev/null +++ b/bin/statics-generate.sh @@ -0,0 +1,16 @@ +#!/bin/bash +CONFIG=$1 +CONTENT_DIR=$2 +OUTPUT_DIR=$3 +cat $1 | + jq -r '.[] | .content, .header, .url' | + while read CONTENT_FILE + do + read HEADER + read OUTPUT_FILE + if [ -n "$CONTENT_FILE" ] + then + python scripts/statics-compile.py $CONTENT_DIR/$CONTENT_FILE "$HEADER" > $OUTPUT_DIR/$OUTPUT_FILE + python scripts/menus-write.py $OUTPUT_DIR/$OUTPUT_FILE $OUTPUT_DIR/.menu.html + fi + done diff --git a/bin/target-ranking-files.sh b/bin/target-ranking-files.sh deleted file mode 100755 index 001834f..0000000 --- a/bin/target-ranking-files.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -CONFIG=$1 -jq -jr '.[] | .url + " "' $CONFIG diff --git a/bin/write-menus.sh b/bin/write-menus.sh deleted file mode 100755 index 500db52..0000000 --- a/bin/write-menus.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -CONFIG_FILE=$1 -DIRECTORY=$2 -mkdir -p $DIRECTORY/players -find $DIRECTORY -type d -not -name _\* | - while read HTMLDIR - do - python scripts/generate-static-menu.py $CONFIG_FILE $DIRECTORY $HTMLDIR > $HTMLDIR/.menu.html - done -- cgit v1.2.3