Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
scrapper-portabilidad
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Javier
scrapper-portabilidad
Commits
c3aab81c
Commit
c3aab81c
authored
Jul 04, 2022
by
Javier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separación de DB
parent
6507ee51
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
6 deletions
+62
-6
a2billing.py
a2billing/a2billing.py
+1
-1
db.py
mbilling/db.py
+26
-0
exceptions.py
mbilling/exceptions.py
+35
-5
No files found.
a2billing/a2billing.py
View file @
c3aab81c
...
@@ -79,4 +79,4 @@ def account_data(callerid: str = None, account : str = None) -> dict:
...
@@ -79,4 +79,4 @@ def account_data(callerid: str = None, account : str = None) -> dict:
return
dict
(
zip
(
headers
,
data
+
get_dids_account
(
data
[
0
])))
if
data
else
None
return
dict
(
zip
(
headers
,
data
+
get_dids_account
(
data
[
0
])))
if
data
else
None
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
print
(
account_data
(
'9563
64709
'
))
print
(
account_data
(
'9563
87046
'
))
mbilling/db.py
0 → 100644
View file @
c3aab81c
from
sqlalchemy
import
create_engine
from
sqlalchemy.orm
import
sessionmaker
import
pathlib
import
re
from
dotenv
import
dotenv_values
from
sqlalchemy.ext.automap
import
automap_base
# CONFIGURACIÓN
# Path de MBILLING
mbapi_path
=
pathlib
.
Path
(
pathlib
.
Path
()
.
resolve
(),
'mbilling'
)
# Petición Correcta
succesful
=
re
.
compile
(
r'^\[20\d\]'
)
# Carga de Variables ENV
values
=
dotenv_values
(
pathlib
.
Path
(
mbapi_path
,
'.env'
))
# Conexión a Base de Datos
Base
=
automap_base
()
engine
=
create_engine
(
f
"mariadb+pymysql://{values['DB_USER']}:{values['DB_PASSWORD']}@{values['DB_HOST']}/{values['DB_NAME']}?charset=utf8mb4"
)
Base
.
prepare
(
engine
,
reflect
=
True
)
Session
=
sessionmaker
(
bind
=
engine
)
session
=
Session
()
mbilling/exceptions.py
View file @
c3aab81c
class
AccountExistsError
(
Exception
):
class
AccountExistsError
(
Exception
):
pass
pass
class
SipRegisteredError
(
Exception
):
class
SipRegisteredError
(
Exception
):
pass
pass
class
UserNotFound
(
Exception
):
pass
class
DidNotFound
(
Exception
):
class
NotFound
(
Exception
):
pass
\ No newline at end of file
def
__init__
(
self
,
message
:
str
=
None
)
->
None
:
if
not
message
:
message
=
'No se ha localiado ningún elemento con la referencia indicada.'
super
()
.
__init__
(
message
=
message
)
class
SipNotFound
(
NotFound
):
def
__init__
(
self
,
message
:
str
=
None
)
->
None
:
if
not
message
:
message
=
'No existe ninguna cuenta SIP con el Caller ID indicado.'
super
()
.
__init__
(
message
=
message
)
class
UserNotFound
(
NotFound
):
def
__init__
(
self
,
message
:
str
=
None
)
->
None
:
if
not
message
:
message
=
'No existe ninguna cuenta de facturación con el número indicado.'
super
()
.
__init__
(
message
=
message
)
class
DidNotFound
(
NotFound
):
def
__init__
(
self
,
message
:
str
=
None
)
->
None
:
if
not
message
:
message
=
'No existe ninguna cuenta DID con el Caller ID indicado.'
super
()
.
__init__
(
message
=
message
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment