yichao firstname, zeaster nickname, zhang lastname

A tool that import all posts from wordpress to blogger in python

the tool can be downloaded from
http://yichao.zhang.googlepages.com/wordpress2blogger.py

Readme:

1 set the following parameters in the wordpress2blogger.py file
# set your wordpress username, password, xmlrpc url    
wp_username = 'admin'  
wp_passwd = 'mypwd'
wp_url = 'http://localhost/wordpress/xmlrpc.php'
                       
# set your blogger email, password, blogid
# blogid is in your blogspot Dashboard url, for example:
# http://www2.blogger.com/posts.g?blogID=18083698, "18083698" is your blogid.
blogger_email = 'yichao.zhang@gmail.com'
blogger_passwd = 'mypwd'
blogger_blogid = '18083698'

# set how many recent posts do you want to import from wordpress to blogger
wp_recent_posts_num = 5 

# set debug mode = True if you want to get debug info
DEBUG = True

3 make sure python in your path

4 in terminal, type the following command
   "python wordpress2blogger.py"

js feature by jQuery copied from codeplayer

Now, after loading this page, all titles of the posts are folded and click "+" to unfold, click title to dig into the single post page.
The feature above is implemented by the following code copied from codeplayer.
css part:
.mytoggle{
  cursor:pointer;
  font-size:22px;
  color:green;
}

script part:
<script src='http://www.douban.com/js/jquery.js' type='text/javascript'></script>
<script language='javascript'>
$(function(){
  $(".post-title").prepend("<span class='mytoggle'>-</span>");
  $(".mytoggle").click(
    function(e){
      var content = $(this).parent().next().next();
      content.toggle();
      if(content.css("display")=="none")
        $(this).html("+");
      else
        $(this).html("-");
    }
  ).click();
})
</script>

Translate ipmsg into GBK on Mac OS X

在公司使用ipmsg作为即时通讯工具,不过那是windows版的,用了Mac后自然无法使用了。
最近发现不用ipmsg,好多公司的通知都收不到了,虽然偶现在实习写论文,也没什么大事儿,但还是有点不方便。
于是google之:
惊喜!ipmsg竟然有unix,Mac OS X,java等诸多版本。
立马下了个Mac的版本,装上一看,都是日文!原来ipmsg是日本人开发的,除了windows版有国人azhi做了汉化,并改名为飞鸽传书,其他版本均不支持中文。

无奈!只好试试java版的了,发现使用swt写的,于是自己汉化之。
汉化还是比较容易的,有源代码,这点上还是要赞一下那位日本作者!
主要改了3个地方,
一是把界面显示的文字汉化
二是把消息传递时的字符编码改为GBK,本想改为UTF-8的,但这样和windows版的又不兼容了,所以只好改为GBK。
三是把保存日志时的字符编码改为GBK。

另外,java版的ipmsg每次都会弹出个login的对话框,需要点一下才可以登陆,麻烦!于是改代码,把这个对话框去掉了,每次都只从ipmsg.properties文件中读取用户以及分组信息。

接下来要赞一下eclipse!
这个swt工程可以直接export成苹果的应用程序,app格式,帅呆了!
另外,程序中使用了当前目录下的文件,如icon.gif或ipmsg.properties等。通过自己建了个"./testfile.txt"的文件后,知道原来打包成.app后的当前目录就是.app所在的目录。于是把icon文件夹以及ipmsg.properties放到和ipmsg.app平级的位置就可以了!

哈哈,这下在Mac OS X下也可以使用ipmsg了,虽然java版的不支持文件传输,但以后接收公司通知是没问题了。
文件传输的问题也可以通过苹果自带的ftp服务器方便的解决。哈哈

PS - 2009-02-16:
应网友的请求, 把原来打好包的ipmsg放到了这里, 方便有需要的朋友下载
http://blogsync-java.googlecode.com/files/ipmsg-macosx.zip

另外, 如果有朋友想继续完善ipmsg for Mac OS X 的功能, 可以下载这个eclipse项目.
http://blogsync-java.googlecode.com/files/ipmsg_eclipse_project.zip

active mode OR passive mode on FTP

自从给小黑装上了Mac OS X就再也不想用windows了,不管是xp还是vista,都太蹩脚了
在公司和同事传文件时,苹果自带的ftp服务器就派上了用途。
苹果自带的这个ftp服务器还是很好用的,不需要配置,只需要在sharing中启动ftp服务,打开防火墙就OK了。
但接下来也遇到了一点点麻烦:
同事使用windows自带的ftp命令行工具则可以访问我的ftp服务器,使用flashFXP则无法访问。
后来证实是因为ftp命令行使用active mode(主动模式)所以可以访问,而flashFXP选用passive mode(被动模式)无法访问,不选用被动模式则可以正常访问。

于是google之:
看到这篇文章,疑惑顿释。
主动模式和被动模式是相对于ftp服务器来说的,即是ftp服务器主动同客户端建立通讯socket或ftp服务器被动接受客户端发来的建立通讯socket请求。
ftp以及telnet等老式的通信协议使用了2种端口,一个是命令端口(Command Port),另一个是数据端口(Data Port)
ftp的命令端口是21,这个端口在苹果防火墙设置中被开放。但另一个数据端口是在通信时由客户端随机指定的,如果使用被动模式,客户端使用数据端口进行通信时就会被Mac的防火墙拦住。而使用主动模式时,是ftp服务器使用数据端口和同事的机器建立socket,而同事机器上没有防火墙,因此可以正常访问。

