发送Subversion提交信息到Twitter金宝搏188官方

Hello, this is a bridge between Subversion (svn) and Twitter, the intent of this tool is to update a Twitter account when new commit messages arrives in a Subversion repository. We almost never have access to svn repository to add a post-commit hook in a way to call our script and send updates to twitter, so this tool was done to overcome that situation. Using it, you can monitor for example a svn repository from Google Hosting, from Sourceforge.net, etc…

The process of the tool is simple: it will firstly check Twitter account for the last svn commit message (the messages always start with a “$” prefix, or with another user-defined prefix), and then it will check the svn repository server to verify if it has new commits compared to the last tweet revision, if it has, it will update twitter with newer commit messages.

Here is a simple example of a Twitter account updated with commit messages:

twittsvn

The tool is very simple to use in command-line:

Python的twittsvn v.0.1克里斯蒂安S. Perone //www.cpetem.com用法:twittsvn.py [选项]选项:-h,--help显示此帮助信息并退出Twitter的选项:Twitter的会计选项-u TWITTER_USERNAME金宝搏188官方,--username =金宝搏188官方 TWITTER_USERNAME Twitter用户名(必需)。-p 金宝搏188官方TWITTER_PASSWORD,--password = TWITTER_PASSWORD微博密码(必需)。-r 金宝搏188官方TWITTER_REPONAME,--reponame = TWITTER_REPONAME库名称(需要)。-c 金宝搏188官方TWITTER_COUNT,--twittercount = TWITTER_COUNT多少鸣叫从Twitter获取,默认值是 '30'。颠覆选项:Subversion的选项-s SVN_PATH,--spath = SVN_PATH颠覆路径,默认为 ''。-n SVN_NUMLOG,--numlog = SVN的SVN_NUMLOG数记录得到的,默认为 '5'。

这里是一个简单的例子:

#蟒蛇twittsvn.py -u TWITTE金宝搏188官方R_USERNAME -p twitter_password \ -r any_repository_name

你必须在一个仓库目录执行它(而不是服务器,本地文件),或使用“-s”选项来指定本地存储库的路径。你应该把这个脚本使用cron或类似的东西来执行periodicaly。

要使用这个工具,你必须安装pysvnpython-twitter. To install Python-twitter you can use “easy_install python-twitter”, but for pysvn you must check the download section at the project site.

Here is the source-code of the twittsvn.py:

#中的python-twittsvn  - 一个SV金宝搏188官方N / Twitter的桥#版权所有(C)2009基督教S. Perone ##这个程序是免费软件:您可以重新分配和/或发表修改#它在GNU通用公共许可证的条款#自由软件基金会,无论是牌照的第3版,或#(由你选择)任何更新的版本。##本程序是基于希望,这将是有用的,但#无任何担保。甚至没有#适销性或适用于特定用途的隐含担保。详情请参见该#GNU通用公共许可证。##你应该已经收到一份GNU通用公共许可证#的副本连同本程序。如果不是看到。从进口optparse进口OptionParser SYS进口重新导入时,选项组__version__ = “0.1” __author__ = “基督教S. Perone” TWITTER_PREFIX = “$” TWITTER_MSG = TWITTER_PREFI金宝搏188官方X +“[%s]的修订版%的[%s]的%S d:%s的“尝试:进口pysvn除了导入错误:养导入错误,‘pysvn没有找到,检查http://pysvn.tigris.org/project_downloads.html’尝试:除了导入错误导入Twitter的:提高导入错误,”蟒蛇,叽叽喳喳未找到金宝搏188官方检查http://code.google.com/p/python-twitte金宝搏188官方r “DEF ssl_server_trust_prompt(trust_dict):返回TRUE,如图5所示,真DEF run_main():解析器= OptionParser()打印”。Python的twittsvn v%S \ n根据%的 “%(__version__,__author__)打印的 ”http://www.cpetem.com \ n“ 个group_tw金宝搏188官方itter =选项组(解析器, ”推选项“, ”微博会计选项“)group_twitter.add_option( ” -  U“,”--username”,DEST = 金宝搏188官方“TWITTER_USERNAME”,帮助= “Twitter用户名(必需)”,类型= “字符串”)group_twitter.add_option( “ -  p”, “ - 密码”,DEST = “twitter_password”,帮助= 金宝搏188官方“推密码(必需)。”, type="string") group_twitter.add_option("-r", "--reponame", dest="twitter_reponame", help="Repository name (required).", type="string") group_twitter.add_option("-c", "--twittercount", dest="twitter_count", help="How many tweets to fetch from Twitter, default is '30'.", type="int", default=30) parser.add_option_group(group_twitter) group_svn = OptionGroup(parser, "Subversion Options", "Subversion Options") group_svn.add_option("-s", "--spath", dest="svn_path", help="Subversion path, default is '.'.", default=".", type="string") group_svn.add_option("-n", "--numlog", dest="svn_numlog", help="Number of SVN logs to get, default is '5'.", default=5, type="int") parser.add_option_group(group_svn) (options, args) = parser.parse_args() if options.twitter_username is None: parser.print_help() print "\nError: you must specify a Twitter username !" return if options.twitter_password is None: parser.print_help() print "\nError: you must specify a Twitter password !" return if options.twitter_reponame is None: parser.print_help() print "\nError: you must specify any repository name !" return twitter_api = twitter.Api(username=options.twitter_username, password=options.twitter_password) twitter_api.SetCache(None) # Dammit cache ! svn_api = pysvn.Client() svn_api.callback_ssl_server_trust_prompt = ssl_server_trust_prompt print "Checking Twitter synchronization..." status_list = twitter_api.GetUserTimeline(options.twitter_username, count=options.twitter_count) print "Got %d statuses to check..." % len(status_list) last_twitter_commit = None for status in status_list: if status.text.startswith(TWITTER_PREFIX): print "SVN Commit messages found !" last_twitter_commit = status break print "Checking SVN logs for ['%s']..." % options.svn_path log_list = svn_api.log(options.svn_path, limit=options.svn_numlog) if last_twitter_commit is None: print "No twitter SVN commit messages found, posting last %d svn commit messages..." % options.svn_numlog log_list.reverse() for log in log_list: message = log["message"].strip() date = time.ctime(log["date"]) if len(message) <= 0: message = "(no message)" twitter_api.PostUpdate(TWITTER_MSG % (options.twitter_reponame, log["revision"].number, log["author"], date, message)) print "Posted %d svn commit messages to twitter !" % len(log_list) else: print "SVN commit messages found in twitter, checking last revision message...." msg_regex = re.compile(r'Rev\. (\d+) by') last_rev_twitter = int(msg_regex.findall(last_twitter_commit.text)[0]) print "Last revision detected in twitter is #%d, checking for new svn commit messages..." % last_rev_twitter rev_num = pysvn.Revision(pysvn.opt_revision_kind.number, last_rev_twitter+1) try: log_list = svn_api.log(options.svn_path, revision_end=rev_num, limit=options.svn_numlog) except pysvn.ClientError: print "No more revisions found !" log_list = [] if len(log_list) <= 0: print "No new SVN commit messages found !" print "Updated !" return log_list.reverse() print "Posting new messages to twitter..." posted_new = 0 for log in log_list: message = log["message"].strip() date = time.ctime(log["date"]) if len(message) <= 0: message = "(no message)" if log["revision"].number > last_rev_twitter: twitter_api.PostUpdate(TWITTER_MSG % (options.twitter_reponame, log["revision"].number, log["author"], date, message )) posted_new+=1 print "Posted new %d messages to twitter !" % posted_new print "Updated!" if __name__ == "__main__": run_main()

