rename csv before move

This commit is contained in:
2020-05-02 15:43:33 +02:00
parent 0ca5cfeeac
commit 776ab2ee13
3 changed files with 11 additions and 32 deletions

View File

@@ -13,7 +13,7 @@ from email.mime.text import MIMEText
from asebat.timefmt import timestamp_fmt as ts
from asebat.timefmt import date_refmt as df
from asebat.config import set_config as config
from asebat.config import set_config as setting
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
@@ -117,6 +117,7 @@ class ASEHandler(FTPHandler):
) + "/"
newFilename = (newPath + filename + "_" +
str(ts.timestamp("tms") + fileExtension))
fileRenamed = (file + "_" + str(ts.timestamp("tms")))
try:
os.makedirs(newPath)
logging.info("PID {:>5} >> path {} created.".format(
@@ -125,7 +126,8 @@ class ASEHandler(FTPHandler):
logging.info("PID {:>5} >> path {} already exists.".format(
os.getpid(), newPath))
try:
shutil.move(file, newFilename)
os.rename(file, fileRenamed)
shutil.move(fileRenamed, newFilename)
logging.info("PID {:>5} >> {} moved into {}.".format(
os.getpid(), filenameExt, newFilename))
except OSError:
@@ -154,7 +156,7 @@ class ASEHandler(FTPHandler):
def main():
cfg = config.config()
cfg = setting.config()
try:
authorizer = UnixAuthorizer(rejected_users=["root"],
require_valid_shell=True)