daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # This script is used to upload data to PMS
  2.  
  3. import sys
  4. import ftplib
  5. import glob
  6. import shutil
  7. import os
  8.  
  9. CONFIG_UPLOAD_ITEMS = [
  10.     {
  11.         "src" : "c:/Interface/IData",
  12.         "dest" : "idata1"
  13.     }
  14. ]
  15. CONFIG_FTP_HOST = "203.154.175.170"
  16. CONFIG_FTP_USER = "pms_integration_service"
  17. CONFIG_FTP_PASSWORD = "loudtown19"
  18.  
  19. for item in CONFIG_UPLOAD_ITEMS:
  20.     src = item["src"]
  21.     dest = item["dest"]
  22.     print("processing " + src)
  23.     file_list = glob.glob(src + "/*")
  24.     ftp = ftplib.FTP(CONFIG_FTP_HOST)
  25.     ftp.login(CONFIG_FTP_USER, CONFIG_FTP_PASSWORD)
  26.     ftp.cwd("idata")
  27.     for file in file_list:
  28.         print("uploading " + file)
  29.         file_name = os.path.basename(file)
  30.         myfile = open(file, 'r')
  31.         ftp.storlines('STOR ' + file_name, myfile)
  32.         myfile.close()
  33.        
  34.     print("moving files to uploaded")
  35.     for file in file_list:
  36.         shutil.move(file, src + "/uploaded/")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top