Commit 4f631de4 authored by Luiza Wille's avatar Luiza Wille

Issue #58: Fixed some errors pointed by Cris

Signed-off-by: Luiza Wille's avatarLuiza Wille <lmwc14@inf.ufpr.br>
parent 00c96f1f
indexName=$1
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <index-name>"
exit
fi
indexName=$1
curl -XDELETE "localhost:9200/$indexName?pretty"
# Input: Kibana/ElasticSearch's user and password and two index names: the script will rename the index with the first name to the second one.
userAndPasswd=$1
sourceIndex=$2
destIndex=$3
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <user:password> <old-index> <new-index>"
echo "Example: $0 myuser:mypass ufpr-csv-2016-11 ufpr-servidores-2016-11"
exit
fi
userAndPasswd=$1
sourceIndex=$2
destIndex=$3
source ./config.sh
# Copy old index to new index...
......
......@@ -10,6 +10,10 @@ import sys, csv, json, math, subprocess
from pathlib import Path
from subprocess import call
if len(sys.argv) != 10:
print("Usage: " + sys.argv[0] + " <year (2016)> <month (01)> <day (31)> <index> <host> <entity> <username> <password> <path>")
sys.exit()
year = sys.argv[1]
month = sys.argv[2]
day = sys.argv[3]
......@@ -20,10 +24,6 @@ username = sys.argv[7]
passwd = sys.argv[8]
path = sys.argv[9]
if len(sys.argv) != 10:
print("Usage: " + sys.argv[0] + " <year (2016)> <month (01)> <day (31)> <index> <host> <entity> <username> <password> <path>")
sys.exit()
# Generate JSON CNPJ merge config file:
data = {
"path": path
......
......@@ -13,21 +13,23 @@
# Output: The commands/scripts outputs.
function inputError(){
echo "Var ${1} is unset. Set in file '${2}'."
varName=$1
file=$2
echo "Var ${varName} is unset. Set in file '${file}'."
return 0
}
year=$1
month=$2
user=$3
passwd=$4
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <year> <month> <user> <password>"
echo "Example: $0 2016 12 myuser mypass"
exit
fi
year=$1
month=$2
user=$3
passwd=$4
source ./config.sh
# Check if all variables in config file are set:
......@@ -86,10 +88,10 @@
rm $path/${year}${month}_Favorecidos.zip
# Remove null bytes
cat $path/${year}${month}_CNPJ.csv | tr -d '\000' > $path/${year}{$month}_CNPJ_NotNull.csv
cat $path/${year}${month}_NaturezaJuridica.csv | tr -d '\000' > $path/${year}{$month}_NatJur_NotNull.csv
mv $path/${year}{$month}_CNPJ_NotNull.csv $path/${year}${month}_CNPJ.csv
mv $path/${year}{$month}_NatJur_NotNull.csv $path/${year}${month}_NaturezaJuridica.csv
cat $path/${year}${month}_CNPJ.csv | tr -d '\000' > $path/${year}${month}_CNPJ_NotNull.csv
cat $path/${year}${month}_NaturezaJuridica.csv | tr -d '\000' > $path/${year}${month}_NatJur_NotNull.csv
mv $path/${year}${month}_CNPJ_NotNull.csv $path/${year}${month}_CNPJ.csv
mv $path/${year}${month}_NatJur_NotNull.csv $path/${year}${month}_NaturezaJuridica.csv
for key in "${!filter[@]}"
do
......
......@@ -46,12 +46,13 @@ def getDataWithEmptyRow(columns, row):
newRow.append('')
return newRow
configFile = sys.argv[1]
if len(sys.argv) != 4:
print("Usage: " + sys.argv[0] + " <config.json> <filter> <columnId>")
sys.exit()
configFile = sys.argv[1]
with open(configFile) as f:
params = json.load(f)
......
#!/bin/bash
path=$1
date=$2
filter=$3
column=$4
if [ "$#" -ne 4 ]; then
echo "Usage $0 <path> <date> <filter> <column-name>"
echo "Example: $0 ./tmp_201612 201612 MEC 2"
exit
fi
path=$1
date=$2
filter=$3
column=$4
dateWithoutHyphen=${date//-}
input="${path}/${dateWithoutHyphen}_GastosDiretos.csv"
......
......@@ -7,12 +7,6 @@
# - Filter: An array of n values, that will create n indexes in ElasticSearch, each one filtering data from Portal Transparencia using its corresponding string. Ex: "UNIVERSIDADE FEDERAL DO PARANA"
# - University: An array of n values, with n being the same n as Filter's array. This array should contain the initials from Universities declared in Filter array, in the same order.
year=$1
month=$2
user=$3
passwd=$4
insertions=$5
if [[ "$#" -ne 5 || "$year" == "-help" || "$year" == "--help" ]]; then
echo " Usage: $0 <year> <month> <user> <password> <insertions>"
echo " Insertions must be one between: expenses, travel_allowances, workers, ministry_of_health, all"
......@@ -20,6 +14,12 @@ if [[ "$#" -ne 5 || "$year" == "-help" || "$year" == "--help" ]]; then
exit
fi
year=$1
month=$2
user=$3
passwd=$4
insertions=$5
if [[ "$insertions" == "all" || "$insertions" == "expenses" ]]; then
# First, insert Expenses data.
echo "Inserting Expenses from ${year}-${month}..."
......
......@@ -10,6 +10,10 @@ import sys, csv, json, math, subprocess
from pathlib import Path
from subprocess import call
if len(sys.argv) != 10:
print("Usage: " + sys.argv[0] + " <year (2016)> <month (01)> <day (31)> <index> <host> <entity> <username> <password> <path>")
sys.exit()
year = sys.argv[1]
month = sys.argv[2]
day = sys.argv[3]
......@@ -20,10 +24,6 @@ username = sys.argv[7]
passwd = sys.argv[8]
path = sys.argv[9]
if len(sys.argv) != 10:
print("Usage: " + sys.argv[0] + " <year (2016)> <month (01)> <day (31)> <index> <host> <entity> <username> <password> <path>")
sys.exit()
with open('logstash_config.example') as infile:
example = infile.read()
......
......@@ -12,21 +12,23 @@
# Output: The commands/scripts outputs.
function inputError(){
echo "Var ${year} is unset. Set in file '${month}'."
varName=$1
file=$2
echo "Var ${varName} is unset. Set in file '${file}'."
return 0
}
year=$1
month=$2
user=$3
passwd=$4
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <year> <month> <user> <password>"
echo "Example: $0 2016 12 myuser mypass"
exit
fi
year=$1
month=$2
user=$3
passwd=$4
source ./config.sh
# Check if all variables in config file are set:
......
#!/bin/bash
path=$1
date=$2
filter=$3
column=$4
if [ "$#" -ne 4 ]; then
echo "Usage $0 <path> <date> <filter> <column-name>"
echo "Example: $0 ./tmp_201612 201612 MEC 2"
exit
fi
path=$1
date=$2
filter=$3
column=$4
dateWithoutHyphen=${date//-}
input="${path}/${dateWithoutHyphen}_Diarias.csv"
......
......@@ -12,6 +12,10 @@ import sys, csv, json, math, subprocess
from pathlib import Path
from subprocess import call
if len(sys.argv) != 10:
print("Usage: " + sys.argv[0] + " <year (2016)> <month (01)> <day (31)> <index> <host> <entity> <username> <password> <path>")
sys.exit()
year = sys.argv[1]
month = sys.argv[2]
day = sys.argv[3]
......@@ -22,10 +26,6 @@ username = sys.argv[7]
passwd = sys.argv[8]
path = sys.argv[9]
if len(sys.argv) != 10:
print("Usage: " + sys.argv[0] + " <year (2016)> <month (01)> <day (31)> <index> <host> <entity> <username> <password> <path>")
sys.exit()
data = {
"path": path
, "date": year + month + day
......
......@@ -16,21 +16,23 @@
# WARNING: We get the day from the CSV file by using cut in characters 7 and 8. This means we assume they will write something like 01 as day 1. If they change it to 1, this script will not work!
function inputError(){
echo "Var ${year} is unset. Set in file '${month}'."
varName=$1
file=$2
echo "Var ${varName} is unset. Set in file '${file}'."
return 0
}
year=$1
month=$2
user=$3
passwd=$4
if [ "$#" -ne 4 ]; then
echo "Usage: $0 <year> <month> <user> <password>"
echo "Example: $0 2016 12 myuser mypassword"
exit
fi
year=$1
month=$2
user=$3
passwd=$4
source ./config.sh
configFile='scripts/workers/config.sh'
if [ -z "${index}" ]; then
......
......@@ -43,14 +43,14 @@ def getDataWithEmptyRow(columns, row):
newRow.append('')
return newRow
configFile = sys.argv[1]
filterReport = sys.argv[2]
columnId = sys.argv[3]
if len(sys.argv) != 4:
print("Usage: " + sys.argv[0] + " <config.json> <filter> <columnId>")
sys.exit()
configFile = sys.argv[1]
filterReport = sys.argv[2]
columnId = sys.argv[3]
with open(configFile) as f:
params = json.load(f)
......
#!/bin/bash
path=$1
date=$2
filter=$3
column=$4
if [ "$#" -ne 4 ]; then
echo "Usage $0 <path> <date> <filter> <column-name>"
echo "Example: $0 ./tmp_201612 201612 MEC 2"
exit
fi
path=$1
date=$2
filter=$3
column=$4
input="${path}/${date}_Cadastro.csv"
output="${path}/${date}_Cadastro_Unique.csv"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment