1.1 --- a/tools/addusers.py Sat Nov 02 01:48:34 2013 +0100
1.2 +++ b/tools/addusers.py Sat Nov 02 19:03:37 2013 +0100
1.3 @@ -18,6 +18,7 @@
1.4 from subprocess import call
1.5 import random, string
1.6 import sys
1.7 +import codecs
1.8
1.9 def randompass():
1.10 return "".join(random.sample(string.ascii_letters, 10))
1.11 @@ -41,14 +42,16 @@
1.12 print >>sys.stderr, "Example: %s wiki" % progname
1.13 sys.exit(1)
1.14
1.15 - line = sys.stdin.readline()
1.16 + stdin = codecs.getreader("utf-8")(sys.stdin)
1.17 + stdout = codecs.getwriter("utf-8")(sys.stdout)
1.18 + line = stdin.readline()
1.19 while line:
1.20 username, fullname, email, image = line.strip("\n ").split("\t")
1.21 password = randompass()
1.22 add_user(wiki, username, fullname, email, password)
1.23 - print "\t".join([username, fullname, email, image, password])
1.24 + print >>stdout, "\t".join([username, fullname, email, image, password])
1.25
1.26 - line = sys.stdin.readline()
1.27 + line = stdin.readline()
1.28
1.29 if __name__ == "__main__":
1.30 main()
2.1 --- a/tools/get_profile.py Sat Nov 02 01:48:34 2013 +0100
2.2 +++ b/tools/get_profile.py Sat Nov 02 19:03:37 2013 +0100
2.3 @@ -9,11 +9,11 @@
2.4
2.5 from os.path import split
2.6 from urllib import basejoin
2.7 -import libxml2dom, sys
2.8 +import libxml2dom, sys, codecs
2.9
2.10 def get_profile(url, username):
2.11 try:
2.12 - d = libxml2dom.parseURI("%s/display/~%s" % (url.rstrip("/"), username), html=True)
2.13 + d = libxml2dom.parseURI("%s/display/~%s" % (url.rstrip("/"), username), html=True, htmlencoding="utf-8")
2.14
2.15 fullname = d.xpath("//span[@id='fullName']")
2.16 fullname = fullname and fullname[0].textContent or ""
2.17 @@ -39,8 +39,9 @@
2.18 print >>sys.stderr, "Example: %s http://wiki.list.org/ <username>" % progname
2.19 sys.exit(1)
2.20
2.21 + stdout = codecs.getwriter("utf-8")(sys.stdout)
2.22 details = get_profile(url, username)
2.23 - print "\t".join(details)
2.24 + print >>stdout, "\t".join(details)
2.25
2.26 if __name__ == "__main__":
2.27 main()
3.1 --- a/tools/get_profiles.py Sat Nov 02 01:48:34 2013 +0100
3.2 +++ b/tools/get_profiles.py Sat Nov 02 19:03:37 2013 +0100
3.3 @@ -13,6 +13,7 @@
3.4 from time import sleep
3.5 from os.path import split
3.6 import sys
3.7 +import codecs
3.8
3.9 this_dir = split(sys.argv[0])[0]
3.10 sys.path.append(this_dir)
3.11 @@ -31,10 +32,11 @@
3.12 print >>sys.stderr, "Example: %s http://wiki.list.org/" % progname
3.13 sys.exit(1)
3.14
3.15 + stdout = codecs.getwriter("utf-8")(sys.stdout)
3.16 line = sys.stdin.readline()
3.17 while line:
3.18 username = line.strip()
3.19 - print "\t".join(get_profile(url, username))
3.20 + print >>stdout, "\t".join(get_profile(url, username))
3.21
3.22 sleep(delay)
3.23 line = sys.stdin.readline()