Personal tools
You are here: Home QRSS Upload program
Document Actions

Upload program

Upload program skrevet i python

# -*- coding: cp1252 -*-

# LA5GOA upload program for QRSS
import ftplib
import os
import sys
import traceback
import time
import shutil

STI = "C:\\qrss\\1_ftp\\"                  # Argo lagrer her
FILNVN = "upload.jpg"                     # navn pÃ¥ fil som nettsiden bruker til visning
SERVER = "www.qsl.net"                 # paa logging server
PORT = "21"
FTPUSER = "user"         
FTPPASS = "pasw"
FTPSTI = "/"                                      # filplasering pÃ¥ server for upload.jpg
DEST_STI = "C:\\qrss\\arkiv\\"         # dir for arkiv
INTERVALL = 15                               # sekunder

while (True):   
    try:
        try:
            for fil in os.listdir(STI) :   
                    if os.path.exists(STI + FILNVN):
                        break
                    print ("\nFunnet " + fil)
                    shutil.copy(STI + fil, DEST_STI + fil)
                    os.rename(STI + fil, STI + FILNVN)
                    break


            if os.path.exists(STI + FILNVN):
                ftp = ftplib.FTP()
                ftp.connect(SERVER, PORT)
                print "Kobler til FTP server..."
                ftp.login(FTPUSER, FTPPASS)
                ftp.cwd(FTPSTI)
                f = open(STI + FILNVN, "rb")
                print "Laster opp fil..."
                ftp.storbinary('STOR ' + FILNVN, f)
                f.close()
                ftp.quit()
                print "Frakoblet"
                os.remove(STI + FILNVN)
            else:
                sys.stdout.write (".")
        finally:
                time.sleep(INTERVALL)
    except:
        traceback.print_exc()
       
time.sleep(INTERVALL)

« June 2013 »
Su Mo Tu We Th Fr Sa
1
2345678
9101112131415
16171819202122
23242526272829
30
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: