Is anybody aware of a Python solution to sftp into the Bloomberg enterprise service. We're converting some bloomberg pulling from Mathworks to Python. Historically, I would have done this in Mathworks like this using the bdl function.
username = 'xxxxx';
password = 'xxxxxxxx';
hostname = 'dlsftp.bloomberg.com';
portnumber = 30206;
decrypt = 'nAcLeZ';
c = bdl(username,password,hostname,portnumber,decrypt)
Any thoughts? Thanks!
OK, for anybody that needs SOCKS proxy through Bloomberg, here is what I've done and it works:
After some research, it appears the decrypt is not necessary. This code works, just be sure to include the two files for a test: ('readme.txt','readme-test.txt') on your bloomberg server using RequestBuilder or WinSCP.
# coding: utf-8
import paramiko
import socket
import socks
proxy_details = {'host': "xxx",
'port': 1080,
'username': "xxx",
'password': "xxx"}
auth_credentials = {'host': "sftp.bloomberg.com",
'username': "dlxxxxxx",
'password': "xxxxxx"}
s = socks.socksocket()
s.set_proxy(
proxy_type=socks.SOCKS5,
addr=proxy_details['host'],
port=proxy_details['port'],
username=proxy_details['username'],
password=proxy_details['password']
)
#setup the SFTP client using the connected socket
s.connect((auth_credentials['host'],22))
transport = paramiko.Transport(s)
transport.connect(username=auth_credentials['username'],
password=auth_credentials['password'])
# start SFTP Client from SSH transport
sftp = paramiko.SFTPClient.from_transport(transport) #.get_transport() was appended
#will download readme.txt from the remote server, and save as the filename in the second argument
sftp.get('readme.txt','readme-test.txt')
#Test whether transport is authenticated
print (transport.is_authenticated())
# cleanup
sftp.close()
transport.close()