aboutsummaryrefslogtreecommitdiffstats
path: root/python/upload_daily.py
blob: b209f5e5bbd282381103b5a4a40639f4c3ac1823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import os
import os.path
import datetime
from ftplib import FTP
import common
import config

workdate = str(datetime.date().today())
# globeopdate = datetime.strftime(datetime.today(), '%Y%m%d')

filelist = [(f, os.stat(os.path.join(common.root, workdate, f)).st_ctime) \
                for f in os.listdir(os.path.join(common.root, workdate)) \
                if "securitiesNpv" in f]

filelist = sorted(filelist, key = lambda x: x[1], reverse = True)
file_to_upload = filelist[0][0]

if filetoupload:
    ftp = FTP('ftp.globeop.com')
    ftp.login('srntsftp', config.ftp_password)
    ftp.cwd('incoming')
    with open(os.path.join(common.root, workdate, file_to_upload), "rb") as fh:
        ftp.storbinary('STOR ' + file_to_upload, fh)

print "done"