Source

wd_pys60 / wd_httpd_utility.py

import wd_key_press as wk
import e32
import laa
if e32.pys60_version=="1.4.5 final":
    import socket as socket
else:
    import btsocket as socket
#print e32.pys60_version=="1.4.5 final"

import time
t=time.sleep
ip_addr="127.0.0.1"
ip_addr="0.0.0.0"
ap_id,apo=[None]*2
def init_connect():
    global ip_addr,ap_id,apo
    ap_id = socket.select_access_point()
    apo = socket.access_point(ap_id)
    apo.start()
    ip_addr=apo.ip()
    print ip_addr
def update_site_info_on_gae():
    import urllib
    print urllib.urlopen("http://wd-database-gae.weakdancer.com/write?type=string&key_name=wd_6120c_ip_addr&content=%s"%ip_addr).read()
def set_httpconf():
    _cf=file("c:\\data\\apache\\conf\\httpd-listen.conf","w+")
    res="Listen %s:80"%ip_addr
    _cf.write(res)
    _cf.close()
def launch_pamp():
    laa.execute(0xe45c24ff)
def quit_pamp():
    wk.left_soft()
    wk.up()
    wk.ok()
def start_httpd():
    wk.left_soft()
    wk.right()
    wk.down()
    wk.ok()
    t(1)
    wk.ok()
    t(1)
    wk.ok()
def stop_httpd():
    wk.left_soft()
    wk.down()
    wk.right()
    wk.ok()
def restart_httpd():
    stop_httpd()
    t(4)
    start_httpd()

init_connect()

#set_httpconf()
launch_pamp()
t(3)
start_httpd()

update_site_info_on_gae()

"""
t(12)
restart_httpd()
t(12)
stop_httpd()
quit_pamp()
"""