def savepage(): rs={'msg':'','log':'','rst':'','data':{}} form = cgi.FieldStorage() conf = readconf() if "username" in form: conf["username"]=form["username"].value if "password" in form: conf["password"]=form["password"].value if "LIXIAN_DOWNLOAD_PATH" in form: conf["LIXIAN_DOWNLOAD_PATH"]=form["LIXIAN_DOWNLOAD_PATH"].value if "pretask" in form: if form["pretask"].value == '-': conf["pretask"]="" else: conf["pretask"]=chkscript(form["pretask"].value) if "aftertask" in form: if form["aftertask"].value == '-': conf["aftertask"]="" else: conf["aftertask"]=chkscript(form["aftertask"].value) try: writeconf(conf) if not "username" in form and not "password" in form: rs['msg']="changeok" return rs sys.path.append('core') from lixian import XunleiClient client = XunleiClient(conf['username'],conf['password'],os.environ['LIXIAN_HOME'] +'/.xunlei.lixian.cookies') if client.has_logged_in(): rs['msg']="loginok" return rs else: rs['msg']="faillogin" return rs except Exception as inst: rs['msg']="faillogin" rs['log']=str(inst) return rs
def startup(): rs={'msg':'','log':'','rst':'','data':{}} rs['data'] = {'startup':'false' ,'logined':'false'} #lixian core check try: sys.path.append('core') from lixian import XunleiClient except Exception as e: rs['msg'] = "coreerr" rs['log'] = str(e) return rs #config check try: conf=readconf() except Exception as e: rs['msg'] = "configerr" rs['log'] = str(e) return rs rs['data']['startup'] = 'true' #login check try: client = XunleiClient(conf['username'],conf['password'],os.environ['LIXIAN_HOME'] +'/.xunlei.lixian.cookies') except Exception as e: rs['msg'] = "needlogin" rs['log'] = str(e) return rs #client.login if not client.has_logged_in(): rs['msg'] = "needlogin" return rs rs['data']['logined'] = 'true' rs['msg'] ="loginok" return rs