An analysis of Benford’s law applied to Twitter

Benford’s law是那些很奇怪的事情,我们无法解释亚洲金博宝之一,当我们发现越来越多的现象遵守法律,我们成了惊讶。两个人(西蒙·纽康– 1881 andFrank Benford- 1938年)指出,法以同样的方式, while flipping pages of a logarithmic table book; they noticed that the pages at the beginning of the book were dirtier than the pages at the end.

目前,还没有先验criteria that say to us when a dataset will or will not obey the Benford’s Law. And it is because of this, that I’ve done an analysis on theTwitter Public Timeline.

Twit金宝搏188官方ter的API来获取公共时间轴是这种分析根本没用,因为在API文档,他们说,公共时间轴将缓存60秒!60秒是永恒,且有150请求/小时的请求评级。所以,它不能帮助,buuuuuut,有一个alpha测试API与公共时间轴数据的漂亮,非常有用的流;亚洲金博宝有Twitter的流API的方法很多,而最有趣的是“流水”,金宝搏188官方它返回所有的公共状态,但这种方法仅适用于intere $婷的人,我不是其中之一。Buuuut,我们有“汽酒”,它返回所有的公共状态的一部分,因为它只是我们所拥有的可在当下,它必须是有用的,它是数据的一个漂亮的流=)

所以,我已经得到了数据的汽酒实时流和处理与正则表达式找到状态的所有数字抵达每一个新的状态;如果状态是“我有5只狗和3只猫”,收集应该是数字“[5,3]”。那么所有这些积累的数字进行了检查对本福德定律。我用Matplotlib绘制两条曲线(在本福德定律和Twitter的状态位分配),以经验观察它们之间的相关性。金宝搏188官方您可以在视频的右上角注意,Pearson’s correlation两个分布过于之间。

Here is the video (I’ve seen only after creating of the video, but the color of the curves are the inverse as seen in the legend):

视频代表Twitter的公共时间轴的15分钟(3.160拍摄的状态)。金宝搏188官方在视频的结尾,你可以看到0.95的Pearson相关性。看来,我们已经发现了另一本福德的儿子=)

处理数据的Twitter的汽酒流和绘制实时相关性图中的小工具金宝搏188官方,完全是用Python写的,我会做一个清理,并张贴在这里,我很快就得到了时间。该工具生成了一个使用ffmpeg的合并,1823个PNG图像。

我希望你喜欢=)

Cite this article as: Christian S. Perone, "An analysis of Benford’s law applied to Twitter," in亚洲金博宝未知领域, 11/08/2009,//www.cpetem.com/2009/08/an-analysis-of-benfords-law-applied-to-twitter/.

UPDATE 11/08:用户“poobare”援引有关本福德定律一个有趣的纸书签交易, here is链接.

More posts about Benford’s Law

素数和本福德定律

Delicious.com,检查用户数对本福德定律

Benford’s Law meets Python and Apple Stock Prices

Twitter in 3D !

我有在做一些测试eUbigraphdynamic graph visualization tool and I have this idea to use the Ubigraph tool to render 3D graphs of Twitter friends on real-time. Follows the video of the scripting utility I’ve created, it starts with a red node ofyour twitter当你点击,它显示你的朋友,当你点击你的朋友,这说明他们的朋友,等等。我觉得有趣的社交网络图,当我得到了更多的时间,我会把更多的想法在实践相关=)

Update (26/02):在这里下载脚本源代码。
To use it, you must install python-twitter, use the easy_install:

easy_install的蟒蛇,叽叽喳喳金宝搏188官方

I’ve tested with Python 2.5, but it should works on 2.4 and 2.6 too.

Start the Ubigraph visualization server and run the script. The syntax for the script is like this:

python twitter3d.py -u username

You can get a help using:

python twitter3d.py –help