Skip to content

Commit

Permalink
Docker Changes,Ghostscript Installation Command
Browse files Browse the repository at this point in the history
  • Loading branch information
N3XT14 committed Jun 18, 2022
1 parent 8e264b0 commit b41691f
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 116 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

RUN apt-get update
RUN apt-get install -y ghostscript
RUN apt-get install ffmpeg libsm6 libxext6 -y

# gunicorn
Expand Down
53 changes: 22 additions & 31 deletions apps/home/extractTrxData.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from cProfile import label
import enum
import camelot
import re
from pathlib import Path
from datetime import date, datetime as dt
from itertools import groupby
import pandas as pd
import json
import sys
import traceback

f = open ('apps/static/assets/json/banks.json', "r")
bankStructure = json.loads(f.read())
Expand Down Expand Up @@ -173,9 +173,26 @@ def extractData(fileList, bankName):
filename = Path.home() / file[0]
filename = str(filename).replace("\\","/")

# tables2=camelot.read_pdf("D:/ME/Projects/Python/BankStatement.pdf", flavor=bankStructure[bankName]["type"], pages='all')
tables2=camelot.read_pdf(filename, flavor=bankStructure[bankName]["type"], pages='all')
#print(tables2)
try :
tables2=camelot.read_pdf(filename, flavor=bankStructure[bankName]["type"], pages='all')
except BaseException as ex:
# Get current system exception
print('Entered except')
ex_type, ex_value, ex_traceback = sys.exc_info()

# Extract unformatter stack traces as tuples
trace_back = traceback.extract_tb(ex_traceback)

# Format stacktrace
stack_trace = list()

for trace in trace_back:
stack_trace.append("File : %s , Line : %d, Func.Name : %s, Message : %s" % (trace[0], trace[1], trace[2], trace[3]))

print("Exception type : %s " % ex_type.__name__)
print("Exception message : %s" %ex_value)
print("Stack trace : %s" %stack_trace)
print(tables2)
dateMap = {
"Total_Amount": 0,
"Total Transaction": 0,
Expand All @@ -197,29 +214,3 @@ def extractData(fileList, bankName):
resObj = createResponseObj(dateMap)

return resObj
# extractData(['BankStatement.pdf'], 'kotak')
# filename = Path("D:/ME/Projects/Python/BankStatement.pdf").absolute()
# print(filename)
# filename = str(filename).replace("\\","/")
# tables2=camelot.read_pdf("../../BankStatement.pdf", flavor='stream', pages='1')
# tables2=camelot.read_pdf("D:/ME/Projects/Python/BankStatement.pdf", flavor='stream', pages='1')
# tables2=camelot.read_pdf(filename, flavor='stream', pages='1')
# tables1=camelot.read_pdf(
# '../foo.pdf',
# password=None,
# flavor='lattice',
# suppress_stdout=False,
# layout_kwargs={}
# )
# print(tables2[1].df)
# print(type(tables2[0]))
# print(tables2[1].df.head(2).to_dict())
# print(tables2[1].df.iloc[:2].to_dict())
# # for table in tables1:
# # #print(table.parsing_report)
# # reportObj = table.parsing_report
# # #print(reportObj['whitespace'])
# # if reportObj and reportObj["whitespace"] < 50:
# # print(table.df.iloc[1].to_list())
# print(tables1[0])
# print(tables1[0].parsing_report)
10 changes: 4 additions & 6 deletions apps/home/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def handleFile(request):
if file and allowed_file(file.filename):
fileList.append([secure_filename(file.filename), file])
else:
return "Extension Not Supported", 422
return "Extension Not Supported", 422
response = extractData(fileList, bankname)
return fileList, 200, response
return
Expand All @@ -42,22 +42,20 @@ def index():
def route_template(template):

try:

if not template.endswith('.html'):
template += '.html'

segment = get_segment(request)
if segment.endswith('.html'):
pagename = segment.replace('.html','')
pagename = 'Dashboard' if pagename == 'index' else pagename.capitalize()
print(pagename)

global message

if message == {} or message is None or request.method == 'POST':
message = handleFile(request)

print('Url',message)
message = handleFile(request)

return render_template("home/" + template, segment=segment, pagename=pagename, message=message)

except TemplateNotFound:
Expand Down
2 changes: 1 addition & 1 deletion apps/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% endif %}
{% endwith %}
</p>
<form action="http://127.0.0.1:5000/index.html" method = "POST"
<form action="http://127.0.0.1:85/index.html" method = "POST"
enctype = "multipart/form-data">
<label for="files" class="btn btn-outline-primary btn-md mb-0 w-100">No files read yet!! Read Now? Click Me</label>
<input type="file" name="files[]" id='files' hidden />
Expand Down
2 changes: 1 addition & 1 deletion apps/templates/includes/fixed-plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h5 class="mt-3 mb-0">My Accountant</h5>
<hr class="horizontal dark my-1">
<p>Want to visualize your spendings with another statement.<br /> Load it now!!</p>
<div class="card-body pt-sm-3 pt-0">
<form action="http://127.0.0.1:5000/index.html" method = "POST"
<form action="http://127.0.0.1:85/index.html" method = "POST"
enctype = "multipart/form-data">
<label for="files" class="btn btn-outline-primary btn-md mb-0">No files read yet!! Read Now? Click Me</label>
<input type="file" name="files[]" id='files' hidden />
Expand Down
19 changes: 19 additions & 0 deletions docker-compose-with-reloading.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: '3'