后来,在同事机器上装了天网防火墙,建立了若干规则,很容易就验证了上述想法。

xmlrpc for python

使用python处理xmlrpc太简单了,又一次感受到了python的力量!
下面以使用python调用wordpress提供的xmlrpc方法为例简单介绍一下:

1) how to call xmlrpc method in python
>>> import xmlrpclib
>>> from pprint import pprint
>>> server = xmlrpclib.ServerProxy("http://localhost/wordpress/xmlrpc.php")
>>> pprint(server.system.listMethods() )

['system.multicall',
 'system.listMethods',
 'system.getCapabilities',
 'demo.addTwoNumbers',
 'demo.sayHello',
 'pingback.extensions.getPingbacks',
 'pingback.ping',
 'mt.publishPost'......]

>>> blogs = server.metaWeblog.getRecentPosts('','admin','passwd',5)
>>> pprint(blogs)
>>> print(blogs[2]['permaLink'])

http://localhost/wordpress/?p=135

2)how to setup a xmlrpc server in python

import calendar, SimpleXMLRPCServer
#The server object
class Calendar:
    def getMonth(self, year, month):
        return calendar.month(year, month)

    def getYear(self, year):
        return calendar.calendar(year)
calendar_object = Calendar()
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8888))
server.register_instance(calendar_object)
#Go into the main listener loop
print "Listening on port 8888"
server.serve_forever()

3)write a client to test server above
import xmlrpclib
server = xmlrpclib.ServerProxy("http://localhost:8888")
month = server.getMonth( 2002, 8 )
print month

     August 2002
Mo Tu We Th Fr Sa Su
                 1    2    3   4
 5   6   7   8    9   10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

PS:
pprint means pretty print. A cool tool too.

Reference:
1 http://docs.python.org/lib/module-xmlrpclib.html
2 http://www-128.ibm.com/developerworks/library/ws-pyth10.html
3 http://groovy.codehaus.org/XMLRPC

A simpler tool that imports all posts from wordpress to blogger/blogspot

jigar told me that the tool I post yesterday is too technical in Groups Google.
see
"""
can you make it simpler by making a standalone application. (I m trying
with that.)
This is too technical.
 If successful definitely it will be most useful thing around for
blogger.
"""
so I made it simpler by building a standalone. and
The simpler tool can be downloaded from this link.

After that, I found python is more suitable to do this staff and I'll try to make a more simpler tool written in python later.

Readme.txt
0. What is it used for?
This is a simple tool to import all posts from wordpress to blogger/blogspot.

1. How to use it?
1.1 as standalone app
for windwows user
1) set java in your path
2) set some parameters in run.bat, see details in run.bat
3) run run.bat now.

for linux/Mac OS X user
1) set java in your path
2) some parameters in run.sh, see details in run.sh
3) run run.sh now.

1.2 you can compile it and run it of course!
This tool depends on (a) Google Data APIs java client library and (b) apache xml-rpc library.
You can find them on
(a) http://code.google.com/apis/gdata/download/gdata.java.zip
(b) http://ws.apache.org/xmlrpc/download.html

download and put the above two libraries in your classpath
now configure some parameters in src/org/easter/blogsync/SyncWorker.java
1) set your wordpress blog url
2) set your wordpress blog username and password
3) set your blogger username and password
4) set your blogger blogid. Don't know what's your blogger's blogid? go to step 2.
5) set how many recent posts do you want to import from wordpress.

ok, let's run SyncWorker.java, and done.

2. what is my blogger blogid?
It's in your blogspot Dashboard url, for example: http://www2.blogger.com/posts.g?blogID=18083698
"18083698" is your blogid.


install subversion on Mac OS X

DO NOT use *.zip file, that's for windows!
decompress *.tar.gz and *-deps.tar.gz and just run:
./configure --with-apxs=/usr/local/apache2/bin/apxs --prefix=/usr/local/subversion --with-ssl --without-berkeley-db

simple shell to compress and decompress .tar.gz on Mac OS X

compress:
tar -czf dirname.tar.gz dirname

decompress:
tar -xzf dirname.tar.gz

parameter -z means .gz

A tool that imports all posts from wordpress to blogger/blogspot

The tool can be download from this link

Readme.txt:

0. What is it used for?
This is a simple tool to import all posts from wordpress to blogger/blogspot.

1. How to use it?
This tool depends on (a) Google Data APIs java client library and (b) apache xml-rpc library.
You can find them on
(a) http://code.google.com/apis/gdata/download/gdata.java.zip
(b) http://ws.apache.org/xmlrpc/download.html

download and put the above two libraries in your classpath
now configure some parameters in src/org/easter/blogsync/SyncWorker.java
1) set your wordpress blog url
2) set your wordpress blog username and password
3) set your blogger username and password
4) set your blogger blogid. Don't know what's your blogger's blogid? go to step 2.
5) set how many recent posts do you want to import from wordpress.

ok, let's run SyncWorker.java, and done.

2. what is my blogger blogid?
It's in your blogspot Dashboard url, for example: http://www2.blogger.com/posts.g?blogID=18083698

"18083698" is your blogid.

The tool can be download from this link

technorati tags:, ,