Changeset - 6c4fa1df8add
[Not reviewed]
default
0 1 1
Laman - 6 years ago 2019-05-05 13:01:34

uploading to FTP
2 files changed with 23 insertions and 0 deletions:
0 comments (0 inline, 0 general)
.hgignore
Show inline comments
 
@@ -2,3 +2,4 @@
 
^\.idea/
 
^images/
 
^config.json$
 
ftp.json$
exp/kerokero/ftp.py
Show inline comments
 
new file 100644
 
import os
 
import json
 
import ftplib
 
import logging as log
 

	
 
thisDir=os.path.dirname(__file__)
 
with open(os.path.join(thisDir,"ftp.json")) as f:
 
	cfg=json.load(f)
 

	
 

	
 
def push(path):
 
	ftp=ftplib.FTP()
 
	ftp.connect(cfg["host"],cfg["port"])
 
	ftp.login(cfg["user"],cfg["password"])
 

	
 
	filename=os.path.basename(path)
 

	
 
	log.info("uploading %s",path)
 
	with open(path,mode="rb") as f:
 
		ftp.storbinary("STOR "+filename,f)
 

	
 
	ftp.close()
0 comments (0 inline, 0 general)