0 Replies - 287 Views - Last Post: 03 April 2013 - 11:41 PM Rate Topic: -----

#1 precyoz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-April 13

Python 2.5 - Automatic Downloading difficulties

Posted 03 April 2013 - 11:41 PM

Hi,

Does anyone here knows any python script that could create an interface with ftp site, login and password? Which when everytime you'll login a pop up window with checkboxes will appear...these checkboxes should be connected to the ftp site...you're going to choose in any of the checkboxes and it'll automatically download...continuously download not until you'll turn off your pc...

I've done researches and i don't know how to do it..it indicates errors...it always says "gettaddrinfo failed"...how can i solve this?

i'm not good in python scripts...hope anyone can help me with this...Thanks!

here is the script that i've used:

 #!/usr/bin/python


from ftplib import FTP, all_errors
import wx


class MyStatusBar(wx.StatusBar):
    
    def __init__(self, parent):
        super(MyStatusBar, self).__init__(parent)

        self.SetFieldsCount(2)
        self.SetStatusText('Welcome to Kika', 0)
        self.SetStatusWidths([-1, 50])

class Example(wx.Frame):
           
    def __init__(self, *args, **kw):
        super(Example, self).__init__(*args, **kw) 
        
        self.InitUI()
        
    def InitUI(self):    

        wx.StaticText(self, label='Ftp site', pos=(10, 20))
        wx.StaticText(self, label='Login', pos=(10, 60))
        wx.StaticText(self, label='Password', pos=(10, 100))

        self.ftpsite = wx.TextCtrl(self, pos=(110, 15), 
            size=(120, -1))
        self.login = wx.TextCtrl(self,  pos=(110, 55), 
            size=(120, -1))
        self.password = wx.TextCtrl(self, pos=(110, 95), 
            size=(120, -1), style=wx.TE_PASSWORD)

        self.ftp = None

        con = wx.Button(self, label='Connect', pos=(10, 160))
        discon = wx.Button(self, label='DisConnect', pos=(120, 160))

        self.Bind(wx.EVT_BUTTON, self.OnConnect, con)
        self.Bind(wx.EVT_BUTTON, self.OnDisConnect, discon)
        self.Bind(wx.EVT_MAXIMIZE, self.OnMaximize) 

        self.sb = MyStatusBar(self)
        self.SetStatusBar(self.sb)
        
        self.SetSize((250, 270))
        self.SetTitle('Kika')
        self.Centre()
        self.Show()
 
    def OnMaximize(self, e):
        
        self.sb.PlaceIcon()             

    def OnConnect(self, e):
        
        if not self.ftp:
            
            ftpsite = self.ftpsite.GetValue()
            login = self.login.GetValue()
            password = self.password.GetValue()

            try:
                self.ftp = FTP(ftpsite)
                var = self.ftp.login(login, password)
                    
                self.sb.SetStatusText('User connected')
                
            except AttributeError:

                self.sb.SetStatusText('Incorrect params')
                self.ftp = None

            except all_errors, err:
                
                self.sb.SetStatusText(str(err))
                self.ftp = None

    def OnDisConnect(self, e):
        
        if self.ftp:
            
            self.ftp.quit()
            self.ftp = None
            
            self.sb.SetStatusText('User disconnected')


def main():
    
    ex = wx.App()
    Example(None)
    ex.MainLoop()    


if __name__ == '__main__':
    main()   




Is This A Good Question/Topic? 0
  • +

Page 1 of 1