def read_messages(): try: opt=globalui.global_popup_menu([u'Inbox \xbb',u'Outbox \xbb',u'Sent \xbb',u'Draft \xbb'],u'Choose Folder') if opt==0: fold=inbox.EInbox if opt==1: fold=inbox.EOutbox if opt==2: fold=inbox.ESent if opt==3: fold=inbox.EDraft fol=inbox.Inbox(fold) meid=fol.sms_messages() if meid!=[]: global som, old old=[appuifw2.app.menu_key_text,appuifw2.app.menu,appuifw2.app.exit_key_text,appuifw2.app.exit_key_handler,appuifw2.app.title] som=[] m=[] for i in meid: som.append((fol.content(i),fol.address(i),fol.time(i))) m.append((fol.content(i),fol.address(i))) appuifw2.app.body=appuifw2.Listbox(m,mes) appuifw2.app.title=u'Select Message' appuifw2.app.menu=[(u'Info',minf),(u'Close',stop)] appuifw2.app.exit_key_handler=stop appuifw2.app.menu_key_text=u'Messages' appuifw2.app.exit_key_text=u'Close' ao=e32.Ao_lock() ao.wait() else: appuifw2.note(u'Folder Empty','error') read_messages() except: return None
def startinfo(s, arg=None, move=None): if not s.list: aw.note('Нет сохраненных копий'.decode("utf-8")) return None def window(): i = s.index m = ('янв', 'фев', 'мар', 'апр', 'май', 'июн', 'июл', 'авг', 'сен', 'окт', 'ноя', 'дек') t = s.list[i][0] s.info.start(s.list[i][1].decode("utf-8"), lambda: s.stopinfo(1), s.delete_copy, s.stopinfo, s.startinfo) aw.app.title = u'[%d/%d] %s %s\n%s : %s : %s' % (i + 1, len( s.list), t[6:8], m[int(t[4:6]) - 1], t[8:10], t[10:12], t[12:14]) e32.ao_yield() if not arg: s.capture.stop() s.old_title = aw.app.title elif arg and move == 63495: s.index -= 1 if s.index < 0: s.index = len(s.list) - 1 window() elif arg and move == 63496: s.index += 1 if s.index > len(s.list) - 1: s.index = 0 window() if not move: window()
def ma(): ui.note(u'VERSION: 1.3') #ui.app.menu=[(u'Static Calc', static), (u'Dynamic Calc', dynamic), (u'Author', la), (u'Version', ma), (u'Exit', exit_key_handler)] #ui.app.exit_key_handler=exit_key_handler #app_lock.wait()
def lbox(self): ind=self.lb.current() if ind==2: a=ui.selection_list([u'Static', u'Dynamic']) if a==0: static() elif a==1: dynamic() elif ind==0: tnu=self.tnu tcp=self.tcp cgpa=self.cgpa() ui.query(u'TCP :> '+tcp.strip()+'\nTNU :> '+tnu+'\n\nCGPA :> '+cgpa, 'query', None, u'OK', u'Back') else: new=static(int(self.tnu), float(self.tcp)) if not new: return 0 if type(new)!=list: ui.note(u'an error occurred', 'error') return 0 a=open(folder+'%s.gpd'%self.user, 'w') a.write(str(new[1])+'\n') a.write(str(new[0])) a.close() self.update(self.user)
def printException(Exception, e, str1=''): logs(u'@ Error :') errStr = cn(str(Exception) + u': ' + str(e)) logs(errStr) traceback.print_exc() if str1: displayLongText(u'Error Encountered: \n' + errStr + u'\n' + str1) appuifw.note(u'View E:\\neteaseDebug\\log.txt For More Details.')
def clear_data(self, user): if ui.query(u'sure to clear all records', 'query', None, u'Yes', u'No'): new=open(folder+'%s.gpd'%user, 'w') data=('0', '0') for i in data: new.write(i+'\n') new.close() self.update(user) ui.note(u'cleared', 'conf') return 1
def all_users(self): if not self.db: ui.note(u'no user yet') return 0 a=ui.View() a.title=u'All Users' lb=ui.Listbox(self.db.keys()) a.body=lb ui.app.view=a a.exit_key_text=u'Close' a.menu_key_text='' a.exit_key_handler=a.close
def continuework(self,path,navi_title,uipos,soundposition,manual): if manual: self.close() self.soundobj=self.backupobj;del self.backupobj if soundposition: self.soundobj.set_position(soundposition) try: self.soundobj.set_volume(1) self.soundobj.play(callback=self.callselect) except: appuifw2.note(u"file corrupt!","error") return appuifw2.app.title=u"Playing:" appuifw2.app.navi_text=u"%s"%navi_title[:22] self.changedata([(0,uipos),(1,soundposition),(2,path),(3,navi_title)])
def del_user(): try: if ui.query(u'Confirm Account Delete', 'query', None, u'Confirm', u'Cancel'): os.chmod(folder+'%s.gpd'%user, ~0) os.remove(folder+'%s.gpd'%user) f=open(folder+'ini.db', 'w') del self.db[user] f.write(str(self.db)) f.close() ui.note(u'deleted', 'conf') a.close() return 1 except: ui.note(u'Error\nTry Again', 'error') return 1
def ch_pass(self, user): new=ui.multi_query(u'enter current password:'******'enter new password:'******'wrong password', 'error') return 0 else: self.db[user]=new[1] a=open(folder+'ini.db', 'w') a.write(str(self.db)) a.close() ui.note(u'success', 'conf') return 1
def clearCache_(): dirs = [ 'e:\\neteaseDebug', 'e:\\netease', 'e:\\netease\\lyric', 'e:\\netease\\pic', 'e:\\netease\\cache\\playlist' ] for d in dirs: cleanDir(d) files = ['e:\\netease\\data\\cookie.txt', 'e:\\netease\\data\\captcha.png'] for f in files: if os.path.isfile(f): try: os.remove(f) except: logs('remove error on %s' % f) appuifw.note(cn('清除完成'))
def saveSong(self): try: songDict = self.listdetail[self.songIndex] prompt = cn('') if not os.path.exists(self.songPath): self.songPath = self.fetchSong() if os.path.exists(self.songPath): desPath = 'E:\\Music\\%s - %s.mp3' % (cn( songDict['name']), cn(songDict['artists'][0]['name'])) desPath = cn(desPath) orgPath = cn(self.songPath) fileman.file_copy(orgPath, desPath, cfileman.EOverWrite) prompt += cn('在E:\\Music') + cn('创建了') + cn( os.path.basename(nc(desPath))) + cn('(') + cn( str(self.br / 1000)) + cn('Kbps)') else: return False if self.hasLyric: desPath = 'E:\\Music\\%s - %s.lrc' % (cn( songDict['name']), cn(songDict['artists'][0]['name'])) desPath = nc(cn(desPath)) f = os.open(desPath, os.O_WRONLY | os.O_CREAT) os.write(f, STR_UTF8_BOM) os.write(f, nc(cn(self.hasLyric))) os.close(f) prompt += cn('和') + cn(os.path.basename(desPath)) resp = appuifw.note(prompt) except Exception, e: printException(Exception, e, cn('SomeErrorsWithsaveSong')) try: os.close(f) except: pass
def new_user(self): while True: user=ui.query(u'enter username:'******'text') if not user: return 0 user=user.lower() if os.path.exists(folder+'%s.gpd'%user): ui.note(u'username already exists', 'error') else: break while True: passw=ui.multi_query(u'enter password', u'retype password') if not passw: return 0 if passw[0]!=passw[1]: ui.note(u'password mismatch', 'error') else: break new=open(folder+'%s.gpd'%user, 'w') data=('0', '0') for i in data: new.write(i+'\n') new.close() self.db[user]=passw[0] db=open(folder+'ini.db', 'w') db.write(str(self.db)) db.close() ui.note(u'Success', 'conf') return 1
def user_data(self, user): def logout(): ui.note(u'Goodbye') a.close() def del_user(): try: if ui.query(u'Confirm Account Delete', 'query', None, u'Confirm', u'Cancel'): os.chmod(folder+'%s.gpd'%user, ~0) os.remove(folder+'%s.gpd'%user) f=open(folder+'ini.db', 'w') del self.db[user] f.write(str(self.db)) f.close() ui.note(u'deleted', 'conf') a.close() return 1 except: ui.note(u'Error\nTry Again', 'error') return 1 if not self.update(user): ui.note(u'user data not found\naccount deleted', 'error') return 0 a=ui.View() a.title=user self.choice=[u'Current CGPA Details', u'Update Profile', u'Instant GPCalc'] self.lb=ui.Listbox(self.choice, self.lbox) a.body=self.lb a.exit_key_text=u'Logout' a.exit_key_handler=logout a.menu=[ (u'CGPA', lambda: ui.note(self.cgpa())), (u'Clear Data', lambda: self.clear_data(self.user)), (u'Change Password', lambda: self.ch_pass(self.user)), (u'Logout', logout), (u'Delete Account', del_user)] ui.app.view=a
def static(): noc=ui.query(u'total no of courses taken:', 'number') if not noc: ui.note(u'no course taken') return 1 iter=0 tnu=0 tcp=float(0) while iter<noc: while True: unit=ui.query(u'enter course unit:', 'number') if unit==0: ui.note(u'a value is required') elif not unit: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 else: break tnu+=unit while True: score=ui.query(u'enter score or grade:', 'text') if not score: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 elif score in (['%d'%x for x in range(70, 101)]+['A', 'a']): tcp+=5*unit break elif score in (['%d'%x for x in range(60, 70)]+['B', 'b']): tcp+=4*unit break elif score in (['%d'%x for x in range(50, 60)]+['C', 'c']): tcp+=3*unit break elif score in (['%d'%x for x in range(46, 50)]+['D', 'd']): tcp+=2*unit break elif score in (['%d'%x for x in range(40, 46)]+['E', 'e']): tcp+=unit break elif score in (['%d'%x for x in range(40)]+['F', 'f']): break else: ui.note(u'invalid score', 'error') iter+=1 gpa=tcp/tnu if not ui.query(u'ur GPA is: %.3f'%gpa, 'query', None, u'ok', u'comments'): __comments(gpa)
def dynamic(tnu=0, tcp=0): ui.note(u'lets get started') #tnu=0 tcp=float(tcp) while True: while True: unit=ui.query(u'enter course unit:', 'number') if unit==0: ui.note(u'a value is required') elif not unit: if ui.query(u'Stop Calc', 'query', None, u'Yes', u'No'): return 0 else: break tnu+=unit while True: score=ui.query(u'enter score or grade:', 'text') if not score: if ui.query(u'Stop Calc', 'query', None, u'Yes', u'No'): return 0 elif score in (['%d'%x for x in range(70, 101)]+['A', 'a']): tcp+=5*unit break elif score in (['%d'%x for x in range(60, 70)]+['B', 'b']): tcp+=4*unit break elif score in (['%d'%x for x in range(50, 60)]+['C', 'c']): tcp+=3*unit break elif score in (['%d'%x for x in range(46, 50)]+['D', 'd']): tcp+=2*unit break elif score in (['%d'%x for x in range(40, 46)]+['E', 'e']): tcp+=unit break elif score in (['%d'%x for x in range(40)]+['F', 'f']): break else: ui.note(u'invalid score', 'error') gpa=tcp/tnu if not ui.query(u'ur GPA is: %.3f'%gpa, 'query', None, u'continue', u'stop'): break __comments(gpa) return [tnu, tcp]
def login(self): user=ui.query(u'enter username:'******'text') if not user: return 1 else: user=user.lower() if user not in self.db.keys(): ui.note(u'username does not exist', 'error') return 0 passw=ui.query(u'enter password:'******'code') if not passw: return 0 else: if passw!=self.db[user]: ui.note(u'incorrect password', 'error') return 0 else: self.passw=passw ui.note(u'Welcome') return self.user_data(user)
def logout(): ui.note(u'Goodbye') a.close()
def success(text): appuifw.note(unicode(text), 'conf')
def get_shortcuts(cls): menu = old_get_shortcuts() menu.append(ui.MenuItem(_('Description for func'), target=func)) menu.append(ui.MenuItem(_('Bla-bla-bla'), target=lambda:aw.note(u'Bla-bla-bla'))) return menu
return picPath def fetchPicImage(self): picImage = 1 try: picImage = graphics.Image.open(self.fetchPic()) return picImage except Exception, e: printException(Exception, e) del picImage try: if os.path.exists(self.picPath): os.remove(self.picPath) except Exception, e: printException(Exception, e) appuifw.note(cn('出现问题,图片加载错误。请浏览日志文件。')) return graphics.Image.open(sys.path[0] + '\\pic\\pic.bmp').resize( (self.picSize, self.picSize)) def fetchSong(self): #根据当前播放的歌曲,返回音频文件的路径,有必要时下载 logs('Start Fetching Song') songPath = 'e:\\netease\\%s_%s.mp3' % ( self.listdetail[self.songIndex]['id'], self.br) if not os.path.exists(songPath): strList = [ cn('下载歌曲 ') + cn(self.listdetail[self.songIndex]['name']), cn('目标') + cn(songPath.split('\\')[-1]) ] strList2 = [cn('写入文件')] download(self.listdown[self.songIndex], songPath,
def hand(rect): can.blit(img) lock=e32.Ao_lock() can=ui.Canvas(redraw_callback=hand) ui.app.screen='full' ui.app.body=can #thread.start_new_thread(tr, ()) ui.app.exit_key_handler=lock.signal lock.wait() def dresscode(): global a, b topc=['red', 'yellow', 'green', 'blue', 'black', 'wine', 'brown', 'white', 'grey', 'pink', 'orange'] troc=['white', 'black', 'striped', 'blue_jean', 'black_jean'] a=random.choice(topc) b=random.choice(troc) #c=random.choice(color_list) result=u'TOP: %s\nTROUSERS: %s\n\nyou like it?' %(a, b) a, b=eval(a), eval(b) viewit(a, b) ans=msgquery.infopopup(result, u'Dress Code Result:', msgquery.OKRCancel) return ans getting=dresscode() while not getting: getting=dresscode() else: ui.note(u'you made a wonderful selection !', 'conf') getting=0 viewit(a, b)
def la(): ui.note(u'ADIO Kingsley O\n(c) June 2011\n\[email protected]')
def set_speech(): try: e32.start_exe('z:\\sys\\bin\\ttsmanager.exe', '') except: appuifw2.note(u'Unable to Open', 'error')
elif self.isvalidsobj() is 2: self.soundposition=self.soundobj.current_position() self.soundobj.stop() self.changedata([(1,self.soundposition)]) appuifw2.app.title=u"Pause:" else: self.isvalidfile(path,navi_title,uipos=pos,manual=True) def isvalidfile(self,path,navi_title,uipos=0,soundposition=0L,manual=False): try: if manual: self.backupobj=audio.Sound.open(path) else: self.soundobj=audio.Sound.open(path) except: appuifw2.note(u"file corrupt,or file not exists!","error") return self.continuework(path,navi_title,uipos,soundposition,manual) def close(self): try: self.soundobj.close() except:self.soundobj=None def isvalidsobj(self): try: return self.soundobj.state() except:return False def nextitem(self): if self.allmark[0]>=self.amount-1:
#improved ! #now with static and #dynamic GPA calculators import e32, os import appuifw2 as ui from graphics import * from camera import _main_pane_size as pixels #app_lock=e32.Ao_lock() ui.app.title=u'myGPCalc' ui.app.screen='normal' img=Image.open(os.path.dirname(ui.app.full_name())+'\\me.jpg') img=img.resize(pixels()) ui.note(u'my GPA Calculator\namplified...') def handle_redraw(rect): canvas.blit(img) canvas=ui.Canvas(event_callback=None, redraw_callback=handle_redraw) ui.app.body=canvas def static(): noc=ui.query(u'total no of courses taken:', 'number') if not noc: ui.note(u'no course taken') return 1 iter=0 tnu=0
def static(): noc=ui.query(u'total no of courses taken:', 'number') if not noc: ui.note(u'no course taken') return 1 iter=0 tnu=0 tcp=float(0) while iter<noc: while True: unit=ui.query(u'enter course unit:', 'number') if unit==0: ui.note(u'a value is required') elif not unit: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 else: break tnu+=unit while True: score=ui.query(u'enter score or grade:', 'text') if not score: if ui.query(u'exit GPCalc', 'query', None, u'Yes', u'No'): return 1 elif score in (['%d'%x for x in range(70, 101)]+['A', 'a']): tcp+=5*unit break elif score in (['%d'%x for x in range(60, 70)]+['B', 'b']): tcp+=4*unit break elif score in (['%d'%x for x in range(50, 60)]+['C', 'c']): tcp+=3*unit break elif score in (['%d'%x for x in range(46, 50)]+['D', 'd']): tcp+=2*unit break elif score in (['%d'%x for x in range(40, 46)]+['E', 'e']): tcp+=unit break elif score in (['%d'%x for x in range(40)]+['F', 'f']): break else: ui.note(u'invalid score', 'error') iter+=1 GPA=tcp/tnu if not ui.query(u'ur GPA is: %.3f'%GPA, 'query', None, u'ok', u'comments'): if 5.0>=GPA>=4.5: ui.note(u'FIRST CLASS\nwhao! keep it up', 'info') elif 4.5>GPA>=3.5: ui.note(u'SECOND class, UPPER division\nur best is yet to come') elif 3.5>GPA>=2.5: ui.note(u'SECOND class, LOWER division\nu can do beta') elif 2.5>GPA>=1.5: ui.note(u'THIRD class\nput in more effort') elif 1.5>GPA>=1.0: ui.note(u'This is just a PASS result') else: ui.note(u'u are advised to WITHDRAW')
def la(): ui.note(u'ADIO Kingsley O\n(c) 2011 ADIKSonline\[email protected]')
def __comments(GPA): if 5.0>=GPA>=4.5: ui.note(u'FIRST CLASS\nwhao! keep it up', 'info') elif 4.5>GPA>=3.5: ui.note(u'SECOND class, UPPER division\nur best is yet to come') elif 3.5>GPA>=2.5: ui.note(u'SECOND class, LOWER division\nu can do beta') elif 2.5>GPA>=1.5: ui.note(u'THIRD class\nput in more effort') elif 1.5>GPA>=1.0: ui.note(u'This is just a PASS result') elif 1.0>GPA>=0.0: ui.note(u'u are advised to WITHDRAW') else: ui.note(u'unrecognized gradepoint') return 1
def error(text): appuifw.note(unicode(text), 'error')
def ma(): ui.note(u'VERSION: 1.3')
def alert(text): appuifw.note(unicode(text), 'info')
def a(x): appuifw.note(txt[x] + cn("大白痴"))
def s_7(): if len(s_45.get_selection()[2]) == 0: appuifw.note(ru('未标记文字!'), 'error') else: s_45.copy()