From df14d92746ce98e07407a92507db97ae7e6a896a Mon Sep 17 00:00:00 2001 From: Harald Mueller Date: Tue, 24 May 2022 13:49:44 +0200 Subject: [PATCH] muh --- m122/LB_Einzelaufgabe_Projekt/testdaten.txt | 1 + m122/tools-technics/README.md | 11 +++++++ m122/tools-technics/ftp.py | 33 +++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 m122/LB_Einzelaufgabe_Projekt/testdaten.txt create mode 100644 m122/tools-technics/README.md create mode 100644 m122/tools-technics/ftp.py diff --git a/m122/LB_Einzelaufgabe_Projekt/testdaten.txt b/m122/LB_Einzelaufgabe_Projekt/testdaten.txt new file mode 100644 index 0000000..fcf4ec2 --- /dev/null +++ b/m122/LB_Einzelaufgabe_Projekt/testdaten.txt @@ -0,0 +1 @@ +Testdaten H. Müller vom 16.5.2022 diff --git a/m122/tools-technics/README.md b/m122/tools-technics/README.md new file mode 100644 index 0000000..1c21537 --- /dev/null +++ b/m122/tools-technics/README.md @@ -0,0 +1,11 @@ +# m122 + +## Tools & Technics + +### FTP + + - [https://www.howtoforge.com/tutorial/how-to-use-ftp-on-the-linux-shell/](https://www.howtoforge.com/tutorial/how-to-use-ftp-on-the-linux-shell/) + - HOST: ftp.haraldmueller.ch + - USER: schoolerinvoices + - PASS: Berufsschule8005! + \ No newline at end of file diff --git a/m122/tools-technics/ftp.py b/m122/tools-technics/ftp.py new file mode 100644 index 0000000..e00ba16 --- /dev/null +++ b/m122/tools-technics/ftp.py @@ -0,0 +1,33 @@ +import ftplib +import glob + + +def file_filename(path): + for filename in glob.glob(path): + file = open(filename, 'rb') + return file, filename + +def upload_files(): + ftp = ftplib.FTP("url", "username", "password") + + file_txt = file_filename("uploads\\zahlungssystem\\*.txt") + filename_txt = file_filename("uploads\\zahlungssystem\\*.txt") + + file_xml = file_filename("uploads\\zahlungssystem\\*.xml") + filename_xml = file_filename("uploads\\zahlungssystem\\*.xml") + + # zum Erstzen (leer machen) der Pfadangaben + filename_txt = filename_txt.replace("uploads\\zahlungssystem\\", "") + filename_xml = filename_xml.replace("uploads\\zahlungssystem\\", "") + + ftp.cwd("in/" + "foldername") + + ftp.storbinary("STOR " + filename_txt) + ftp.storbinary("STOR " + file_txt) + file_txt.close() + + ftp.storbinary("STOR " + filename_xml) + ftp.storbinary("STOR " + file_xml) + file_xml.close() + + ftp.quit() \ No newline at end of file