Click here to Skip to main content
15,881,882 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: determine page title Pin
Jassim Rahma19-Nov-11 4:26
Jassim Rahma19-Nov-11 4:26 
GeneralRe: determine page title Pin
Jassim Rahma19-Nov-11 19:50
Jassim Rahma19-Nov-11 19:50 
GeneralRe: determine page title Pin
Niall Barr21-Nov-11 1:06
professionalNiall Barr21-Nov-11 1:06 
AnswerRe: determine page title Pin
afroxav30-Nov-11 6:35
afroxav30-Nov-11 6:35 
Questionfile_get_contents() Pin
tarık kazancı17-Nov-11 2:11
tarık kazancı17-Nov-11 2:11 
AnswerRe: file_get_contents() Pin
cjoki18-Nov-11 9:27
cjoki18-Nov-11 9:27 
Questionuse doctrine ORM in Model laye MVC Pin
Mr.Moqadam16-Nov-11 22:19
Mr.Moqadam16-Nov-11 22:19 
QuestionUsing python to copy only files with a given extension Pin
matjame14-Nov-11 21:20
matjame14-Nov-11 21:20 
Hi. New in python but managed to find my way around. I have a folder named date(i.e 20111011, or 20111101). The script goes and ftps the folder that matches the date passed(python CallTibcoWS.py 20111104). If the folder name matches the date passed then it will copy the folder to a specified location. Now I want to use the same code to copy files. I have another folder(folder name not important), with files. File extensions are dates(i.e name.20111111, surname.20110102, python.20101111). I want to copy all the files that match the date passed when I run the script(python CallTibcoWS.py 20111104).....My code is as below

import os
import datetime
import time
import sys
import subprocess
import paramiko
import platform

WSDESCRIPTOR = 'ESSImporter'
LOGFILE = 'C:/Logs/%s/%s_%s.log' % (WSDESCRIPTOR.lower(), WSDESCRIPTOR, datetime.datetime.now().strftime("%Y-%m-%d"))
TIBCOSERVER = 'GenevaServer'
TIBCOPORT = '7979'
WEBSERVICEADDRESS = "http://%(server)s:%(port)s/ESSImporter/Services/Interface/intfESSImporter-service.serviceagent/intfwsProcess_ESSImporterEndpoint1" % {'server': TIBCOSERVER, 'port': TIBCOPORT, 'ws': WSDESCRIPTOR}
FILEPATH='/export/home/extracts/out/%s'

REMOTEPATH='C:/ESSSWAP/Ess_Import/%s'

FTPSERVER = 'Server'
FTPUSER = 'test'
if platform.system().upper() == 'WINDOWS' : #dev environment
   FTPPASSWORD = "C:/Priv_Key.ppk"
else:
    FTPPASSWORD = "/export/Priv_Key.ppk"
    
FILEEXT = 'date is the extension_%s' % (datetime.datetime.now().strftime("%Y-%m-%d"))
FILELIST = (('basket_div_SA.0', 'basket_div_SA'), ('basket_payment_SA.0', 'basket_payment_SA'), ('basket_summary_SA.0', 'basket_summary_SA'), ('basket_swap_SA.0', 'basket_swap_SA'), ('basket_trade_SA.0', 'basket_trade_SA'), ('interest_detail_SA.0', 'interest_detail_SA'), ('unwind_SA.0', 'unwind_SA'))
    

def getfile(ftphost, fromfile, tofile, tibcoinstanceInfo=None, tibcoinstanceError=None):
    
    
    if tibcoinstanceInfo:
        tibcoinstanceInfo('Connecting to %s as %s with pw %s' % (ftphost, FTPUSER, FTPPASSWORD))
        
    try:
        t = paramiko.Transport((ftphost, 22))
        key = paramiko.RSAKey.from_private_key_file(FTPPASSWORD)
        t.connect(username=FTPUSER, pkey=key)
        sftp = paramiko.SFTPClient.from_transport(t)
        
        print(fromfile)
      

                
        if sftp != None:
            sftp.get(fromfile, tofile)

            sftp.close()
        
            if tibcoinstanceInfo:
                tibcoinstanceInfo('FTP of the file was successful')
            result = True
        else:
            if tibcoinstanceError:
                tibcoinstanceError('Could not connect to the FTP server')
            result = False
        
        
    except Exception, e:
        if tibcoinstanceError:
            tibcoinstanceError('Error FTPing the file from %s to %s: %s: %s' % (fromfile,tofile,e.__class__, e))
        result = False
        
    return result

kagiso

AnswerRe: Using python to copy only files with a given extension Pin
Addy Tas29-Nov-11 12:28
Addy Tas29-Nov-11 12:28 
Questionhow to specify page title? Pin
Jassim Rahma10-Nov-11 4:23
Jassim Rahma10-Nov-11 4:23 
AnswerRe: how to specify page title? Pin
Mohibur Rashid10-Nov-11 4:42
professionalMohibur Rashid10-Nov-11 4:42 
AnswerRe: how to specify page title? Pin
arya168515-Nov-11 1:10
arya168515-Nov-11 1:10 
QuestionPageLayout - your advise? Pin
Jassim Rahma10-Nov-11 3:04
Jassim Rahma10-Nov-11 3:04 
AnswerRe: PageLayout - your advise? Pin
Mohibur Rashid10-Nov-11 4:37
professionalMohibur Rashid10-Nov-11 4:37 
AnswerRe: PageLayout - your advise? Pin
arya168515-Nov-11 1:09
arya168515-Nov-11 1:09 
GeneralRe: PageLayout - your advise? Pin
Jassim Rahma15-Nov-11 3:49
Jassim Rahma15-Nov-11 3:49 
AnswerRe: PageLayout - your advise? Pin
awedaonline5-Dec-11 23:21
awedaonline5-Dec-11 23:21 
Questionwidth is making crazy! Pin
Jassim Rahma10-Nov-11 2:11
Jassim Rahma10-Nov-11 2:11 
AnswerRe: width is making crazy! Pin
Mohibur Rashid10-Nov-11 4:49
professionalMohibur Rashid10-Nov-11 4:49 
GeneralRe: width is making crazy! Pin
Jassim Rahma10-Nov-11 5:50
Jassim Rahma10-Nov-11 5:50 
GeneralRe: width is making crazy! Pin
Mohibur Rashid10-Nov-11 10:16
professionalMohibur Rashid10-Nov-11 10:16 
GeneralRe: width is making crazy! Pin
Jassim Rahma10-Nov-11 6:09
Jassim Rahma10-Nov-11 6:09 
GeneralRe: width is making crazy! Pin
Mohibur Rashid10-Nov-11 10:17
professionalMohibur Rashid10-Nov-11 10:17 
GeneralRe: width is making crazy! Pin
Jassim Rahma10-Nov-11 23:14
Jassim Rahma10-Nov-11 23:14 
GeneralRe: width is making crazy! Pin
Mohibur Rashid11-Nov-11 1:26
professionalMohibur Rashid11-Nov-11 1:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.