Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
payment-report
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit e6979b69
authored
Aug 20, 2022
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Bug fixed log2db saat Postgres offline
1 parent
4029b12f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
payment_report/scripts/common.py
payment_report/scripts/log2db.py
payment_report/scripts/pbb.py
payment_report/scripts/common.py
View file @
e6979b6
...
...
@@ -44,7 +44,8 @@ BIT_18_NAMES = {
'6014'
:
'INTERNETBANKING'
,
'6015'
:
'KIOSK'
,
'6016'
:
'AUTODEBET'
,
'6017'
:
'MOBILBANKING'
}
'6017'
:
'MOBILBANKING'
,
'7012'
:
'PTPOS'
}
# Bit 41, 42, dan 43
BIT_PROFILE_NAMES
=
{
...
...
@@ -64,7 +65,7 @@ BIT_PROFILE_NAMES = {
'BLIBLI'
:
'BLIBLI'
,
'ARTPAY'
:
'ARTPAY'
}
BANK_NAMES
=
{
'700'
:
'PT
POS'
}
BANK_NAMES
=
{
'700'
:
'PTPOS'
}
my_registry
=
dict
()
...
...
payment_report/scripts/log2db.py
View file @
e6979b6
...
...
@@ -11,7 +11,10 @@ from watchdog.observers import Observer
from
watchdog.events
import
FileSystemEventHandler
from
sqlalchemy
import
create_engine
from
sqlalchemy.orm
import
sessionmaker
from
sqlalchemy.exc
import
IntegrityError
from
sqlalchemy.exc
import
(
IntegrityError
,
OperationalError
,
)
from
..log_models
import
LogFile
from
.tools
import
BacaFile
...
...
@@ -50,13 +53,21 @@ def read_log(log_file, db_url, tail_mode=True):
return
print
([
line
])
line_id
=
sha256
(
line
.
encode
(
'utf-8'
))
.
hexdigest
()
row
=
LogFile
(
line_id
=
line_id
,
line
=
line
)
try
:
db_session
.
add
(
row
)
db_session
.
flush
()
db_session
.
commit
()
except
IntegrityError
:
db_session
.
rollback
()
while
True
:
row
=
LogFile
(
line_id
=
line_id
,
line
=
line
)
try
:
db_session
.
add
(
row
)
db_session
.
flush
()
db_session
.
commit
()
return
except
IntegrityError
:
db_session
.
rollback
()
return
except
OperationalError
as
e
:
db_session
.
rollback
()
print
(
e
)
print
(
'Tunggu, mungkin sedang maintenance ...'
)
sleep
(
10
)
engine
=
create_engine
(
db_url
)
factory
=
sessionmaker
(
bind
=
engine
)
...
...
payment_report/scripts/pbb.py
View file @
e6979b6
...
...
@@ -119,6 +119,9 @@ class App(BaseApp):
self
.
Sppt
=
self
.
models
.
Sppt
self
.
base_q_sppt
=
self
.
prod_session
.
query
(
self
.
Sppt
)
self
.
nip_pospbb
=
self
.
conf
.
get
(
'nip_pospbb'
)
self
.
set_other_db
()
def
set_other_db
(
self
):
if
'h2h_db_url'
in
self
.
conf
:
factory
=
self
.
get_factory
(
'h2h_db_url'
)
self
.
h2h_session
=
factory
()
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment