[M2Crypto] Problems uploading to IIS using FTP over SSL
System: # rpm -q python m2crypto python-2.4.3-27.el5 m2crypto-0.16-6.el5.6 # cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.4 (Tikanga) I have the following method: def ftp_tarball(aggregation_dir, date_format, ftp_server, ftp_user, ftp_pass): date = datetime.today().strftime(date_format) ftp = ftpslib.FTP_TLS() ftp.connect(ftp_server) ftp.auth_tls() ftp.set_pasv(0) ftp.login(ftp_user, ftp_pass) filename = aggregation_dir + 'zultys-logs_' + date + '.tar.gz' short_name = os.path.split(filename)[1] tarball = open(filename, 'rb') ftp.storbinary('STOR ' + short_name, tarball) tarball.close() ftp.quit() This works perfectly with VSFTPD on Linux, with SSL forced for non- anonymous users. I try to connect to a supplier's IIS FTP server, and get: Traceback (most recent call last): File "/usr/local/bin/lumberjack", line 45, in ? lumberjack.ftp_tarball( aggregation_dir, date_format, ftp_server, ftp_user, ftp_pass ) File "/usr/lib64/python2.4/site-packages/lumberjack.py", line 93, in ftp_tarball ftp.storbinary('STOR ' + short_name, tarball) File "/usr/lib64/python2.4/ftplib.py", line 415, in storbinary conn = self.transfercmd(cmd) File "/usr/lib64/python2.4/ftplib.py", line 345, in transfercmd return self.ntransfercmd(cmd, rest)[0] File "/usr/lib64/python2.4/site-packages/M2Crypto/ftpslib.py", line 86, in ntransfercmd conn, size = FTP.ntransfercmd(self, cmd, rest) File "/usr/lib64/python2.4/ftplib.py", line 331, in ntransfercmd sock = self.makeport() File "/usr/lib64/python2.4/ftplib.py", line 292, in makeport resp = self.sendport(host, port) File "/usr/lib64/python2.4/ftplib.py", line 256, in sendport return self.voidcmd(cmd) File "/usr/lib64/python2.4/ftplib.py", line 246, in voidcmd return self.voidresp() File "/usr/lib64/python2.4/ftplib.py", line 221, in voidresp resp = self.getresp() File "/usr/lib64/python2.4/ftplib.py", line 216, in getresp raise error_perm, resp ftplib.error_perm: 501 Server cannot accept argument. A colleague is able to connect using the Filezilla client, configured as servertype: FTPES - FTP over explicit TLS/SSL setting. I've not been able to find any further guidnance on the web. If you've experienced this before, or can see something that I've obviously got wrong, I'd appreciate your help. TIA, S. -- http://mail.python.org/mailman/listinfo/python-list
[M2Crypto] Problems uploading to IIS using FTP over SSL
Hello, System: # rpm -q python m2crypto python-2.4.3-27.el5 m2crypto-0.16-6.el5.6 # cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.4 (Tikanga) I have the following method: def ftp_tarball(aggregation_dir, date_format, ftp_server, ftp_user, ftp_pass): date = datetime.today().strftime(date_format) ftp = ftpslib.FTP_TLS() ftp.connect(ftp_server) ftp.auth_tls() ftp.set_pasv(0) ftp.login(ftp_user, ftp_pass) filename = aggregation_dir + 'zultys-logs_' + date + '.tar.gz' short_name = os.path.split(filename)[1] tarball = open(filename, 'rb') ftp.storbinary('STOR ' + short_name, tarball) tarball.close() ftp.quit() This works perfectly with VSFTPD on Linux, with SSL forced for non- anonymous users. I try to connect to a supplier's IIS FTP server, and get: Traceback (most recent call last): File "/usr/local/bin/lumberjack", line 45, in ? lumberjack.ftp_tarball( aggregation_dir, date_format, ftp_server, ftp_user, ftp_pass ) File "/usr/lib64/python2.4/site-packages/lumberjack.py", line 93, in ftp_tarball ftp.storbinary('STOR ' + short_name, tarball) File "/usr/lib64/python2.4/ftplib.py", line 415, in storbinary conn = self.transfercmd(cmd) File "/usr/lib64/python2.4/ftplib.py", line 345, in transfercmd return self.ntransfercmd(cmd, rest)[0] File "/usr/lib64/python2.4/site-packages/M2Crypto/ftpslib.py", line 86, in ntransfercmd conn, size = FTP.ntransfercmd(self, cmd, rest) File "/usr/lib64/python2.4/ftplib.py", line 331, in ntransfercmd sock = self.makeport() File "/usr/lib64/python2.4/ftplib.py", line 292, in makeport resp = self.sendport(host, port) File "/usr/lib64/python2.4/ftplib.py", line 256, in sendport return self.voidcmd(cmd) File "/usr/lib64/python2.4/ftplib.py", line 246, in voidcmd return self.voidresp() File "/usr/lib64/python2.4/ftplib.py", line 221, in voidresp resp = self.getresp() File "/usr/lib64/python2.4/ftplib.py", line 216, in getresp raise error_perm, resp ftplib.error_perm: 501 Server cannot accept argument. A colleague is able to connect using the Filezilla client, configured as servertype: FTPES - FTP over explicit TLS/SSL setting. I've not been able to find any further guidance on the web. If you've experienced this before, or can see something that I've obviously got wrong, I'd appreciate your help. TIA, S. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems uploading to IIS using FTP over SSL
On Feb 26, 2:05 pm, Stephen Nelson-Smith wrote: > Hello, I'm sorry - I hadn't realised that python-list ended up here as well. Sincere apologies for double-posting. S. -- http://mail.python.org/mailman/listinfo/python-list
Trouble with quotes
Hi, I've written some (primitive) code to parse some apache logfies and establish if apache has appended a session cookie to the end. We're finding that some browsers don't and apache doesn't just append a "-" - it just omits it. It's working fine, but for an edge case: Couldn't match 192.168.1.107 - - [24/Feb/2010:20:30:44 +0100] "GET http://sekrit.com/node/175523 HTTP/1.1" 200 - "http://sekrit.com/search/results/"3%2B2%20course""; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.4)" Couldn't match 192.168.1.107 - - [24/Feb/2010:20:31:15 +0100] "GET http://sekrit.com/node/175521 HTTP/1.1" 200 - "http://sekrit.com/search/results/"3%2B2%20course""; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.4)" Couldn't match 192.168.1.107 - - [24/Feb/2010:20:32:07 +0100] "GET http://sekrit.com/node/175520 HTTP/1.1" 200 - "http://sekrit.com/search/results/"3%2B2%20course""; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.4)" Couldn't match 192.168.1.107 - - [24/Feb/2010:20:32:33 +0100] "GET http://sekrit.com/node/175522 HTTP/1.1" 200 - "http://sekrit.com/search/results/"3%2B2%20course""; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.4)" Couldn't match 192.168.1.107 - - [24/Feb/2010:20:33:01 +0100] "GET http://sekrit.com/node/175527 HTTP/1.1" 200 - "http://sekrit.com/search/results/"3%2B2%20course""; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; GTB6.4)" Couldn't match 192.168.1.107 - - [25/Feb/2010:17:01:54 +0100] "GET http://sekrit.com/search/results/ HTTP/1.0" 200 - "http://sekrit.com/search/results/"guideline%20grids"&page=1"; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" Couldn't match 192.168.1.107 - - [25/Feb/2010:17:02:15 +0100] "GET http://sekrit.com/search/results/ HTTP/1.0" 200 - "http://sekrit.com/search/results/"guideline%20grids"&page=1"; "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)" If there are " " inside the request string, my regex breaks. Here's the code: #!/usr/bin/env python import re pattern = r'(?P^(-|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(, [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})*){1}) (?P(\S*)) (?P(\S*)) (?P(\[[^\]]+\])) (?P(\"([^"\\]*(?:\\.[^"\\]*)*)\")?) (?P(\S*)) (?P(\S*)) (?P(\"([^"\\]*(?:\\.[^"\\]*)*)\")?) (?P(\"([^"\\]*(?:\\.[^"\\]*)*)\")?)( )?(?P(\"([^"\\]*(?:\\.[^"\\]*)*)\")?)' regex = re.compile(pattern) lines = 0 no_cookies = 0 unmatched = 0 for line in open('/home/stephen/scratch/test-data.txt'): lines +=1 line = line.strip() match = regex.match(line) if match: data = match.groupdict() if data['SiteIntelligenceCookie'] == '': no_cookies +=1 else: print "Couldn't match ", line unmatched +=1 print "I analysed %s lines." % (lines,) print "There were %s lines with missing Site Intelligence cookies." % (no_cookies,) print "I was unable to process %s lines." % (unmatched,) How can I make the regex a bit more resilient so it doesn't break when " " is embedded? -- Stephen Nelson-Smith Technical Director Atalanta Systems Ltd www.atalanta-systems.com -- http://mail.python.org/mailman/listinfo/python-list