def show_log(self): logdir = u'c:\\logs\\cl2\\' try: flist = [ unicode(file) for file in os.listdir(logdir) if file.endswith(".txt") ] except: # The directory not existing will cause an exception that # appears to be quietly consumed, i.e., it is not printed # to the console. flist = [] if len(flist) == 0: appuifw.note(u"No logs to display", "info") return index = appuifw.popup_menu(flist, u'Select file to view') if index is None: return fname = logdir + flist[index] print "opening " + fname doc_lock = e32.Ao_lock() ch = appuifw.Content_handler(doc_lock.signal) ch.open(fname) doc_lock.wait()
def helpDlg(self): progpath = os.path.split(sys.argv[0])[0] if appuifw.app.uid() != UID: # running as a script progpath = progpath[:2] + '/Python' manpage = os.path.join(progpath, 'manual.html').replace('/', '\\') appuifw.note(u(manpage)) appuifw.Content_handler().open(u(manpage))
def show_description(): global desc f = file(DESCRIPTION_FILE, "w") f.write(u"<html><body>%s</body></html>" % desc) f.close() lock = e32.Ao_lock() viewer = appuifw.Content_handler(lock.signal) viewer.open(DESCRIPTION_FILE) lock.wait()
def load(self): haveFix = 0 latitude_in = 0 longitude_in = 0 while self.running: buffer = "" ch = self.sock.recv(1) while (ch != '$'): ch = self.sock.recv(1) while 1: if (ch == '\r'): break buffer += ch ch = self.sock.recv(1) if (buffer[0:6] == "$GPGGA"): try: (GPGGA, utcTime, lat, ns, lon, ew, posfix, sats, hdop, alt, altunits, sep, sepunits, age, sid) = buffer.split(",") latitude_in = float(lat) longitude_in = float(lon) haveFix = int(posfix) except: haveFix = 0 if haveFix: zoom = 2 if ns == 'S': latitude_in = -latitude_in if ew == 'W': longitude_in = -longitude_in latitude_degrees = int(latitude_in / 100) latitude_minutes = latitude_in - latitude_degrees * 100 longitude_degrees = int(longitude_in / 100) longitude_minutes = longitude_in - longitude_degrees * 100 latitude = latitude_degrees + (latitude_minutes / 60) longitude = longitude_degrees + (longitude_minutes / 60) self.showLatLon(latitude, longitude) try: self.getImage(latitude, longitude) except: pass if self.url != self.displayUrl: try: id = appuifw.app.body.current() content_handler = appuifw.Content_handler() content_handler.open("C:\\ymap.png") except IOError: appuifw.note(u"Could not fetch the map.", 'info') except Exception, E: appuifw.note(u"Could not open the map, %s" % E, 'info') self.displayUrl = self.url self.running = 0
def test_content_handler(): def content_handler_callback(): appuifw.note(u"File opened. CH callback hit!") ch = appuifw.Content_handler(content_handler_callback) fp = open("c:\\data\\python\\temp.txt", "w") fp.write("FOO BAR") fp.close() appuifw.note(u"Opening temp.txt in embedded mode") ch.open(u"c:\\data\\python\\temp.txt") os.remove("c:\\data\\python\\temp.txt") appuifw.note(u"Opening snake.py in standalone mode") ch.open_standalone(u"c:\\data\\python\\snake.py")
def fetching(): url = "http://www.leninsgodson.com/courses/pys60/resources/vid001.3gp" tempfile = "e:\\video01.3gp" try: print "Retrieving information..." urllib.urlretrieve(url, tempfile) lock = e32.Ao_lock() content_handler = appuifw.Content_handler(lock.signal) content_handler.open(tempfile) # Wait for the user to exit the image viewer. lock.wait() print "Video viewing finished." except: print "Problems."
def install_cert(self): fn = u"cl2-ca-cert.der" certfile = None for dn in ('c:\\data\\cl2\\', 'e:\\data\\cl2\\'): pn = dn + fn if os.path.exists(pn): certfile = pn if certfile is None: appuifw.note(u"No cert to install", "error") return doc_lock = e32.Ao_lock() ch = appuifw.Content_handler(doc_lock.signal) ch.open(certfile) doc_lock.wait()
def __init__(self, bt_address=None): print "in __init__" try: if (bt_address == None): self.address, self.services = socket.bt_discover() else: self.address, self.services = socket.bt_discover(bt_address) print "Discovery successful" print self.address print self.services except: import traceback traceback.print_exc() appuifw.query( unicode( "Error in bluetooth connection, is the service running"), 'query') appuifw.app.body.text((40, 90), unicode("Please restart!")) lock = e32.Ao_lock() lock.wait() self.data = "" self.sock = 0 self.lock = e32.Ao_lock() self.audio = 0 self.content_handler = appuifw.Content_handler() pykeygrab.init() if len(self.services) > 1: choices = self.services.keys() choices.sort() choice = appuifw.popup_menu( [unicode(self.services[x]) + ": " + x for x in choices], u'Choose port:') self.target = (self.address, self.services[choices[choice]]) else: self.target = (self.address, self.services.values()[0]) self.key_capturer = keycapture.KeyCapturer(self.key_callback) keys = keycapture.all_keys try: keys.remove( keycapture.EKeySelect ) # I haven't figured out how to simulate the select key in the contacts app keys.remove(keycapture.EKeySelect ) # for some reason, EKeySelect is in the list twice # It turns out that this is a bug in the Symbian key_simulation API. I connected a bluetooth keyboard and it exhibited the same problems except: import traceback traceback.print_exc() traceback.print_stack() self.key_capturer.keys = keys
def download(): url = "http://research.nokia.com/people/vidya_setlur/classes/MobileMultimedia/waterski.3gp" tempfile = "c:\\waterski.3gp" try: print "Retrieving information..." urllib.urlretrieve(url, tempfile) lock = e32.Ao_lock() content_handler = appuifw.Content_handler(lock.signal) content_handler.open(tempfile) # Wait for the user to exit the image viewer. lock.wait() print "Finished media playing." print "press options or exit." except IOError: print "Could not download the media." except: print "Could not open data received."
def lbox_observe(self, ind=None): if not ind == None: index = ind else: index = self.lb.current() focused_item = 0 if self.current_dir.at_root: self.dir_stack.append(index) self.current_dir.add(index) elif index == 0: # ".." selected focused_item = self.dir_stack.pop() self.current_dir.pop() elif os.path.isdir(self.current_dir.entry(index - 1)): self.dir_stack.append(index) self.current_dir.add(index - 1) else: item = self.current_dir.entry(index - 1) if os.path.splitext(item)[1].lower() == u'.py': i = appuifw.popup_menu([u"execfile()", u"Delete"]) else: i = appuifw.popup_menu([u"Open", u"Delete"]) if i == 0: if os.path.splitext(item)[1].lower() == u'.py': execfile(item, globals()) self.refresh() #appuifw.Content_handler().open_standalone(item) else: try: appuifw.Content_handler().open(item) except: import sys type, value = sys.exc_info()[:2] appuifw.note(unicode(str(type) + '\n' + str(value)), \ "info") return elif i == 1: os.remove(item) focused_item = index - 1 entries = self.current_dir.list_repr() if not self.current_dir.at_root: entries.insert(0, (u"..", u"")) self.lb.set_list(entries, focused_item)
def fetching(): # define the url where the video file is located on the server url = "http://www.leninsgodson.com/courses/pys60/resources/vid001.3gp" # define the loction on the phone where the fetched video file shall be stored tempfile = "c:\\video01.3gp" try: print "Retrieving information..." # fetch down the video and store it to you hard drive urllib.urlretrieve(url, tempfile) # create an active object before playin the video lock = e32.Ao_lock() # a content handler handles the playing of the video # load the content handler and tell to release the active object after the video has finnished playing (lock.signal) content_handler = appuifw.Content_handler(lock.signal) # open the video via the content handler. It will start playing automatically content_handler.open(tempfile) # Wait for the user to exit the image viewer. lock.wait() print "Video viewing finished." print "press options or exit." except IOError: print "Could not fetch the image." except: print "Could not open data received."
(u"US Satellite Image", "http://weather.gov/satellite_images/national.jpg", "jpg")] tempfile_without_extension = "c:\\weather" old_title = appuifw.app.title appuifw.app.title = u"Weather forecast" L = [x[0] for x in choices] index = appuifw.popup_menu(L, u"Select picture") if index is not None: url = choices[index][1] ext = choices[index][2] tempfile = tempfile_without_extension + "." + ext try: print "Retrieving information..." urllib.urlretrieve(url, tempfile) lock = e32.Ao_lock() content_handler = appuifw.Content_handler(lock.signal) content_handler.open(tempfile) # Wait for the user to exit the image viewer. lock.wait() print "Image viewer finished." except IOError: print "Could not fetch the image." except: print "Could not open data received." appuifw.app.title = old_title
def ru(x): return x.decode('utf-8') import appuifw appuifw.Content_handler().open_standalone(ru("E:\\Python\\PyfClock.swf")) appuifw.app.set_exit()
def lbox_observe(self, ind=None): if not ind == None: index = ind else: index = self.lb.current() focused_item = 0 if self.current_dir.at_root: self.dir_stack.append(index) self.current_dir.add(index) elif index == 0: # ".." selected focused_item = self.dir_stack.pop() self.current_dir.pop() elif os.path.isdir(self.current_dir.entry(index - 1)): self.dir_stack.append(index) self.current_dir.add(index - 1) else: item = self.current_dir.entry(index - 1) if os.path.splitext(item)[1] == '.py': i = appuifw.popup_menu([u"open python", u"Delete"]) elif os.path.splitext(item)[1] == '.jpg': i = appuifw.popup_menu( [u"open pic", u"Delete", u"change size pic"]) elif os.path.splitext(item)[1] == '.png': i = appuifw.popup_menu( [u"open pic", u"Delete", u"change size pic"]) else: i = appuifw.popup_menu([u"Open", u"Delete"]) if i == 0: if os.path.splitext(item)[1].lower() == u'.py': execfile(item, globals()) self.refresh() #appuifw.Content_handler().open_standalone(item) elif os.path.splitext(item)[1].lower() == u'.jpg': appuifw.Content_handler().open(item) elif os.path.splitext(item)[1].lower() == u'.png': appuifw.Content_handler().open(item) else: try: appuifw.Content_handler().open(item) except: import sys type, value = sys.exc_info()[:2] appuifw.note(unicode(str(type) + '\n' + str(value)), "info") return elif i == 1: os.remove(item) focused_item = index - 1 elif i == 2: if os.path.splitext(item)[1].lower() == u'.jpg': img = graphics.Image.open(item) w = appuifw.query(u"Width", "number") d = appuifw.query(u"Height", "number") img = img.resize((w, d), keepaspect=0) if appuifw.query(u"do you want change name pic", "query") == True: namu = appuifw.query(u"please put name pic", "text") img.save("e:\\PyResizePic\\" + namu + ".jpg") else: img.save("e:\\PyResizePic\\image.jpg") appuifw.note(u"image resize successfully", "conf") focused_item = index - 1 elif os.path.splitext(item)[1].lower() == u'.png': img = graphics.Image.open(item) w = appuifw.query(u"Width", "number") d = appuifw.query(u"Height", "number") img = img.resize((w, d), keepaspect=0) if appuifw.query(u"do you want change name pic", "query") == True: namu = appuifw.query(u"please put name pic", "text") img.save("e:\\PyResizePic\\" + namu + ".png") else: img.save("e:\\PyResizePic\\image.png") appuifw.note(u"image resize successfully", "conf") focused_item = index - 1 entries = self.current_dir.list_repr() if not self.current_dir.at_root: entries.insert(0, (u"..", u"")) self.lb.set_list(entries, focused_item)
def runpy(self): ch = appuifw.Content_handler() #ch.open_standalone(self.path.replace("/","\\")) execfile(self.path.replace("/", "\\"), globals()) self.refresh()
def wybierz(): global lista global listbox global li global screen global img global ustaw global ekran global mp3 global sciezkaplik global ladow global sck global pb mp3 = 0 sciezkaplik = sck index = listbox.current() appuifw.app.body = listbox = appuifw.Listbox( [(u'Beeper 6.00', u'symbian-freak.com')], ukryj) if int(ustaw[45:48]) <> 0: screen.hide() if lista[index][0] == u'General Options': k = 1 while (k > 0): k = appuifw.popup_menu([ u'Alert sound', u'Alert volume', u'Hour alert range', u'Text style', u'Bar info', u'Startup appearance' ], u'General Options') if k == 1: q = appuifw.popup_menu( [u'100%', u'75%', u'50%', u'25%', u'Silent'], u'Alert volume') if q <> None: ustaw = ustaw[0:36] + '%03d' % (100 - (q * 25)) + ustaw[39:57] elif k == 2: q = appuifw.query(u'Begin (0-23)', 'number', int(ustaw[39:42])) if (q <> None) and (q < 24): ustaw = ustaw[0:39] + '%03d' % q + ustaw[42:57] q = appuifw.query(u'End (0-23)', 'number', int(ustaw[42:45])) if (q <> None) and (q < 24): ustaw = ustaw[0:42] + '%03d' % q + ustaw[45:57] elif k == 3: q = appuifw.popup_menu( [u'Normal', u'Bold', u'Normal italic', u'Bold italic'], u'Text style') if q <> None: ustaw = ustaw[0:45] + '%03d' % ( q + (10 * (int(ustaw[45:48]) / 10))) + ustaw[48:57] elif k == 4: q = appuifw.popup_menu( [u'None', u'Time', u'Date', u'Ram', u'Signal', u'Battery'], u'Bar info') if q <> None: ustaw = ustaw[0:45] + '%03d' % ( (q * 10) + (int(ustaw[45:48]) % 10)) + ustaw[48:57] elif k == 5: q = appuifw.popup_menu( [u'Show after startup', u'Hide after startup'], u'Startup appearance') if q <> None: ustaw = ustaw[0:48] + '%03d' % q + ustaw[51:57] elif lista[index][0] == u'Bar Face': k = 0 while k is not None: k = appuifw.popup_menu( [u'Bar size', u'Bar position', u'Text position'], u'Bar Face') if k == 0: q = appuifw.query(u'Value X', 'number', int(ustaw[0:3])) if (q <> None) and (q < 353): ustaw = '%03d' % q + ustaw[3:57] q = appuifw.query(u'Value Y', 'number', int(ustaw[3:6])) if (q <> None) and (q < 417): ustaw = ustaw[0:3] + '%03d' % q + ustaw[6:57] if k == 1: q = appuifw.query(u'Value X', 'number', int(ustaw[6:9])) if (q <> None) and (q < 353): ustaw = ustaw[0:6] + '%03d' % q + ustaw[9:57] q = appuifw.query(u'Value Y', 'number', int(ustaw[9:12])) if (q <> None) and (q < 417): ustaw = ustaw[0:9] + '%03d' % q + ustaw[12:57] if k == 2: q = appuifw.query(u'Value X', 'number', int(ustaw[12:15])) if (q <> None) and (q < 353): ustaw = ustaw[0:12] + '%03d' % q + ustaw[15:57] q = appuifw.query(u'Value Y', 'number', int(ustaw[15:18])) if (q <> None) and (q < 417): ustaw = ustaw[0:15] + '%03d' % q + ustaw[18:57] elif lista[index][0] == u'Bar Color': k = 0 while k is not None: k = appuifw.popup_menu([u'Bar color', u'Text color'], u'Bar Color') if k == 0: q = appuifw.query(u'Value R (0-256) (888)', 'number', int(ustaw[18:21])) if q == 888: ustaw = ustaw[0:18] + '888000000' + ustaw[27:57] ima.blit(graphics.screenshot(), ((int(ustaw[6:9]), int(ustaw[9:12])), (int(ustaw[6:9]) + int(ustaw[0:3]), int(ustaw[9:12]) + int(ustaw[3:6])))) else: if (q <> None) and (q < 256): ustaw = ustaw[0:18] + '%03d' % q + ustaw[21:57] q = appuifw.query(u'Value G (0-256)', 'number', int(ustaw[21:24])) if (q <> None) and (q < 257): ustaw = ustaw[0:21] + '%03d' % q + ustaw[24:57] q = appuifw.query(u'Value B (0-256)', 'number', int(ustaw[24:27])) if (q <> None) and (q < 257): ustaw = ustaw[0:24] + '%03d' % q + ustaw[27:57] elif k == 1: q = appuifw.query(u'Value R (0-255)', 'number', int(ustaw[27:30])) if (q <> None) and (q < 256): ustaw = ustaw[0:27] + '%03d' % q + ustaw[30:57] q = appuifw.query(u'Value G (0-255)', 'number', int(ustaw[30:33])) if (q <> None) and (q < 256): ustaw = ustaw[0:30] + '%03d' % q + ustaw[33:57] q = appuifw.query(u'Value B (0-255)', 'number', int(ustaw[33:36])) if (q <> None) and (q < 256): ustaw = ustaw[0:33] + '%03d' % q + ustaw[36:57] elif lista[index][0] == u'Extras': p = 0 while p is not None: p = appuifw.popup_menu([ u'Test alarm', u'Highlight screen', u'Battery charge', u'Restart phone', u'Export sms', u'Program starter', u'Call recorder' ], u'Extras') if p == 0: try: if os.path.isdir(sciezkaplik): q = appuifw.query(u'Sound file (0-24)', 'number', 0) mp3 = audio.Sound.open( unicode(sciezkaplik + '\\' + str('%02d' % q) + '.mp3')) else: mp3 = audio.Sound.open(unicode(sciezkaplik)) mp3.play() audio.Sound.set_volume( mp3, int( audio.Sound.max_volume(mp3) * (float(int(ustaw[36:39])) / float(100)))) except: pass try: miso.vibrate(500, 100) except: pass elif p == 1: if ekran > 0: ekran = 0 else: ekran = 1 p = None elif p == 2: if ladow > 0: ladow = 0 else: ladow = 1 p = None elif p == 3: if appuifw.query(u'Restart phone now ?', 'query') == True: e32.start_exe(u'z:\\sys\\bin\\starter.exe', '') elif p == 4: lista = [(u'Please wait', u'')] appuifw.app.body = listbox = appuifw.Listbox(lista, nic) index = 0 tx = appuifw.Text() inb = inbox.Inbox() msgs = inb.sms_messages() tx.clear() for msg in msgs: mies = time.strftime('%m', time.localtime(inb.time(msg))) dz = time.strftime('%d', time.localtime(inb.time(msg))) rok = time.strftime('%Y', time.localtime(inb.time(msg))) czas = time.strftime('%H:%M:%S', time.localtime(inb.time(msg))) tx.add(u'Sender: ') tx.add(unicode(inb.address(msg))) tx.add(u'\n') tx.add(u'Date: ') tx.add(unicode(dz + '.' + mies + '.' + rok)) tx.add(u'\n') tx.add(u'Time: ') tx.add(unicode(czas)) tx.add(u'\n') tx.add(unicode(inb.content(msg))) tx.add(u'\n') tx.add(u'\n') if len(tx.get()) == 0: tx.add(u'None message') tx.add(u'\n') (rok, mies, dz, godz, min, x, x, x, x) = time.localtime() rok = str(rok)[2:4] mies = '%02d' % (mies) dz = '%02d' % (dz) godz = '%02d' % (godz) min = '%02d' % (min) appuifw.app.body = listbox = appuifw.Listbox( [(u'Beeper 6.00', u'symbian-freak.com')], nic) q = appuifw.query( u'C:\\Data\\', 'text', unicode(rok + mies + dz + godz + min + '.txt')) if q is not None: k = tx.get() try: f = open('c:\\data\\' + q, 'w') k = k.replace(unichr(8233), unichr(13) + unichr(10)) f.write(k.encode('utf-16')) f.close() except: appuifw.note(u'Error', 'error') else: if appuifw.query(u'Open file now ?', 'query') == True: appuifw.Content_handler().open_standalone( 'c:\\data\\' + q) elif p == 5: q = 0 while q <> None: q = appuifw.popup_menu([ u'Program ' + unicode(pb), u'Time ' + unicode(ustaw[51:53]) + u':' + unicode(ustaw[53:55]) ], u'Program starter') if q == 0: k = appuifw.popup_menu(ppb, u'Program') if k is not None: if k <> 2: pb = ppb[k] else: k = appuifw.query(u'X:\\Sys\\Bin\\', 'text', u'program.exe') if k is not None: if len(k) > 4: if k[len(k) - 4:] == '.exe': pb = k[:len(k) - 4] if q == 1: k = appuifw.query( u'Time', 'time', float( int(ustaw[51:53]) * 3600 + int(ustaw[53:55]) * 60)) if k is not None: ustaw = ustaw[0:51] + str( '%02d' % (k // 3600)) + str('%02d' % ((k - ( (k // 3600) * 3600)) // 60)) + ustaw[55:57] elif p == 6: q = 0 while q <> None: q = appuifw.popup_menu([ unicode(u'File path ' + fpp[int(ustaw[56:57])]), unicode('File format ' + aww[int(ustaw[55:56])]) ], u'Call recorder') if q == 0: k = appuifw.popup_menu(fpp, u'File path') if k is not None: ustaw = ustaw[0:56] + str(k) if q == 1: k = appuifw.popup_menu(aww, u'File format') if k is not None: ustaw = ustaw[0:55] + str(k) + ustaw[56:57] screen = TopWindow.TopWindow() screen.size = (int(ustaw[0:3]), int(ustaw[3:6])) screen._set_position((int(ustaw[6:9]), int(ustaw[9:12]))) screen.add_image(img, (0, 0)) if (lista[index][0] == u'General Options') and (k == 0): lista = [u'..'] listbox = appuifw.Listbox(lista, pozycja) sck = sciezkaplik pozycja() else: try: xt = str(ustaw) + chr(10) + str(sciezkaplik) + chr(10) + str(pb) dat = open('c:\\system\\Beeper.data', 'w') dat.write(xt) dat.close() except: pass xt = 0 li = 0 lista = [ (u'General Options', u'(' + str(int(ustaw[36:39])) + ') (' + str(int(ustaw[39:42])) + ',' + str(int(ustaw[42:45])) + ') (' + str(1 + int(ustaw[45:48]) % 10) + ') (' + str(1 + int(ustaw[45:48]) / 10) + ') (' + str(1 + int(ustaw[48:51])) + ')'), (u'Bar Face', u'(' + str(int(ustaw[0:3])) + ',' + str(int(ustaw[3:6])) + ') (' + str(int(ustaw[6:9])) + ',' + str(int(ustaw[9:12])) + ') (' + str(int(ustaw[12:15])) + ',' + str(int(ustaw[15:18])) + ')'), (u'Bar Color', u'(' + str(int(ustaw[18:21])) + ',' + str(int(ustaw[21:24])) + ',' + str(int(ustaw[24:27])) + ') (' + str(int(ustaw[27:30])) + ',' + str(int(ustaw[30:33])) + ',' + str(int(ustaw[33:36])) + ')'), (u'Extras', u'(Additional Functions)') ] appuifw.app.body = listbox = appuifw.Listbox(lista, wybierz) appuifw.app.menu = [(u'Hide program', ukryj), (u'About', prog)] appuifw.app.exit_key_handler = koniec if int(ustaw[45:48]) <> 0: screen.show()
RECEIVED = 0 if GENERR != 1: try: f = open(u'c:\\downloaded.html', 'w') f.write(msg) f.close() # lmsg = "\nother file operations" # LF.write(lmsg) except: pass # LF.close() del aSocket del aSSrv lock.signal() sync = e32.Ao_lock() thread.start_new_thread(thread_func, (sync,)) sync.wait() print "\ndone" try: content_handler = appuifw.Content_handler() r = content_handler.open(u'c:\\downloaded.html') if r != u"OK": appuifw.note(r, "info") except: print "couldn't open data received"
def show_config_file(self): doc_lock = e32.Ao_lock() ch = appuifw.Content_handler(doc_lock.signal) ch.open(unicode(config_file)) doc_lock.wait()