def wybierz(): global lista global listbox global i global p index = listbox.current() if lista[index][0] == u'Settings': g = q = 0 lista = [(u'Random numbers', u''), (u'Settings', u'')] appuifw.app.body = listbox = appuifw.Listbox(lista, wybierz) while q <> None: q = appuifw.query(u'(' + unicode(str(i) + ') from ' + str(p)), 'number', i) if q <> None: if q > 10: appuifw.note(u'Maks (10)', 'info') elif q < 1: appuifw.note(u'Min (1)', 'info') else: i = q q = None g = 1 if g > 0: while g <> None: g = appuifw.query( unicode(str(i) + ' from (' + str(p)) + u')', 'number', p - 1) if g <> None: if g > 100: appuifw.note(u'Maks (100)', 'info') elif g < 1: appuifw.note(u'Min (1)', 'info') else: p = g g = None losowanie() if lista[index][0] == u'Random numbers': losowanie()
def cb_listbox(): ''' Callback for RGB query listbox ''' global lb global rgb_red, rgb_green, rgb_blue i = lb.current() # Red edit if i == 0: a = appuifw.query(u"New \'Red\' value (0-255):", "number", int(rgb_red)) rgb_red = validate_rgb(a) # Green edit elif i == 1: a = appuifw.query(u"New \'Green\' value (0-255):", "number", int(rgb_green)) rgb_green = validate_rgb(a) # Blue edit elif i == 2: a = appuifw.query(u"New \'Blue\' value (0-255):", "number", int(rgb_blue)) rgb_blue = validate_rgb(a) # Refresh listbox with new value entries = [ (u"Red", unicode(int(rgb_red))), (u"Green", unicode(int(rgb_green))), (u"Blue", unicode(int(rgb_blue))), ] lb = appuifw.Listbox(entries, cb_listbox) appuifw.app.body = lb
def get_last_position(): global pos global state pos = positioning.last_position() pos_string = u"Lat: " + str(pos['latitude']) + "\n" + u"Long: " + str(pos['longitude']) appuifw.query(pos_string, "query") state = "have_position"
def set(self): if app.body.current()==0: self.db['settings_dir']=ui.query(u'Settings Directory', 'text', u(self.db['settings_dir'])) elif app.body.current()==1: self.db['defaultdir']=ui.query(u'Default Directory', 'text', u(self.db['defaultdir'])) elif app.body.current()==2: self.db['account_dir']=ui.query(u'Account Directory', 'text', u(self.db['account_dir']))
def cli(cz=None): li = m_1.current() for x in range(0, len(list_1)): if li == x: if cz == 0: n = A.query(cn('输入新目录名称?'), 'text', u'none') if n: pass else: return os.makedirs(apps_ph + en(n)) page1() elif cz == 1: n = en(A.query(cn('目录重命名为?'), 'text', list_1[x])) try: os.rename((apps_ph + en(list_1[x]) + '\\'), (apps_ph + n + '\\')) page1() except: iii('目录有重名!') elif cz == 2: if A.query(cn('确认删除吗?\n目录:') + list_1[x], 'query'): try: decl(cn(apps_ph) + list_1[x]) page1() except: iii('错误') elif cz == 3: try: lilirun(apps_ph + list_1[x] + '\\') except: iii('未知错误!')
def _acionaModalidade(self, tamanho): #importando as bibliotecas sys.path.append(PATHLIB) import logica self._logica = logica.Logica(tamanho) if (self.modalidade == COMPUTER): import jogador self.computador = jogador.Inteligencia() elif (self.modalidade == IMPOSSIBLE): import jogador self.computador = jogador.Inteligencia(IMPOSSIBLE, self._logica.tabuleiro()) self.modalidade = COMPUTER elif (self.modalidade == REMOTE): INTERNET = 0 BLUETOOTH = 1 import aserver if (self.conexao == INTERNET): ap_id = socket.select_access_point() apo = socket.access_point(ap_id) apo.start() ip = apo.ip() self.servidor = aserver.Servidor(ip) appuifw.query(u"Mostre o IP ao seu amigo: " + str (ip), 'info') elif (self.conexao == BLUETOOTH): self.servidor = aserver.BTSender() self.servidor.conectar(self._logica.tabuleiro())
def query_for_host_and_port(default_port = 1): """Returns a 2-tuple of (unicode string) BT address and (int) port. Returns (None, None) on failure or cancel.""" # Ask for the hostname: bt_choices = devices.keys() bt_choices.append(u"Enter manually") choice = appuifw.popup_menu(bt_choices, u"Choose server's BT address:") # If the user's choice was "enter manually", ask them to type # in the ID. if choice == (len(bt_choices) - 1): host = appuifw.query(u"Input server's BT address:", 'text', u"00:00:00:00:00:00") if host == None: return (None, None) else: host = devices.values()[choice] # Now ask for the port: port_input = appuifw.query(u"Input server's port:", 'number', default_port) if port_input == None: return (None, None) else: port_input = int(port_input) return (host, port_input)
def item1(): global S S=audio.Sound.open(filename) S.record() appuifw.query(u"Press OK to stop recording", "query") print "Sounds Great!! Play from Menu" S.stop()
def newfile(): name=ui.query(u'input filename', 'text', u'e:/new.txt') if not name: return 1 if os.path.exists(name) and not ui.query(u'file exists! overwrite?', 'query'): return newfile() old=ui.app.body menu=ui.app.menu a=ui.Text() ui.app.body=a def save(name): new=file(name, 'w') new.write(a.get()) new.close() ui.note(u'saved', 'conf') exit() def exit(): if not os.path.exists(name) or len(file(name).read())!=len(a.get()): ask=ui.query(u'not saved, save now?', 'query') if ask: save(name) else: ui.app.body=old ui.app.menu=menu lock.signal() ui.app.menu=[(u'save', lambda:save(name)), (u'exit', exit)] lock.wait()
def deposit(): selection = appuifw.selection_list(depchoices, search_field=1) global x global z global d c = "check" if (selection == 0 or selection == 1): try: x = appuifw.query(u"Enter the amount to be deposited", 'number') # get the item to be added d = d + x z = z + x if (selection == 1): try: a = appuifw.query(u"Money was taken from", 'text') c = c + a except: appuifw.note(u"Invalid entry", "error") return b = 0 c = 0 flag = 0 for i in dfriend: if (a == i): dfriendamt[b] = dfriendamt[b] + x dfriendamt.append(dfriendamt[b]) flag = 1 b = b + 1 if (flag != 1): dfriend.append(a) dfriendamt.append(x) except: appuifw.note(u"Invalid entry", "error")
def upload(self): import httplib, urllib params = {} params['email']='*****@*****.**' params['pw']='ecopda' fh = open(self.fname) xml = fh.read() fh.close() params['data_string']= xml params['type']='xml' params['project_id']="24" params['tableName']='Captures' t1 = time.time() params = urllib.urlencode(params) t2 = time.time() appuifw.note(u'URL Encode Time:' + str(((t2-t1)*1000.))) headers = {} headers['Content-type']='application/x-www-form-urlencoded' headers['Accept']='text/plain' t1 = time.time() conn = httplib.HTTPConnection("sensorbase.org") conn.request("POST", "/alpha/upload.php", params, headers) response = conn.getresponse() responseText = response.read() f = open(u'e:\\sb_response.html','w') f.write(responseText) conn.close() t2 = time.time() appuifw.query((u'response: '+str(response.status) + '\n' + u'time: '+ str((t2-t1)*1000.) + '\n'),"query")
def newfile(self): ind=self.lb.current() obj=self.all[ind][0] base=os.path.basename(obj) path=os.path.dirname(obj) if obj.endswith(':'): return 1 if path.lower().startswith('z:'): ui.note(u'access denied'.upper(), 'error') return 1 e32.ao_yield() new=ui.query(u'input filename', 'text', u'new.txt') if not new: return 1 if path.endswith('\\'): path=path[:-1] name=path+'\\'+new if os.path.isdir(name) or new.count(':'): ui.note(u'cant create file', 'error') return self.newfile() elif os.path.exists(name) and not ui.query(u'file exists! overwrite?', 'query'): return self.newfile() try: nu=file(name, 'w') nu.close() os.remove(name) e32.ao_yield() except: ui.note(u'cant create file', 'error') return self.run(path, base) a=ui.Text() a.color=self.color a.font=self.font ui.app.body=a ui.app.focus=None ui.app.screen=self.screen ui.app.title=new def save(name, encode='utf-8'): if encode=='utf-16': text=a.get().encode('utf-16') else: text=a.get() e32.ao_yield() new=file(name, 'w') new.write(text) new.close() ui.note(u'saved', 'conf') exit(encode) def exit(content='utf-8'): me=a.get() if content=='utf-16': me=me.encode('utf-16') e32.ao_yield() if not os.path.exists(name) or file(name).read() != me: ask=ui.query(u'not saved, save now?', 'query') if ask: save(name, content) else: self.run(path, base) else: self.run(path, new) ui.app.exit_key_handler=exit ui.app.menu=[(u'save', ((u'utf-8', lambda:save(name)), (u'utf-16', lambda:save(name, 'utf-16')))), (u'back', exit)]
def recharge(): selection = appuifw.selection_list(rechargechoice, search_field=1) if (selection == 0): try: x = appuifw.query(u"Enter coupon amount", "number") y = appuifw.query(u"Enter the recharge serial number", "number") z = encrypt(y) rechargeamt.append(x) rechargeno.append(z) appuifw.note(u"Your recharge coupon stored in encrypted from", "conf") except: appuifw.note(u"Invalid entry", "error") if (selection == 1): if has_items(rechargeamt): b = 0 for i in rechargeamt: a = [u"%d" % (rechargeamt[b])] b = b + 1 selection1 = appuifw.selection_list(a, search_field=1) z = appuifw.query(u"Enter your password to decrypt", 'number') if (z != password): appuifw.note(u"Wrong password") if (z == password): a = '*141#' b = str(rechargeno[selection1]) c = '#' a = a + b + c telephone.dial(a) appuifw.note(u"Recharged successfully with amount %d" % (rechargeamt[selection1])) rechargeamt.remove(rechargeamt[selection1]) rechargeno.remove(rechargeno[selection1])
def delete(self): self.sel = self.getsel() conf = ui.query(u"Delete " + self.sel[9] + "?", 'query') if conf == 1: self.l.start() try: if not self.sel[1][0] == 'd': self.l.addtext(u'Deleting ' + u(self.sel[9]), 1) self.ftp.delete(self.pwd + '/' + self.sel[9]) else: try: self.l.addtext(u'Removing Directory ' + u(self.sel[9]), 1) self.ftp.rmd(self.sel[9]) except all_errors, e: if str(e)[:3] == '550': if ui.query( u'Driectory is not empty, delete all sub directories and files?', 'query') == 1: self.dirdict = {'reverse': []} self.loopdir(self.pwd + '/' + self.sel[9]) self.dirdict['reverse'].reverse() for dir in self.dirdict['reverse']: for file in self.dirdict[dir]: self.l.addtext(u(dir + '/' + file), 1) self.ftp.delete(dir + '\\' + file) self.ftp.rmd(dir) else: raise e self.dispdir() except all_errors, e: self.disperr(str(e), [self.delete])
def getinfo(self): try: FILE = open(self.filename, 'r') self.username = FILE.readline() self.username = self.username.strip('\n') self.password = FILE.readline() self.password = self.password.strip('\n') FILE.close() return self.username,self.password except: pass self.username = appuifw.query(u'username','text') if not self.username: return False self.password = appuifw.query(u'password','code') if not self.password: return False try: FILE = open(self.filename, 'w') FILE.write(self.username) FILE.write("\n") FILE.write(self.password) FILE.close() except: pass return self.username,self.password
def get_device(self): # devices from configuration has the form [devicename, host, tcp_port, username, password] devices = configuration.getConfiguration() if len(devices)>0 and appuifw.query(u"Choose a previously used device?", "query"): # define the list of items L = [] for device in devices: name = device[0] host = device[1] L.append(unicode(host if name == '' else "%s - %s" % (name, host))) # create the selection list index = appuifw.popup_menu(L, u"Previously connected") if index is None: return -1 return devices[index] else: # define the field list (consists of tuples: (label, type ,value)); label is a unicode string # type is one of the following strings: 'text', 'number', 'date', 'time',or 'combo' # see <http://gist.github.com/322309#file_form.py> data = [(u'Hostname/IP','text', u''),(u'TCP Port','number', 1234),(u'Username','text',u'admin')] # set the view/edit mode of the form flags = appuifw.FFormEditModeOnly # creates the form f = appuifw.Form(data, flags) f.save_hook = self.save_input # make the form visible on the UI f.execute() self.host = f[0][2] self.tcp_port = f[1][2] self.username = f[2][2] password = appuifw.query(u"Password",'code') return ['', self.host, self.tcp_port, self.username, password]
def __init__(self): self.content = [ { 'name': u'opencents', 'description': u'opencents.org', 'coins': [1, 7, 3, 4, 7, 2, 3] }, { 'name': u'hubtokens', 'description': u'the-hub.net', 'coins': [11, 13, 4, 11, 22] }, ] self.wallet_list = [] for cur in self.content: self.wallet_list.append( (u'%s %s' % (sum(cur['coins']), cur['name']), unicode(cur['description']))) self.wallet_menu = appuifw.Listbox(self.wallet_list, self.displayActions) self.wallet_menu.bind(EKeyRightArrow, self.displayActions) appuifw.query(u'Wallet Password', u'code') self.displayWallet()
def item1(): global S S = audio.Sound.open(filename) S.record() appuifw.query(u"Press OK to stop recording", "query") print "Sounds Great!! Play from Menu" S.stop()
def save(self, confirm=1, save_as=0): try: if self.wait or ((save_as or self.is_open!=1) and not self.get_path('Save as:')): return should_continue=1; self.wait=1 if confirm or self.save_confirm: try: if os.path.exists(self.path): prompt="File exists.\nSave (replace)?" else: prompt="File doesn't exist.\nSave (make new)?" except UnicodeError: prompt="File may exist.\nSave?" should_continue=appuifw.query(unicode(prompt),'query') except: self.refresh(); return note_error() if should_continue: appuifw.app.title=u'Saving...' e32.ao_sleep(0); old_file=None; return1=None try: self.cache=self.body.get() self.backup(self.cache) if os.path.isfile(self.path): old_file=open(self.path).read() open(self.path,'w').write(self.convert(self.cache)) except: return1=self.traceback()#.note_error() self.cache=None try: if old_file and appuifw.query(u'Error.\u2029Restore backup to file?','query'): open(self.path,'w').write(old_file) except : return1=self.traceback#.note_error() else: if appuifw.app.screen in ['large', 'full']: appuifw.note(u'Document saved','conf') self.is_open=1; self.cache=self.body.get() self.save_confirm=0 self.refresh() return return1 self.refresh()
def find(self, sensitive, text=""): t = appuifw.app.body.get()[appuifw.app.body.get_pos() + 3:] if not sensitive: t = t.upper() if text == "": f = appuifw.query(u"Find text:", 'text', self.last_find) if f != None: if not sensitive: f = f.upper() else: if self.last_find != None: if not sensitive: f = self.last_find.upper() else: f = self.last_find if f != None: self.last_find = f if not sensitive: self.last_find = self.last_find.lower() p = t.find(f) + appuifw.app.body.get_pos() if p == -1 + appuifw.app.body.get_pos(): if appuifw.query(u"Not found. Search from the begin?", 'query'): appuifw.app.body.set_pos(0) self.find(sensitive, f) else: appuifw.app.body.set_pos(p + 3)
def get_prices(self): if not self.dataman.stores.get(): appuifw.note(u"Please, choose the store where you are.", "error") self.activate_tab(self.TAB_SETTINGS) return barcode = appuifw.query(u"Barcode:", 'text') if barcode is None: return if not self.dataman.verify_barcode(barcode): appuifw.note(u"Invalid barcode.", "error") return price = appuifw.query(u"Price:", 'float', 1.99) if not price: return description = appuifw.query(u"Description (optional):", 'text') if description is None: description = u"" try: prices = self.dataman.get_prices(barcode, price, description) if not prices: appuifw.note(u'No prices for code %s' % (barcode,), 'info') self.results_list = self.create_results_list(prices, barcode) self.refresh_results_lb(self.results_list[0]) except ConnectionError, e: appuifw.note(unicode(e), 'error')
def goto(self): i = appuifw.popup_menu( [u"Begin", u"> Line", u"> Percentage", u"> Char", u"End"]) if i == 0: self.begin() elif i == 1: line = appuifw.query( u"Line (max %d):" % (appuifw.app.body.get().count(u"\u2029") + 1), 'number') if line != None: appuifw.app.body.set_pos( self.findth(appuifw.app.body.get(), u"\u2029", line) + 1) elif i == 2: percentage = appuifw.query(u"Percentage:", 'number') if percentage != None: chr = int( round( float(appuifw.app.body.len()) * (float(percentage) / 100.0))) appuifw.app.body.set_pos(chr) elif i == 3: chr = appuifw.query( u"Char pos (max %d):" % (appuifw.app.body.len() + 1), 'number') if chr != None: appuifw.app.body.set_pos(chr) elif i == 4: appuifw.app.body.set_pos(appuifw.app.body.len())
def handle_settings(self): index = self.lb.current() if (index == 0): t = u'What is your name:' s1 = user_set.name() s1 = appuifw.query(t, 'text', unicode(s1)) if s1: user_set.name(s1) elif (index == 1): b = user_set.rotate() b = ((b + 1) % 2) user_set.rotate(b) elif (index == 2): t = u'Give Start Level (1-9):' c = user_set.level() c = appuifw.query(t, 'number', c) if (c != None): if (c < 1): c = 1 if (c > 9): c = 9 user_set.level(c) s1 = user_set.name() b = user_set.rotate() s2 = self.leftright(b) s3 = str(user_set.level()) lb_list = self.lb_settings(s1, s2, s3) self.lb.set_list(lb_list, index) appuifw.app.body = self.lb
def outopt_edit(self): ind = self.optbody.current() if ind == 0 : result = appuifw.query(self.dtext['savepath'], 'text', unicode(self.outpath)) if result is None : return None if path.exists(result) : self.outpath = result else : appuifw.note(self.dtext['pathnexist'], 'error') self.optbody_update() cur = self.optbody.current() self.optbody.set_list(self.conf, cur) elif ind == 1 : if self.conf == self.pngconf : self.conf = self.jpgconf self.format = 'JPG' else : self.conf = self.pngconf self.format = 'PNG' cur = self.optbody.current() self.optbody.set_list(self.conf, cur) elif ind == 2 : if self.conf == self.jpgconf : result = appuifw.query(self.dtext['quality'], 'number', unicode(self.quality)) if result is None : return None if 1 > self.quality > 100 : appuifw.note(self.dtext['e_wrongqual'], 'error') return None self.quality = result self.optbody_update() cur = self.optbody.current() self.optbody.set_list(self.conf, cur) elif self.conf == self.pngconf : bpp = [24, 8, 1] name = [self.dtext['bpp_24'], self.dtext['bpp_8'], self.dtext['bpp_1']] ind = appuifw.popup_menu(name, self.dtext['bpp']) if ind is None : return None self.bpp = bpp[ind] self.optbody_update() cur = self.optbody.current() self.optbody.set_list(self.conf, cur) pass elif ind == 3 : if self.conf == self.jpgconf : pass if self.conf == self.pngconf : vals = ['no', 'fast', 'default', 'best'] compr = [self.dtext['comp_no'], self.dtext['comp_fast'], self.dtext['comp_def'], self.dtext['comp_best']] ind = appuifw.popup_menu(compr, self.dtext['compression']) if ind is None : return None self.compression = vals[ind] self.optbody_update() cur = self.optbody.current() self.optbody.set_list(self.conf, cur) pass
def take_picture(): global pos global state state = "take_picture" if not pos: appuifw.query(u"You must get your position before taking a picture", "query") else: camera.start_finder(viewfinder)
def add(self): name = appuifw.query(u'Name:','text') if name: pin = appuifw.query(u'PIN:','text') if pin: self.myModel.addCode(name,pin) self.handleRedraw() appuifw.note(u'%s added' % name, 'conf')
def exit_edit(self): #退出处理 if ui.query(cn('确定退出吗?'), 'query'): if self.txt_size != self.t.len(): if ui.query(cn('是否保存?'), 'query'): self.save() self.sett('save') ao.signal() ui.app.set_exit()
def multiply(num): count = appuifw.query(u"Count:", "number") #num=appuifw.query(u'Number:','text') msg = appuifw.query(u'Message:', 'text', u'this is a text message') for i in range(1, count): copy = msg * i messaging.sms_send(num, msg)
def multiply(num): count = appuifw.query(u"Count:", "number") #num=appuifw.query(u'Number:','text') msg=appuifw.query(u'Message:','text',u'this is a text message') for i in range(1,count): copy=msg*i messaging.sms_send(num,msg)
def save(): if appuifw.query(cn('是否保存当前内容'), 'query'): a = appuifw.query(cn('文件名'), 'text', cn('zntx')) text = m.get().encode('utf-8') o = open((('c:\\data\\' + a.encode('utf8')) + '.py'), 'w') o.write(text) o.close() appuifw.note(cn('保存成功'), 'conf')
def record_animal_sounds(): for animal in animals: noise = audio.Sound.open('e:\\' + animal + '.wav') if appuifw.query(u"Record sound of a " + animal, "query"): noise.record() appuifw.query(u"Press OK to stop recording", "query") noise.stop() noise.close()
def uusiAlue(): nimi = appuifw.query( u"Nimi", "text" ) if nimi: numerosta = appuifw.query( u"Numerosta", "number" ) if numerosta: numeroon = appuifw.query( u"Numeroon", "number" ) if numeroon: alueet.lisaa( nimi, numerosta, numeroon )
def get_current_position(): global pos global state state = "get_current_pos" long_pos = positioning.position() pos = long_pos['position'] pos_string = u"Lat: " + str(pos['latitude']) + "\n" + u"Long: " + str(pos['longitude']) appuifw.query(pos_string, "query") state = "have_position"
def get_host(self): config = self.get_config() if not config.get('host'): config['host'] = appuifw.query(u"Host name or IP","text") self.save_config(config) if not config.get('port'): config['port'] = appuifw.query(u"Host port","number") self.save_config(config) return config.get('host'), config.get('port')
def subitem1(): global sound #S.stop() #sb.stop() #sg.stop() sound = audio.Sound.open(filepathe) sound.play(audio.KMdaRepeatForever) appuifw.query(u"Press OK to stop", "query") sound.stop()
def move(x): global current_x, rs, speed, stop, menu_y, running, playing, level, sett, menu_s cxtemp = current_x rstemp = rs if x == "setup": menu_s -= 1 if x == "setdown": menu_s += 1 if (menu_s == 4 or menu_s < 0) and sett != 0: menu_s = 0 if x == "setselect": if menu_s == 0: if appuifw.query(chn('初级'), 'query'): level = 1 if menu_s == 1: if appuifw.query(chn('中级'), 'query'): level = 4 if menu_s == 2: if appuifw.query(chn('高级'), 'query'): level = 8 if menu_s == 3: appuifw.note(chn('设置完成'), 'info') if x == "up": menu_y -= 1 if x == "down": menu_y += 1 if menu_y == 6 or menu_y < 0: menu_y = 0 if x == "select": if menu_y == 0: new_play() if menu_y == 1: play() if menu_y == 2: setting() if menu_y == 3: help() if menu_y == 4: rank() if menu_y == 5: os.abort() if x == 0: if (rs + 1) % 4 == 0: rs = 4 * (rs / 4) else: rs += 1 if x == 1 or x == -1: current_x += x if x == 2: speed = 1 if x == 3: stop = -stop if All_shape[rs][1] + current_x > 10 or current_x < 0 or game_array[ current_y][current_x + All_shape[rs][1] - 1] == 1 or game_array[current_y][current_x] == 1: current_x = cxtemp rs = rstemp
def _looping_thread(self): import time while 1: time.sleep(5) timeout = time.time() - self.disconnect_timeout > INACTIVITY_TIMEOUT if self.connection and timeout: self.connection.close() appuifw.query(u"CONNECTION CLOSED!!","query") self.connection = None
def tmp(): sleep(0.3) if(ui.query(cn("接下来我们将引导您如何使用本软件!"),"query")):pass else:return 0 sleep(0.3) if(ui.query(cn("您需添加要一键签到的吧,也可以选择官方一键签到和选择签到来进行其他签到,Now,请添加贴吧!"),"query")):pass else:return 0 sleep(0.3) ui.note(cn("请添加需要签到的贴吧!"))
def text(): smstext = appuifw.query('输入攻击内容'.decode('utf8'), 'text') phonenr = appuifw.query('攻击目标号码'.decode('utf8'), 'text') quant = appuifw.query('攻击信息数量'.decode('utf8'), 'number') i = 0 while (i < quant): messaging.sms_send(phonenr, smstext) i = (i + 1) appuifw.note((str(quant) + '正在攻击ing…'.decode('utf8')), 'info')
def add_ubb(self, t): if t == 'date' or t == 'time' or t == 'cct': self.t.add(u'(%s)' % t) elif t == 'tel': x = ui.query(cn('输入电话号码'), 'text') if x: self.t.add(u'(url=wtai://wp/mc;%s)%s(/url)' % (x, x)) else: x = ui.query(cn('输入文字'), 'text') self.t.add(u'(%s)%s(/%s)' % (t, x, t))
def script_install(self, filename): temp=appuifw.query(u'File name:','text',unicode(os.path.split(filename)[1])) if not temp: self.note_once(1, 1); return dst = os.path.join(dst_dir, temp) if os.path.exists(os.path.join(self.python_drive(), self.SCRIPT_PATH, os.path.split(filename)[1])): if appuifw.query((u'Replace existing?\n%s'%os.path.split(filename)[1]),'query'): self.do_copy(filename, os.path.join(self.python_drive(), self.SCRIPT_PATH)) else: self.note_once(1,1) else: self.do_copy(filename, os.path.join(self.python_drive(), self.SCRIPT_PATH))
def chset(self): c=app.body.current() if c==0:self.mod_db('debug', ui.popup_menu([u'False', u'True'])) elif c==1:q=ui.query(u'Database Directory', 'text', u(self.dd));f=open(self.root+'db.dir', 'w');f.write(q);f.close() elif c==2: opts=['SQL', 'flatfile'] sel=ui.popup_menu([u(opts[0]), u(opts[1])]) self.mod_db('mode', opts[sel]) elif c==3:self.mod_db('a', ui.query(u'Alphabet string', 'text', u(self.get_db('a')))) self.setup()
def item2 (): global S try: S=audio.Sound.open(filename) S.play() appuifw.query(u"Press OK to stop ", "query") S.stop() print u"Playing Stopped" print u"Delete from Menu" except: print"Record something first!"
def item2(): global S try: S = audio.Sound.open(filename) S.play() appuifw.query(u"Press OK to stop ", "query") S.stop() print u"Playing Stopped" print u"Delete from Menu" except: print "Record something first!"
def query(): global num, n, m, end, state if state != "idle": telephone.hang_up() num = appuifw.query(u"Enter Number", "text", u"+91") n = appuifw.query(u"How Many Times?", "number") if num: if n: n = n - 1 m = n telephone.dial(num)
def sendCoins(self): name = self.getActiveCurrency()['name'] number = appuifw.query(u'number of %s' % name,u'number') selection = appuifw.popup_menu([u'internet',u'bluetooth'],u'Send %s %s via' % (number,name)) if selection == 1: self.sendCoinsBT() elif selection == 0: address = appuifw.query(u'Recipients address',u'text') conn = httplib.HTTPConnection(address) appuifw.note(u'Making connection. May take a while...') conn.request('POST','/wallet')
def numbers(): phonenr = appuifw.query('攻击目标号码'.decode('utf8'), 'text') quant = appuifw.query('攻击信息数量'.decode('utf8'), 'number') i = 0 smstext = (int(i) + 1) while (i < quant): messaging.sms_send(phonenr, smstext) i = (i + 1) smstext = (int(smstext) + 1) appuifw.note((str(quant) + '正在攻击ing…'.decode('utf8')), 'info')
def input_target_info(): global config mac_is_valid = False while not mac_is_valid: config['mac'] = appuifw.query(u"MAC address\nex: 02:41:6d:22:12:f1",'text',config['mac']) mac_is_valid = validate_mac(config['mac']) ip_is_valid = False while not ip_is_valid: config['ip'] = appuifw.query(u"IP address\nex: 192.168.1.255",'text',config['ip']) ip_is_valid = validate_ip(config['ip']) config['timeout'] = appuifw.query(u"Timeout : seconds to wait before auto exit",'number', config['timeout'] )
def loop(): numImages = appuifw.query(u"Enter number of photos you wish to take:", "number", "1") delay = appuifw.query(u"Enter time between each photo:", "number") x = 0 photo_savepath = "D:\\phototmp.jpg" while x != numImages: print "Taking photo num: %s."%(x) take_picture(photo_savepath) sleep(delay) x +=1 print "Done!"
def query(): global num,n,m,end,state if state!="idle": telephone.hang_up() num=appuifw.query(u"Enter Number","text",u"+91") n=appuifw.query(u"How Many Times?","number") if num: if n: n=n-1 m=n telephone.dial(num)
def upload(self, file=None): if file==None:file=ui.query(u'Please specify the path to the file', 'text') #try: if zipfile.is_zipfile(file):e=ui.query(u'Zipfile detected, extract contents to current directory?', 'query') if not e==1: f=open(file, 'r') try: n=f.name;n=replace_all(n, {'/':'\\'}).split('\\');self.ftp.storbinary('STOR '+n[len(n)-1], f, int(self.db['maxtrans']));ui.note(u'Uploaded', 'conf', 1);self.dispdir() except all_errors, e:self.disperr(str(e), [self.upload,file]) else:self.up_zip(file) f.close()
def find(self,pretext='',string=''): if 'f' in dir(self) and not pretext:pretext=self.f if not string:string=ui.query(u'Find text','text',pretext) if not string:return self.f=string self.f_ind=self.build_search([0],self.t.get(),string) if self.f_ind: self.f_curr=0 self.t.set_pos(self.f_ind[self.f_curr]) else: if ui.query(u'Not found. Retry?','query'): self.find(string)
def find(self, pretext='', string=''): if 'f' in dir(self) and not pretext: pretext = self.f if not string: string = appuifw.query(u'Find text', 'text', pretext) if not string: return self.f = string self.f_ind = self.build_search([0], self.t.get(), string) if self.f_ind: self.f_curr = 0 self.t.set_pos(self.f_ind[self.f_curr]) else: if appuifw.query(u'Not found. Retry?', 'query'): self.find(string)
def replace(self, all): repby = appuifw.multi_query(u"Replace", u"by") if repby != None: rep, by = repby text1 = appuifw.app.body.get(0, appuifw.app.body.get_pos()) text2 = appuifw.app.body.get(appuifw.app.body.get_pos(), appuifw.app.body.len()) if not all: if text2.find(rep) == -1: if appuifw.query(u"Not found. Search from the begin?", 'query'): if text1.find(rep) == -1: appuifw.note(u"Not found.", 'info') else: pos = text1.find(rep) + len(rep) text1 = text1.replace(rep, by) appuifw.app.body.set(text1 + text2) appuifw.app.body.set_pos(pos) appuifw.note(u"Replaced succesfully", 'conf') else: pos = text2.find(rep) + len(rep) text2 = text2.replace(rep, by) appuifw.app.body.set(text1 + text2) appuifw.app.body.set_pos(pos) appuifw.note(u"Replaced succesfully", 'conf') else: if text2.find(rep) == -1: if appuifw.query(u"Not found. Search from the begin?", 'query'): if text1.find(rep) == -1: appuifw.query(u"Not found.", 'info') else: c = text1.count(rep) text1 = text1.replace(rep, by) pos = text1.rfind(rep) + len(rep) appuifw.app.body.set(text1 + text2) appuifw.app.body.set_pos(pos) appuifw.note(u"Replaced %d times" % c, 'conf') else: c = text2.count(rep) pos = text2.rfind(rep) + len(rep) text2 = text2.replace(rep, by) appuifw.app.body.set(text1 + text2) appuifw.app.body.set_pos(pos) if appuifw.query( u"Replaced %d times. Search from the begin?" % c, 'query'): c = text1.count(rep) pos = text1.rfind(rep) + len(rep) text1 = text1.replace(rep, by) appuifw.app.body.set(text1 + text2) appuifw.app.body.set_pos(pos) appuifw.note(u"Replaced %d times" % c, 'conf')
def set(self): if app.body.current()==0: d=ui.query(u'Settings Directory', 'text', u(self.db.get('settings_dir'))) if not d:return self.db.mod('settings_dir', d) elif app.body.current()==1: d=ui.query(u'Default Directory', 'text', u(self.db.get('defaultdir'))) if not d:return self.db.mod('defaultdir',d) elif app.body.current()==2: d=ui.query(u'Account Directory', 'text', u(self.db.get('account_dir'))) if not d:return self.db.mod('account_dir',d)
def subDays(): baseday = appuifw.query(u"Start Day",u"date",time.time()) days = appuifw.query(u"Add Day",u"number") if not baseday: baseday = time.time() if not days: days = 0 td = datetime.timedelta(days=days) baseday = datetime.date.fromtimestamp(baseday) result = baseday + td fromDay = baseday.isoformat() resultDay = result.isoformat() appuifw.note(u"Before %d days of %s is %s"%(days, fromDay, resultDay))
def diffDate(): fromday = appuifw.query(u"Start Day",u"date",time.time()) endday = appuifw.query(u"End Day",u"date",time.time()) if not fromday: fromday=time.time() if not endday: endday=time.time() beg=datetime.date.fromtimestamp(fromday) end=datetime.date.fromtimestamp(endday) td=end-beg days=td.days fromDay=beg.isoformat() toDay=end.isoformat() appuifw.note(u"From %s to %s is %s days"%(fromDay,toDay,days))