obtain client ip address from SimpleXMLRPCServer ?

2006-01-23 Thread stuff
Is it possible to obtain the client's ip address from a
SimpleXMLRPCServer instance or subclass instance?  When running
SimpleXMLRPCServer with logRequests = 1, the xmlrpc server prints out
the fqdn on the console, however, I'm not sure if this information
(either fqdn or ip address) is available to the SimpleXMLRPCServer
instance.  Can somebody shed some light on how to obtain this
information?

Thanks,

Phil

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: obtain client ip address from SimpleXMLRPCServer ?

2006-01-26 Thread stuff
Thanks for the reply Peter.  Can you provide a code snippet for
extracting this data.  When I print the dir() of the SimpleXMLRPCServer
instance I do not see a request_handler attribute or method.

Phil

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: obtain client ip address from SimpleXMLRPCServer ?

2006-01-29 Thread stuff
Thanks again Peter.  I found 2 potential solutions for obtaining the ip
address of the incoming
connection.  The first was to subclass SimpleXMLRPCRequestHandler class
and pass it
to the SimpleXMLRPCServer constructor.  In doing so, I could directly
access the client_address via self.client_address.  This worked just
fine but was a bit overkill.

The other solution I noticed was that SimpleXMLRPCServer's (which
ultimately subclasses BaseServer) handle_request method invokes
get_request (which merely calls self.socket.accept() -- which returns a
tuple including the ip address).  By re-implementing get_request() as
such:

def get_request(self):
req = self.socket.accept()
ip_address = req[1][0]
return req

I can grab the ip address for internal use and have the get_request
method return the expected data for use by hande_request().

Now I just need to find a thread-safe way of passing this data back to
the XMLRPC server's registered_instance.

-- 
http://mail.python.org/mailman/listinfo/python-list


ftplib and retrbinary or retrlines (losing newline characters in my log files)

2007-01-24 Thread aus stuff

Hi am successfully downloading my text files and writing them to local files
with either

ftp.retrlines('RETR ' + fl, fileObj.write)"

ftp.retrbinary('RETR  ' + fl, fileObj.write)

However all my recieved (log) files have lost thier newline characters?

Can anyone steer me in the right direction so my 'recieved log' files arent
all jumbled into one line?

(full code below)
any help appreciated :)
(excuse my newbie code copying )

Special thanks to the person/s whom originally made this code (found on
google)


>myLogger, "Couldn't find server"
   ftp.login(userName,passWord )
   ftp.cwd(remotePath )

   try:

   #print >>myLogger, "Connecting...",
   print "Connecting..."
   if onlyDiff:
   lFileSet = Set(os.listdir(localPath))
   rFileSet = Set(ftp.nlst())
   transferList = list(rFileSet - lFileSet)
   #print >>myLogger,  "Missing: " + str(len(transferList)) + ' >>>
',
   print "Missing: " + str(len(transferList)),
   else:
   transferList = ftp.nlst()
   delMsg = ""
   filesMoved = 0
   for fl in transferList:
   ttt = ''
   ttt = str(fl)
   if string.find(ttt, '.') > 0 :
   print '\nCopying >>> ' + ttt

   # create a full local filepath
   localFile = localPath + fl
   grabFile = True
   if grabFile:
   #open a the local file
   fileObj = open(localFile, 'wb')
   # Download the file a chunk at a time using RETR
   #ftp.retrbinary('RETR ' + fl, fileObj.write)
   ftp.retrlines('RETR  ' + fl,
fileObj.write)


   # Close the file
   fileObj.close()
   filesMoved += 1

   # Delete the remote file if requested

   if deleteRemoteFiles:
   ftp.delete(fl)
   delMsg = " and Deleted"
   #print >>myLogger,  " and Deleted"

   #print >>myLogger,  "Files Moved" + delMsg + ": " + str(filesMoved)
+ ' >>> ' + " On " + timeStamp()
   print "\nFiles Copied " + delMsg + ": " + str(filesMoved)
   except:
   #print >>myLogger,  "Connection Error - " + timeStamp()
   print "Connection Error - "
   ftp.close() # Close FTP connection
   ftp = None

copyFTPFiles("server","uname","pass","remoteDir","localDir")




code end
-- 
http://mail.python.org/mailman/listinfo/python-list