Mark Brown
Mark.Brown at greenskycredit.com
Thu Mar 11 17:09:05 EST 2010
Sorry that I am really, really new to Python but I have run into a wall and need some help: Basically, I am trying to create a web-client for a sftp server. You enter your user name and password and you authenticate against the sftp server, see a list of all the files on the server, can browse the server, and if you click on a link download the file. I have tried several different methods to keep the network-resource in the session, but nothing thus far has worked. My research seems to indicate that in order to achieve this I would need to write a daemon that handles the connection, and pass the session id to the daemon to match connection to web request. I have found some articles on how to turn a python script into a daemon, but I need some help understanding what is really going. Anyways, the script I have tested thus far using mod_python is below: from mod_python import apache from mod_python import Session import paramiko def handler(req): session=Session.Session(req) req.content_type="text/html" try: session['hits'] +=1 #dirlist=session['sftp'].listdir('.') req.write('From Session') except: t=paramiko.Transport(('[SERVER NAME],22)) t.connect(username='[USER NAME]',password='[PASSWORD]') sftp=paramiko.SFTPClient.from_transport(t) dirlist = sftp.listdir('.') session['hits']=1 session['sftp']=sftp req.write('New Session') session.save() req.write('Hits %d\n' % session['hits']) req.write(dirlist) return apache.OK Mark Brown Credit & Operations Manager GreenSky mark.brown at greenskycredit.com<mailto:esmith at greenskycredit.com> Office: 404.832.4147 Fax: 404.832.4111 ________________________________ This electronic message transmission contains information from GreenSky Trade Credit, LLC which may be confidential & privileged. Recipients should not file copies of this e-mail with publicly accessed records. The information is intended to be for the use of the individual(s) named above. If you are not the intended recipient, please be aware that any disclosure, copying, distribution or use of this message is prohibited. If you have received this electronic transmission in error, please notify us by e-mail immediately. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20100311/9da14353/attachment.html
|