services:

financial_dashboard:
container_name: financial_dashboard
volumes:
- ".:/app"

live-reloader:
image: apogiatzis/livereloading
container_name: livereloader
privileged: true
environment:
- RELOAD_DELAY=1.5 # seconds
- RELOAD_CONTAINER=financial_dashboard
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- ".:/app"
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
container_name: financial_dashboard
restart: always
env_file: .env
build: .
build: .
nginx:
container_name: nginx
restart: always
Expand Down
77 changes: 1 addition & 76 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,81 +8,6 @@ cryptography==36.0.2
et-xmlfile==1.1.0
Flask==2.1.2
ghostscript==0.7
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
numpy==1.22.3
opencv-python==4.5.5.64
openpyxl==3.0.9
pandas==1.4.2
pdfminer.six==20220506
pycparser==2.21
PyPDF2==1.27.12
python-dateutil==2.8.2
pytz==2022.1
six==1.16.0
Werkzeug==2.1.2
camelot-py==0.9.0
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.12
click==8.1.3
colorama==0.4.4
cryptography==36.0.2
et-xmlfile==1.1.0
Flask==2.1.2
ghostscript==0.7
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
numpy==1.22.3
opencv-python==4.5.5.64
openpyxl==3.0.9
pandas==1.4.2
pdfminer.six==20220506
pycparser==2.21
PyPDF2==1.27.12
python-dateutil==2.8.2
pytz==2022.1
six==1.16.0
Werkzeug==2.1.2
camelot-py==0.9.0
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.12
click==8.1.3
colorama==0.4.4
cryptography==36.0.2
et-xmlfile==1.1.0
Flask==2.1.2
ghostscript==0.7
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.1
numpy==1.22.3
opencv-contrib-python==4.5.5.64
opencv-python==4.5.5.64
openpyxl==3.0.9
pandas==1.4.2
pdfminer.six==20220506
pycparser==2.21
PyPDF2==1.27.12
python-dateutil==2.8.2
pytz==2022.1
six==1.16.0
Werkzeug==2.1.2
camelot-py==0.9.0
cffi==1.15.0
chardet==4.0.0
charset-normalizer==2.0.12
click==8.1.3
colorama==0.4.4
cryptography==36.0.2
et-xmlfile==1.1.0
Flask==2.1.2
ghostscript==0.7
gunicorn==20.1.0
itsdangerous==2.1.2
Jinja2==3.1.2
Expand All @@ -99,4 +24,4 @@ python-dateutil==2.8.2
python-dotenv==0.20.0
pytz==2022.1
six==1.16.0
Werkzeug==2.1.2
Werkzeug==2.1.2

0 comments on commit b41691f

Please sign in to comment.