param rabbit
This commit is contained in:
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
// Usare IntelliSense per informazioni sui possibili attributi.
|
||||
// Al passaggio del mouse vengono visualizzate le descrizioni degli attributi esistenti.
|
||||
// Per altre informazioni, visitare: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: File corrente",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"program": "${file}",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -72,13 +72,15 @@ class mq:
|
||||
|
||||
def write(self, msg, cfg):
|
||||
try:
|
||||
props = pika.BasicProperties(
|
||||
delivery_mode=2,
|
||||
content_encoding='utf-8',
|
||||
timestamp=msg["timestamp"],)
|
||||
self.channel.basic_publish(
|
||||
exchange="",
|
||||
routing_key=cfg.csv_queue,
|
||||
body=msg,
|
||||
properties=pika.BasicProperties(
|
||||
delivery_mode=2, # make message persistent
|
||||
),
|
||||
body=msg["payload"],
|
||||
properties=props
|
||||
)
|
||||
logging.info(
|
||||
"Write message {} in queue".format(msg))
|
||||
@@ -133,15 +135,6 @@ class ASEHandler(FTPHandler):
|
||||
{'SITE LSTU': dict(perm='M', auth=True, arg=None,
|
||||
help='Syntax: SITE <SP> LSTU (list virtual users).')}
|
||||
)
|
||||
self.msgid = 0
|
||||
self.msgdt = datetime.now().date()
|
||||
|
||||
def increment_msgid(self):
|
||||
if self.msgdt == datetime.utcnow().date():
|
||||
self.msgid += 1
|
||||
else:
|
||||
self.msgid = 1
|
||||
return self.msgid
|
||||
|
||||
def on_file_received(self, file):
|
||||
unitType = ""
|
||||
@@ -247,18 +240,18 @@ class ASEHandler(FTPHandler):
|
||||
send_mail(
|
||||
"Error", "OS error move " + filenameExt + " to " + newFilename, cfg
|
||||
)
|
||||
now = datetime.now()
|
||||
|
||||
mq_message = "{};{};{};{};{};{};{};{};{}".format(
|
||||
ts.timestamp("tms"),
|
||||
self.increment_msgid(),
|
||||
mq_message = {"payload": "{};{};{};{};{};{};{}".format(
|
||||
unitType,
|
||||
unitName,
|
||||
toolName,
|
||||
toolType,
|
||||
df.dateFmt(fileDate),
|
||||
fileTime,
|
||||
newFilename,
|
||||
)
|
||||
newFilename),
|
||||
"timestamp": int(datetime.timestamp(now)*1000000)
|
||||
}
|
||||
try:
|
||||
queue = mq(cfg)
|
||||
queue.write(mq_message, cfg)
|
||||
|
||||
@@ -7,7 +7,8 @@ from configparser import ConfigParser
|
||||
class config:
|
||||
def __init__(self):
|
||||
c = ConfigParser()
|
||||
c.read(["/etc/aseftp/ftpcsvreceiver.ini", "./ftpcsvreceiver.ini"])
|
||||
c.read(["/etc/aseftp/ftpcsvreceiver.ini", "./ftpcsvreceiver.ini",
|
||||
"./ase-receiver/ase-receiver/ftpcsvreceiver.ini"])
|
||||
# FTP setting
|
||||
self.firstport = c.getint("ftpserver", "firstPort")
|
||||
self.logfilename = c.get("ftpserver", "logFilename")
|
||||
|
||||
Reference in New Issue
Block a user