-
Notifications
You must be signed in to change notification settings - Fork 0
/
budgets.sh
executable file
·82 lines (70 loc) · 2.11 KB
/
budgets.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# Navigate to the project directory
cd /home/emanjarrez/code/python/budgets-visualization
source myenv/bin/activate
# Parse arguments
UPDATE=false
RESET=false
ACCUMULATE=false
MONTH=$(date +%m) # Default to current month
YEAR=$(date +%Y) # Default to current year
# Check if any process named "panel" is listening on port 5006
if sudo lsof -i :5006 | grep -q 'panel'; then
echo "Process 'panel' is running on port 5006. Killing the process..."
# Get the PID of the process named "panel" listening on port 5006
PIDS=$(sudo lsof -t -i :5006 | xargs)
# Kill the process
for PID in $PIDS; do
sudo kill -9 $PID
echo "Killed process with PID $PID"
done
else
echo "No process named 'panel' is running on port 5006."
fi
for arg in "$@"
do
case $arg in
-u|--update)
UPDATE=true
shift # Remove --update from processing
;;
-r|--reset)
RESET=true
shift # Remove --reset from processing
;;
-a|--acc)
ACCUMULATE=true
shift # Remove --acc from processing
;;
-m=*|--month=*)
MONTH="${arg#*=}"
shift # Remove --month= from processing
;;
-y=*|--year=*)
YEAR="${arg#*=}"
shift # Remove --year= from processing
;;
esac
done
if [ "$RESET" = true ] ; then
echo "Deleting sqlite database"
rm -f db/database.db
echo "Recreating sqlite database from schema.sql"
sqlite3 db/database.db < schema.sql
fi
# Activate the Python virtual environment
source ./myenv/bin/activate
# If update flag is set, run the Python import scripts
if [ "$UPDATE" = true ] || [ "$RESET" = true ] ; then
python import_amex.py
python import_bbva.py
python import_bbva_debit.py
fi
sqlite3 db/database.db < db/modifications.sql
if [ "$ACCUMULATE" = true ] ; then
# Run the accumulate_budget.py script with the specified year and month
python accumulate_budget.py --year "$YEAR" --month "$MONTH"
fi
# Convert the Jupyter notebook to a Python script and execute it
jupyter nbconvert --to script Visualize.ipynb
panel serve Visualize.py &