Wednesday, August 31, 2011

Debug GAE application with PTVS

PTVS(python tools for Visual Studio) http://pytools.codeplex.com/ is a python plugin for Visual studio (like PyDev for Eclipse)

GAE local debug starts from <dev_appserver.py> which located in GAE installation path. dev_appserver command line document is here: http://code.google.com/appengine/docs/python/tools/devserver.html

After write GAE code in VS, we prefer trigger it from VS, that make VS as an integrated environment  as it should be.

1, configure debug command:

startup file should be <dev_appserver.py>

0

argument indicated port and project position

1

 

2, press F5, let it go…

you’ll meet a lot of exception, it seems some problems in module loader. Anyway, it’s not exception from our code.

5

3, add this exception in ignore list.

open menu <Debug> <Exceptions…>

add the exception name “google.appengine.dist.py_zipimport.ZipImportError” under Python Exceptions, and uncheck the “User-unhandled” checkbox.

3

4, OK, you can take off now!

Monday, August 29, 2011

Turn on telnet & ftp services on Ubuntu

VNC is really lag cross Win and Linux, I’m suffering in the whole weekend .Today I tried to use outdated, but efficient solution: telnet & ftp >.<

sudo apt-get install telnetd //install telnet service

sudo /etc/init.d/openbsd-inetd restart //restart telnet service

you can simply turn on windows feature “telnet client”, and use telnet in windows command line

>telnet

>o 10.1.1.200

 

--------------------------

sudo apt-get install vsftpd //install ftp service

in FTP server configure file : /etc/vsftpd.conf, uncomment “write_enable=YES”, make sure you can upload file

sudo restart vsftpd //restart ftp service

 

simply try with windows ftp command

>ftp 10.1.1.200

>send c:\1.png

Friday, August 26, 2011

Connect Oracle in python

1, download cx_Oracle module

from http://cx-oracle.sourceforge.net/

[windows] double click the .msi file

[Ubuntu]

1,download .rpm file,

2, install alien tool in Ubuntu

3, install rpm by command “sudo alien -i cx_Oracle-5.1-10g-py27-1.i386.rpm ”

4, mv cx_Oracle related stuff (cx_Oracle-5.1-py2.7.egg-info & cx_Oracle.so) from site-packages/ to dist-packages/

5, add “export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/xe/app/oracle/product/10.2.0/client/lib” in .bashrc

6, source .bashrc

 

2, install oracle client, express version is enough

http://www.oracle.com/technetwork/database/express-edition/index.html

[Windows]set system variable: “ORACLE_HOME” to the path of where express client installed, e.g. D:\XEClient, (this step help cx_Oracle locate some DLLs under Client/bin folder)

[Ubuntu] download and install oracle-xe-client_10.2.0.1-1.0_i386.deb

 

4, make sure you can import cx_Oracle in python correctly now.

python –c ‘import cx_Oracle’

 

5, start coding in python

conn = cx_Oracle.connect(‘username’, “password”, cx_Oracle.makedsn(‘10.1.1.20’, 1521, ‘servicename’)) #connect to db

cur = conn.cursor()

cur.execute(“select * from xxxtable”);

rows = cur.fetchall()

for r in rows:

print r

conn.close();

Monday, August 8, 2011

Share files with Guest account in Win7

when sharing a folder to public, you should
1, turn on Guest account @ “User Accounts”
2, add Guest to sharing users @ sharing setting dialog
3, turn off password sharing.
after step 2, user login your share folder with guest, can not log in in fact. because Win 7 require a password log in by default, just like when using remote desktop, you can not log in with the guest account.
click “network and sharing center”, and turn off “password protected sharing”
image
image
4, now you can share files with guest account Smile with tongue out

Friday, August 5, 2011

Bind a domain name with GAE app

域名提供商Godaddy. 如果只是要提供一個forward,很簡單. 用戶輸入WWW.XXX.COM, 就會跳轉到appspot的域名上, 但是那個不是我需要的.
我需要的是別人不知道我用的是GAE.

1, 登錄app engine, 進入application settings, 選擇add domain
不過直接電價Add domain... 是不行的, 需要先點右邊的sign up for google apps>>
1
3

2,註冊app擁有者的信息
4
5

3,Google現在要驗證你是否是網站的主人.
6
7
選中domain提供商,會出現幫助
8


4,進入godaddy的管理頁面, 開始編輯ZONE FILE
9
TXT下面的@為google上顯示的一段驗證碼
CNAME下的www為ghs.google.com (後面要用到, 因为我们会用www来跳转到绑定的GAE APP)

5,OK 回到在GAE的添加domain頁面, 點擊 add domain… 進入
你會看到dashboard下面已經顯示
10
下面就是比较混乱的时候了...
Google的文档读起来让人疑惑不解...
我要实现用户敲入xxx.com时候,默认为www.xxx.com, 文档上说默认就是这样(http://code.google.com/appengine/docs/domain.html).而另外一个文档上又说几月几日起已经不支持这种nick name的跳转了.
不过我试了下不加new URL, www.XXX.com. google会提示
“GOOGLE app The requested URL / was not found on this server”
然后千辛万苦的找资料. 最后发现,还是要加上www.XXX.Com作为web address.這個時候google會告訴你, 需要去配置CNAME,而剛才我們已經順手將CNAME編輯過了.
 :P