Python SFTP彭博数据许可证 - Paramiko

时间:2017-06-28 20:49:47

标签: python sftp paramiko bloomberg

有人知道一个Python解决方案可以进入Bloomberg企业服务。我们正在将一些bloomberg从Mathworks转换为Python。从历史上看,我会使用bdl函数在Mathworks like this中完成此操作。

username = 'xxxxx';
password = 'xxxxxxxx';
hostname = 'dlsftp.bloomberg.com';
portnumber = 30206;
decrypt = 'nAcLeZ';

c = bdl(username,password,hostname,portnumber,decrypt)

有什么想法?谢谢!

1 个答案:

答案 0 :(得分:2)

好的,对于任何需要通过Bloomberg进行SOCKS代理的人来说,这就是我所做的并且有效:

经过一些研究,似乎没有必要进行解密。这段代码有效,只需确保在您的bloomberg服务器上使用RequestBuilder或WinSCP包含两个文件进行测试:('readme.txt','readme-test.txt')。

# 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()