aa
This commit is contained in:
21
CsvLoader.py
21
CsvLoader.py
@@ -7,6 +7,7 @@ import logging
|
||||
import csv
|
||||
import re
|
||||
import mariadb
|
||||
import shutil
|
||||
|
||||
from asebat.timefmt import timestamp_fmt as ts
|
||||
from asebat.timefmt import date_refmt as df
|
||||
@@ -100,7 +101,7 @@ def callback_ase(ch, method, properties, body, config): #body è di tipo byte
|
||||
sql.write_db()
|
||||
stmlst.clear()
|
||||
except:
|
||||
print("errore nell'inseriento")
|
||||
print("errore nell'inserimento")
|
||||
sys.exit(1)
|
||||
|
||||
if len(stmlst) > 0:
|
||||
@@ -109,8 +110,24 @@ def callback_ase(ch, method, properties, body, config): #body è di tipo byte
|
||||
sql.write_db()
|
||||
ch.basic_ack(delivery_tag=method.delivery_tag)
|
||||
except:
|
||||
print("errore nell'inseriento")
|
||||
print("errore nell'inserimento")
|
||||
sys.exit(1)
|
||||
newFilename = msg[6].replace("received", "loaded")
|
||||
newPath, filenameExt = os.path.split(newFilename)
|
||||
try:
|
||||
os.makedirs(newPath)
|
||||
logging.info("PID {:>5} >> path {} created.".format(
|
||||
os.getpid(), newPath))
|
||||
except FileExistsError:
|
||||
logging.info("PID {:>5} >> path {} already exists.".format(
|
||||
os.getpid(), newPath))
|
||||
try:
|
||||
shutil.move(msg[6], newFilename)
|
||||
logging.info("PID {:>5} >> {} moved into {}.".format(
|
||||
os.getpid(), filenameExt, newFilename))
|
||||
except OSError:
|
||||
logging.error("PID {:>5} >> Error to move {} into {}.".format(
|
||||
os.getpid(), filenameExt, newFilename))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user