def start_section(learn): result = learn.SetListeningResponseInformation('0', '0') status = result['SetListeningResponseInformationResult'] if status == '1': library.success('started section ' + learn.SectionID + ' successfully') else: library.fail('started section ' + learn.SectionID + ' failed') exit() return status
def update_unit(learn): result = learn.SetListeningUnitLearnStaus('1') status = result['SetListeningUnitLearnStausResult'] if status == '1': library.success('update unit learn status success: unit ' + learn.UnitID) else: library.fail('update unit learn status fail: unit ' + learn.UnitID) exit() return status
def login(learn): result = learn.LoginListening() status = result['LoginListeningResult'] if status == '1': library.warning('user ' + learn.username + ' need activation') exit() elif status != '2': library.fail('user ' + learn.username + ' login failed: ' + result['ReturnMessage']) exit() else: library.success('user ' + learn.username + ' login successfully') return status
def __check_connect(self): if self.available == 0: try: r = requests.get('http://' + self.path + '/WebService/ServiceV3.asmx?WSDL', headers={ 'Content-Type': 'application/x-www-form-urlencoded' }) text = r.text if text.find('LoginListeningResponse') != -1: self.available = 1 except: library.fail('fail to connect server: ' + self.path) exit() return
def end_section(learn, score): result = learn.SetListeningResponseInformation("%.1f" % score, '1') status = result['SetListeningResponseInformationResult'] if status == '1': library.success('ended section ' + learn.SectionID + ' successfully: score ' + "%.1f" % score) else: library.fail('ended section ' + learn.SectionID + ' failed') # Retry login status = login(learn) # Retry set response result = learn.SetListeningResponseInformation("%.1f" % score, '1') status = result['SetListeningResponseInformationResult'] if status == '1': library.success('ended section ' + learn.SectionID + ' successfully: score ' + "%.1f" % score) else: library.fail('ended section ' + learn.SectionID + ' failed twice') exit() return status
def active(learn, SerialNumber, LicenseNumber, ActivationCode): result = learn.LoginListening() status = result['LoginListeningResult'] if status == '2': library.warning('user ' + learn.username + ' have been actived') return '1' elif status != '1': if result['ReturnMessage'].find('Activation') == -1: library.fail('user ' + learn.username + ' login failed: ' + result['ReturnMessage']) exit() result = learn.SetListeningUserActiveInfo(SerialNumber, LicenseNumber, ActivationCode) status = result['SetListeningUserActiveInfoResult'] if status == '1': library.success('user ' + learn.username + ' active successfully') else: library.fail('user ' + learn.username + ' active failed: ' + result['ReturnMessage']) exit() return status
obj[name] except: obj[name] = None if var[name] == None: var[name] = obj[name] elif var[name] != obj[name]: obj[name] = var[name] sync(var, obj, [name for name in var]) f.seek(0) json.dump(obj, f) # check necessary arguments if var['path'] == None or var['username'] == None or var[ 'password'] == None or var['level'] == None: library.fail('missing required var') exit() # Var init learn = learn_english(var['path'], var['username'], var['password'], var['level']) # Activation if args.activation == True: print 'Get Activation Code at http://www.neie.edu.cn/License/LicenseActivation.aspx' SerialNumber = raw_input('Serial Number: ') LicenseNumber = raw_input('License Number: ') ActivationCode = raw_input('Activation Code: ') print 'Confirm your information' print 'Path: ' + var['path']