Few days back I was trying to search university local repository for softwares) for unetbootin. After 5mins of search i was still not sure whether 224 has the app or not. So , i began to code my own package for searching local repo’s ,

heres the code https://github.com/pradyu1993/FtpSearch .

so about the code i used depth first algorithm for searching the folders , urllib2 for accessing the local ftp

what can we do with the package, here are some code snippets

from FtpSearch import *

imports all the class present in __init__.py

first do

FtpSearch.SetProxy(Proxy deatils)    # if  your using net under proxy server


ftp = FtpRepo(url)   #creates a instance of FtpRepo
                                         #keyword to be searched 

                                         #depth till which the repo is to be searched

                                         #by default strict search is False making it True will compare case sensitivity also.
ftp.search(keyword)            #will only search the current page

I did this after setting the proxy settings


I searched 223 for ‘math’ for depth = 4, guess what i found 57results



Installing Python Packages under proxy server

Hey guys, lately i was trying to install orange package, then i encountered a error saying that

File "C:\Python27\lib\urllib2.py", line 126, in urlopen
 return _opener.open(url, data, timeout)

Then I realized that the error in  urlopen is because, the request is not going through http proxy server(my University provides internet through proxy server), so i added few lines to the code and the code  started working like a charm. This code could help anyone whose trying to install python packages or trying to use urllib,urllib2 libraries under proxy server.The code goes like this

import urllib2
import urllib

these lines will help python import urllib2(extensible library for opening URLs), urllib(Open arbitrary resources by URL)

name = 'f2011xxx'
password = 'xxxxxx'
proxy = ''
port = '8080'
auth = 'http://%s:%s@%s:%s' % (name , password , proxy , port)

My college proxy server needs authentication , so here name,password means authentication id(used variable as name cause there is a build in function id ) and password and here is my hostel proxy and 8080 is the port number, auth is a string(change http to wat ever necessary depending on the server you are under)

handler = urllib2.ProxyHandler({'http': auth})

ProxyHandler makes all the requests go through the proxy, here http cause im accessing internet through http proxy server(change to wat ever necessary depending on the server ur under),To disable autodetected proxy pass an empty dictionary.

opener = urllib2.build_opener(handler)

build_opener class returns a opener instance and install_opener class set the opener globally so, now all the urlopen requests go through the proxy server

else  we can also try Opener.open() request instead of setting the opener globally but the error will be shown if we try creating another instance of urlopen

else This is the easiest way:

I uploaded a module containing code on github at https://github.com/pradyu1993/ProxyPackage , for setting the proxy using the module do this

import ProxyPackage
proxy = ProxyPackage(give details proxy details here)
proxy.set_global()   #to set proxy settings globally


proxy.open_url(url)   #to open url with the proxy settings

BAM!!!! the package has to start installing