在 TFS 中,如何访问 ReportServer URL 以获取每日 scrum 燃尽图的 jpeg 格式?

发布于 2024-11-17 05:45:59 字数 129 浏览 1 评论 0原文

我想访问 TFS 服务器,并定期下载动态生成的“Scrum Burndown 图表”,以便在单独的报告(即 pdf)中重新使用它 是的,有很多报告......

我如何在服务器中找到正确的 URL 进行下载,以及如何解决权限问题?

I wanted to access a TFS server, and download the dynamically produced "Scrum Burndown chart" on a regular basis, in order to re-use it in a seperate report (ie a pdf)
Yes, there is a lot of reporting going around ...

How do I find the correct URL in the server to download, and how do I get around the permissions problems?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖上得阳光 2024-11-24 05:45:59

这是我自己回答过的一个问题。

过程摘要

  • 使用 HTTP 代理嗅探器来确定 URL 的格式 - 请参阅下文
  • ,使用 py-ntlm 连接到 TFS 服务器,使用已知格式的 URL 获取“完整”报告页面,
  • 解析报告页面以获取图片 url,通过 py-ntlm 再次下载并存储。

没有直接的 URL,即我无法请求 reportserver/myteam/burndownchart/20110815 (很好且安静),但有一个参数样式请求
包装器“报告”我想要的图像。遗憾的是,没有简单的方法可以通过浏览 VS2010 扩展来找到它 - 我使用 Charles 调试器代理来查看 VS2010 发送的内容。

您需要直接访问您团队的报告的 URL 类似于
http://tfs.example.com/reportserver?/TfsReports/ExampleCompany/ExampleProject/Sprint+Burndown+Chart&rc:toolbar=false&pReleaseWorkStreamPath=\Release01\&pSprintTeam= \Release02\Sprint01\Team01

正在进行一些基于会话的混淆与实际的图像 URL,这意味着我必须调用然后解析报告页面,找到图像的 URL,然后下载它。最重要的是,我需要让 Python 与 Windows 身份验证一起工作,并且通常会进行大量的工作

下面的过程是合理的,但代码很脆弱,我只是推荐它作为起点

识别报告的 URL

安装 py-ntlm (http://code.google.com/p/python-ntlm/)

(a) 您需要每次创建用户密码和请求的 url 的哈希值(这通常在浏览器中是不可见的) )
(b) 然后将其作为 urllib2 处理程序传递给 urllib2
(c) 像往常一样通过 urllib2 处理 url,

import urllib2
from ntlm import HTTPNtlmAuthHandler
#
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, password) ## (a) 
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)  #(b)
opener = urllib2.build_opener(auth_NTLM)

urllib2.install_opener(opener)  # (c)
response = urllib2.urlopen(url_moi)
html = response.read()

这样我就可以得到标准报告网页,其中包含图像。我现在需要提取该图像 url,为此我使用正则表达式来获取
所有 IMG 标签并占据列表中的第二个。专业而且一点也不脆弱:-)

然后我们重建 nltm 哈希(我已经下载了 HTML 报告页面,现在我想要其中的 JPG 图像),
调用上面的 URL 并将输出写入本地磁盘。

我希望这有帮助。

青年MMV

This is a question I have answered myself.

Summary of process

  • use a HTTP proxy sniffer to determine the format of the URL - see below
  • using py-ntlm, connect to TFS server, using a known format of URL to get the "full" report page,
  • parse the report page to get the image url, down load that again through py-ntlm, and store.

There is no direct URL ie I cannot ask for reportserver/myteam/burndownchart/20110815 (nice and restful) but there is a param style request for the
wrapper "report" to the image I want. Sadly there is no easy way to find it just browsing in VS2010 extension - I used Charles debugger proxy to see what VS2010 is sending.

The url you will need to directly visit the report for your team is similar to
http://tfs.example.com/reportserver?/TfsReports/ExampleCompany/ExampleProject/Sprint+Burndown+Chart&rc:toolbar=false&pReleaseWorkStreamPath=\Release01\&pSprintTeam=\Release02\Sprint01\Team01

There is some Session based obfuscation going on with the actual image URL, meaning I must call then parse the report page, to find the URL of the image, and then download it. On top of that I needed to get Python to work with Windows Authentication, and generally fiddled around a great deal

The below process is sound but the code is brittle and I just recommend it as a starting point

Identify the URL of the report

Install py-ntlm (http://code.google.com/p/python-ntlm/)

(a) You need to create a hash of user pass and requested url each time (this is invisible by browser usually)
(b) THen pass that as a urllib2 handler to urllib2
(c) process the url as usual through urllib2

import urllib2
from ntlm import HTTPNtlmAuthHandler
#
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, user, password) ## (a) 
auth_NTLM = HTTPNtlmAuthHandler.HTTPNtlmAuthHandler(passman)  #(b)
opener = urllib2.build_opener(auth_NTLM)

urllib2.install_opener(opener)  # (c)
response = urllib2.urlopen(url_moi)
html = response.read()

SO that gets me the standard report web page, with image in it. I now need to extract that image url, for which I used a regex to get
all IMG tags and took the second one in the list. Professional and not at all brittle :-)

We then rebuild the nltm hash (I have downloaded the HTML report page, now I want the JPG image in it),
call the URL above and write the output to local disk.

I hope that helps.

YMMV

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文