Example #1
0
 def connect(self,name,opts,ftp=FTP):
  self.tabs=tab
  self.name=name
  self.menu=[]
  if self.login(ftp,opts)==1:
   self.connected=True
   msg=self.ftp.getwelcome()
   if msg:ui.note(u(msg), 'info')
   self.tabs.new_tab(u(name),self.dispdir)
   if self.tabs.selected==0:self.tabs.select_tab(len(self.tabs.tabs)-1)
   
   self.menu=[
    (u'File...', (
        (u'Open', self.open), 
        (u'Download', self.download), 
        (u'File Info', self.fileinfo),
        (u'Rename', self.rename)
    )),
    (u'Edit...', (
        (u'Cut', self.cut),
        (u'Copy', self.copy)
    )),
    (u'View...', (
        (u'Refresh', self.refresh),
        (u'Change path', self.changepath)
     )), 
     (u'Upload', self.upload),
     (u'Delete', self.delete), 
     (u'New...', (
         (u'File', self.new), 
         (u'Folder', self.newdir)
     )), 
     (u'Send Command', self.sendcmd),
     (u'Disconnect', self.disconnect)]
   app.menu=self.menu
Example #2
0
File: trap.py Project: nesl/ecopda
    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']='Traps'
        
        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()
        conn.close()
        t2 = time.time()
        appuifw.note(u'response: '+str(response.status) + '\n'
                     + u'time: '+ str((t2-t1)*1000.))
def backup():
    qu=ui.popup_menu([u'Phone', u'Memory Card'], u'Select Location')
    loc=['c:\\', 'e:\\']
    try:
        dir=loc[qu]+'ADIKStools\\mySMSbackup\\'+time.strftime('%Y%m%d')+'\\'
    except:
        return
    if not os.path.exists(dir):
        os.makedirs(dir)
        ui.note(u'Folder Successfully Created', 'conf')
    n=dir+time.strftime('%H.%M.%S')+'.txt'
    gui.global_note(u'backing up\nplease wait', 'info')
    fl=open(n, 'a')
    fl.write(u'ADIKSonline SMS Backup\n\n%s\n' %q)
    b=t.sms_messages()
    if len(b)==0:
        ui.note(u'you have no message in your inbox'.upper())
        fl.write(u'No message in Inbox ! ! !\n\n%s\n' %u)
        fl.close()
        return
    y=0
    for i in b:
        try:
            fl.write(u'MESSAGE ID: %d\nSENDER: %s\nTIME: %s\nCONTENTS: %s\n\n%s\n\n' %(i, str(t.address(i)), time.ctime(t.time(i)), t.content(i), u))
            e32.ao_yield()
        except:
            y+=1
            gui.global_note(u'an error occured', 'error')
    fl.write(u'get more, contact:\[email protected]\n+2347035536245')
    fl.close()
    gui.global_note(str(len(b)-y)+u' successful'+u'\n'+str(y)+u' errors', 'confirm')
    e32.ao_sleep(1.5)
    if len(b)-y and msgquery.infopopup(u'View Backup Now?', u'View Backup', msgquery.OKRBack):
        view(n)
Example #4
0
def show():
    appuifw.note(u"Create an HTML backup first!","info")
    tempfile = "e:\\Siraj\SMS-backup.html"
    lock=e32.Ao_lock()
    content_handler = appuifw.Content_handler(lock.signal)
    content_handler.open(tempfile)
    lock.wait()
 def stop_wd_daemon(self):
     """
     Asks the daemon to stop by sending it a request.
     """
     # The Symbian PubSub mechanism would be one option for
     # implementing this.
     appuifw.note(u"No protocol for stopping WD", "error")
def decc():

	box=inbox.Inbox()

	m=box.sms_messages()

	l=box.content(m[0])

	#print l

	f=len(l)

	k=0

	d=0

	x=""

	for i in range(0,f,4):

	

		g=l[i:i+4]	

		d=int(g,0)	

		q=chr(d)

		x = x+q

	appuifw.note(unicode(x),"info")
    def getBTTransport(self):
        if sys.platform == 'symbian_s60': 
            import btsocket
            sock=btsocket.socket(btsocket.AF_BT,btsocket.SOCK_STREAM)
            addr,services=btsocket.bt_discover()
            if len(services)>0:
                port = services[u'opencoin']
            else:
                port=services[services.keys()[0]]
            address=(addr,port)
            sock.connect(address)
        else:
            import bluetooth as bt
            #evil hack
            appuifw.note(u'Searching for devices','info')
            results = [r for r in bt.find_service() if r['name']==None]
            targets = []
            for result in results:
                targets.append(u'%s' % (bt.lookup_name(result['host'])))
            selected = appuifw.popup_menu(targets,u'Connect to...?')
            
            host = results[selected]['host']
            #port = results[selected]['port']
            port = 3
            print 'host: %s, port: %s' % (host,port)
            sock=bt.BluetoothSocket( bt.RFCOMM )
            sock.connect((host, port))

            



        return transports.BTTransport(sock)
Example #8
0
 def refresh(self):
  self.wait=0
  self.body.color=0; self.body.font=u'LatinPlain12'
  if self.is_open: appuifw.app.title=unicode(os.path.split(self.path)[1])
  else: appuifw.app.title=self.defaults['title']
  menu=[[unicode(x), []] for x in ('File','Edit')]
  menu[0][1]+=[(u'Open path...', self.open_as)]
  if self.is_open: menu[0][1]+=[(u'Save', self.save)]
  menu[0][1]+=[(u'Save as...', lambda: self.save(save_as=1))]
  menu[1][1]+=[(u'Find...', self.find),
         (u'Find & Replace...', lambda: self.find(replace=1)),
         (u'Position...', self.position)]
  if self.is_open: menu[0][1]+=[(u'Revert', self.revert),
          (u'Close', self.close)]
  if len(self.recent): menu.insert(0, (u'Open recent', tuple(map(lambda x: (unicode(os.path.split(x)[1]), lambda: self.open_path(x)), self.recent)+[(u'Delete recents...', self.del_recent)])))
  menu+=[(u'Screen mode', tuple(map(lambda x: (unicode(x.title())+u' (current)'*(appuifw.app.screen==x), lambda: appuifw.note(unicode(x))), ('full','large','normal'))))]
  menu+=[(u'Exit', self.exit)]
  for i in range(len(menu)):
   try:
    if menu[i][1]==[]: del menu[i]
    elif type(menu[i][1])==list:
     menu[i][1]=tuple(menu[i][1]); menu[i]=tuple(menu[i])
     if len(menu[i][1])==1: menu[i]=menu[i][1][0]
   except IndexError: break
  try: appuifw.app.menu=menu
  except TypeError: appuifw.note(u'Menu error', 'error')
Example #9
0
 def is_ready_to_send(self):
     if not self.card.validate():
         return False
     if self.scanner_sender.active:
         appuifw.note(u"Still sending", "error")
         return False
     return True
Example #10
0
 def chdir(self, dir):
  try:
   if dir=='..':self.ftp.cwd('..');ui.note(u'Going up one', 'info', 1)
   else:
    ui.note(u'changing directory to '+dir, 'info', 1);self.ftp.cwd(self.pwd+'/'+dir)
   self.dispdir()
  except all_errors, e:self.disperr(str(e), [self.chdir, dir])
Example #11
0
 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()
Example #12
0
 def open_input(self):
     """Opens the input dialog.
     """
     if ui.touch_enabled():
         self.input_dialog.execute()
     else:
         ui.note(_(u"Touch not enabled."), "error")
Example #13
0
 def connect(self):
     """Connects to the server.
     """
     try:
         self.app.btclient.connect()
     except BluetoothError, e:
         ui.note(_(e.msg), "error")
Example #14
0
 def disconnect(self):
     """Disconnects from the server.
     """
     try:
         self.app.btclient.close()
     except BluetoothError, e:
         ui.note(_(e.msg), "error")
Example #15
0
 def reset_config(self):
   if appuifw.query(u'Are you sure you want to delete all settings?', 'query') is True:
     os.remove(self.config_file)
     appuifw.note(u"Done, now you need to restart Sissi!", 'info')
     self.running = False
     self.lock.signal()
     appuifw.app.exit_key_handler = None
Example #16
0
 def reset(self):
     if appuifw.query(u'Are you sure you want to reset? All PINs will be lost.', 'query'):
         self.myModel.resetDatabase()
         del self.myModel
         appuifw.app.body=None
         appuifw.note(u'Reset done','conf')
         self.startModel()
Example #17
0
 def playing(self):
   try:
       self.S = audio.Sound.open(self.filename)
       self.S.play()
       appuifw.note(u"Playing " + self.filename)
   except:
          appuifw.note(u"Record something first.")
Example #18
0
 def set_user(self):
     save_user=appuifw.query(u'Enter user name:', 'text', self.user)
     if not save_user:
         return
     else:
         self.user = unicode(save_user)
         appuifw.note(u'You entered: '+self.user)
Example #19
0
 def check(self):
     if self.b._check():
         appuifw.note(u"Success", "conf")
         if appuifw.query(u"Next game?", "query"):
             self.generateboard()
     else:
         appuifw.note(u"Fail", "error")
 def connect(self,name):
  self.name=name
  if self.login()==1:
   ui.note(u(self.ftp.getwelcome()), 'info')
   self.menu=[
    (u'File...', (
        (u'Open', self.open), 
        (u'Download', self.download), 
        (u'File Info', self.fileinfo),
        (u'Rename', self.rename)
    )),
    (u'Edit...', (
        (u'Cut', self.cut),
        (u'Copy', self.copy)
    )),
    (u'View...', (
        (u'Refresh', self.refresh),
        (u'Change path', self.dummy)
     )), 
     (u'Upload', self.upload),
     (u'Delete', self.delete), 
     (u'New...', (
         (u'File', self.new), 
         (u'Folder', self.newdir)
     )), 
     (u'Send Command', self.sendcmd),
     (u'Disconnect', self.disconnect)]
Example #21
0
    def show_log(self):
        logdir = logs_dir + "\\"
        
        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 disperr(self, e, action):
  if e[:3]=='421' or tuple(e)[0]==13:self.reconnect(*action)
  elif e=="(13, 'Permission denied')":self.reconnect(*action)
  elif e=="(32, 'Broken pipe')":
   ui.note(u'Unexpectly lost connection with '+self.host, 'error');reconn=ui.query(u'Reconnect?', 'query')
   if reconn==1:self.reconnect(*action)
  else:ui.note(u(e), 'error');print e
Example #23
0
def run():
 import appuifw,e32
 lock=e32.Ao_lock()
 def quit():
  lock.signal()
  s.quit()
 appuifw.app.exit_key_handler=quit
 items=[u'Move Forward',u'Move Right',u'Move Backward',u'Move Left',u'Set speed',u'Play sound',u'Upload mp3']
 s=Spykee()
 def call():
  c=appuifw.app.body.current()
  if c==0:s.move('forward')
  elif c==1:s.move('right')
  elif c==2:s.move('backward')
  elif c==3:s.move('left')
  elif c==4:s.setspeed(appuifw.query(u'Set speed','number',s.speed) or s.speed)
  elif c==5:s.sound(appuifw.query(u'Play sound 0-5','number'))
  elif c==6:
   return appuifw.note(u'Not Functioning','error')
   from simon816.util import util
   f=util().select('file',extwhitelist=['mp3'])
   if f:
    f=open(f,'rb')
    while 1:
     buf=f.read(4096)
     if not buf:break
     s.sock.send(s._mk_code(6,16,2)+buf)
    s.sock.send(s._mk_code(7,0,1,6))

 lb=appuifw.Listbox(items, call)
 s.connect(appuifw.query(u'IP Address','text',u'192.168.1.104'))
 appuifw.note(u'Connected to: %s'%s.login('username','password'))
 appuifw.app.body=lb
 lock.wait()
Example #24
0
	def startService(self):
		"""Initiates the bluetooth sockets and listen for a connection"""
		
		self.serverSocket = bt.socket(bt.AF_BT,bt.SOCK_STREAM)
		
		#Gets a free channel for communication
		self.channel = bt.bt_rfcomm_get_available_server_channel(self.serverSocket)
		
		#Binds the socket to that channel and listen for connection
		self.serverSocket.bind(("",self.channel))
		bt.bt_advertise_service( self.serviceName,
                              self.serverSocket,
		                      True,
		                      bt.RFCOMM )
		
		bt.set_security(self.serverSocket, bt.AUTHOR | bt.AUTH )
		self.serverSocket.listen(1)
		
		#Forking into the background
		appswitch.switch_to_fg(u'PythonScriptShell')
		ui.note(u"SmsConsole: Waiting for connections","info")
		appswitch.switch_to_bg(u'PythonScriptShell')
		
		self.clientConn,self.clientAddr = self.serverSocket.accept()
		
		appswitch.switch_to_fg(u'PythonScriptShell')
		ui.note(u"Client %s Connected" % (self.clientAddr), "info")
		appswitch.switch_to_bg(u'PythonScriptShell')
Example #25
0
 def update_modify(self, uno, due, id):
     old_title = appuifw.app.title
     appuifw.app.title = u"Modify Fuel"
     self.show_form_modify(uno, due)
     if self.isSaved():
         # estraggo i dati che mi servono
         date = self.getDate()
         priceLiter = self.getPriceLiter()
         euro = self.getEuro()
         paid = self.getPaid()
         who = self.getWho1()
         km = self.getKm()
         another = self.getAnother()
         # sql_string = u"UPDATE fuel SET (date, priceLiter, euro, paid, who, km, another) VALUES (%d, %f, %f, '%s', '%s', %d, '%s') WHERE id=%d" %( date, priceLiter, euro, paid, who, km, another, int(id) )
         sql_string = (
             u"UPDATE fuel SET date=%d, priceLiter=%f, euro=%f, paid='%s', who='%s', km=%d, another='%s' WHERE id=%d"
             % (date, priceLiter, euro, paid, who, km, another, int(id))
         )
         try:
             db.execute(sql_string)
         except:
             db.open(self.dbpath)
             db.execute(sql_string)
         appuifw.note(u"Update", "conf")
         db.close()
     appuifw.app.title = old_title
Example #26
0
 def save(self, f):
  try:
   self.ftp.storbinary('STOR '+self.sel[9], f, self.db.get('blocksize', 'int'))
   f.close()
   ui.note(u'Saved!', 'conf', 1)
  except all_errors, e:
   self.disperr(str(e), [self.save, f])
Example #27
0
def tracetofile():
    file = open(DEBUG_FILE, "a")
    file.write("Captured traceback\n")
    traceback.print_exc(file=file)
    file.close()
    note(u"Error inesperado", "error")
    raise
Example #28
0
    def CheckSrc(self):
        try:
            try:    #尝试从C盘读取
                #检查图像资源文件-----------
                self.imgStart = graphics.Image.open(r'c:\python\images\KumReader_Start.JPG')    #启动画面
                self.imgBookShelf = graphics.Image.open(r'c:\python\images\KumReader_Bookshelf.JPG')    #书架
                self.imgMainMenu = graphics.Image.open(r'c:\python\images\KumReader_MainMenu.png')      #主菜单
                self.imgBook = graphics.Image.open(r'c:\python\images\KumReader_book.png')      #书籍封面
                self.imgBgGray = graphics.Image.open(r'c:\python\images\bg_Gray.JPG')       #灰色纹理图
                self.imgBgGreen = graphics.Image.open(r'c:\python\images\bg_Green.JPG')     #绿色纹理图
                self.imgBgYellow = graphics.Image.open(r'c:\python\images\bg_Yellow.JPG')   #黄色纹理图

                #检查配置文件----------
                self.dbSetting = e32dbm.open(r'c:\python\UserSettings.e32dbm', 'w')     #软件配置文件
                self.dbBookshelf = e32dbm.open(r'c:\python\Bookshelf.e32dbm', 'w')       #书架书籍信息

            except:     #尝试从D盘读取

                #检查图像资源文件-----------
                self.imgStart = graphics.Image.open(r'd:\python\images\KumReader_Start.JPG')
                self.imgBookShelf = graphics.Image.open(r'd:\python\images\KumReader_Bookshelf.JPG')
                self.imgMainMenu = graphics.Image.open(r'd:\python\images\KumReader_MainMenu.png')
                self.imgBook = graphics.Image.open(r'd:\python\images\KumReader_book.png')
                self.imgBgGray = graphics.Image.open(r'd:\python\images\bg_Gray.JPG')
                self.imgBgGreen = graphics.Image.open(r'd:\python\images\bg_Green.JPG')
                self.imgBgYellow = graphics.Image.open(r'd:\python\images\bg_Yellow.JPG')

                #检查配置文件----------
                self.dbSetting = e32dbm.open(r'd:\python\UserSettings.e32dbm', 'w')
                self.dbBookshelf = e32dbm.open(r'd:\python\Bookshelf.e32dbm', 'w')

        except:
            appuifw.note(self.cn('应用程序已损坏,请重新安装!'), 'error')
            appuifw.app.set_exit()
Example #29
0
    def menu_language(self):
        """Show language list, save changes in config.
        """
        def find_translations():
            """Get list of language codes.

            `gettext.find()` can't do it without defined system variables
            """
            # __builtin__.__dict__['_'] = lambda x: x  # Monkey path
            all_translations = set()
            if self._localedir:
                localedir = self._localedir
            else:
                localedir = gettext._default_localedir
            for loc_folder in os.listdir(localedir):
                for mo in os.listdir(
                        os.path.join(localedir, loc_folder, 'LC_MESSAGES')):
                    if mo.endswith('.mo'):
                        all_translations.add(unicode(loc_folder))
            return list(all_translations)

        translations = find_translations()
        translations.append(u'en')
        idx = appuifw.popup_menu(translations, _(u"Select language:"))
        if idx is not None:
            self.set_language(translations[idx])
            self._cfg.set(self._cfg_section, 'language', translations[idx])
            self.save_cfg()
            self.update_calcs()
            appuifw.note(
                _(u"Please reload the program to apply the changes."), 'info')
Example #30
0
 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))
Example #31
0
 def cssSettings(self,css,save):
  opts=[]
  for k in css:
   opts.append((unicode(k),'text',unicode(css[k])))
  # unusual bug where form.insert does not save current state
  f=appuifw.Form(opts,
     appuifw.FFormEditModeOnly
   |appuifw.FFormDoubleSpaced)
  def add():
   k,v=self.availcss([str(c[0]) for c in f])
   f.insert(len(f),(k,'text',v))
  f.menu=[
   (u'Add css',add),
   (u'Delete',lambda:appuifw.note(u'To delete: remove contents of field and Save afterwards')),
    ]
  f.save_hook=save
  f.execute()
Example #32
0
 def reconnect(self, func, *action):
     if self.login() == 1:
         ui.note(u'reconnected', 'conf', 1)
         if action == []: func()
         else:
             self.ftp.cwd(self.pwd)
             func(*action)
     else:
         if not self.rety == 1:
             ui.note(u'Connection was dropped but could not reconnect',
                     'error')
             ui.note(u'retrying...', 'info', 1)
             self.retry = 1
             self.reconnect(func, *action)
         else:
             ui.note('Could not make a data connection, returning to menu',
                     'error')
             self.retry = 0
             self.conscr()
Example #33
0
class ftpclass:
    def __init__(self, db):
        self.db = db
        self.connected = False
        self.t = text()
        self.t.t.font = self.db.get('font', 'tuple')
        self.t.t.color = self.db.get('color', 'tuple')

    def dummy(self, *args):
        pass

    def exit(self, action):
        app.exit_key_handler = action

    def disp(self, cback):
        return ui.Listbox(self.interface, cback)

    def login(self, ftpMgr, opts=None):
        if opts: self.opts = opts
        opts = self.opts
        self.user = str(opts[2])
        self.host = str(opts[0])
        self.handler = ftpMgr
        self.ftp = ftpMgr()
        #if ftpMgr==fileftp:return 1
        try:
            self.ftp.connect(self.host, int(float(opts[1])))
            self.ftp.set_pasv(opts[5])
            self.ftp.login(
                self.user,
                interface(self.db).decodestring(opts[3], self.db.get('a')))
            self.l = loader(
                graphics.Image.open(
                    'e:\\Python\\apps\\simon816\\ftpbrowser\\loading.gif'),
                100)
            self.pwd = ''
            self.chdir(str(opts[4]))
            return 1
        except all_errors[1], e:
            ui.note(u'could not connect\n' + u(e), 'error')
            self.disconnect(1)
        except all_errors[0], e:
            ui.note(u'could not login\n(Bad username/password)', 'error')
            self.disconnect(1)
Example #34
0
def send_photo():
    try:
        address, services = socket.bt_obex_discover()
    except:
        appuifw.note(u"OBEX Push not available", "error")
        return

    if u'OBEX Object Push' in services:
        channel = services[u'OBEX Object Push']
        socket.bt_obex_send_file(address, channel, PHOTO)
        appuifw.note(u"photo sent", "info")
    else:
        appuifw.note(u"OBEX Push not available", "error")
Example #35
0
 def reset(s):
     while 1:
         t=ui.query(cn("请设置百度帐号"),"text")
         if t!=None:break
         ui.note(cn("帐号输入有误!"),"error")
     open(path+"zh.png","w").write(encrypt(en(t)))
     s.un=decrypt(open(path+"zh.png","r").read())
     while 1:
         t=ui.query(cn("请设置密码"),"code")
         if t!=None:break
         ui.note(cn("密码输入有误!"),"error")
     open(path+"pa.png","w").write(encrypt(en(t)))
     s.psw=decrypt(open(path+"pa.png","r").read())
     ui.note(cn("设置完成!"),"conf")
 def kill_cl2_daemon(self):
     """
     Terminates the daemon. This requires sufficient caps, or we
     will get KERN-EXEC 46.
     """
     if have_miso:
         # http://wiki.forum.nokia.com/index.php/How_to_start_and_stop_exe
         count = miso.kill_process(cl2_pattern, 0)
         if count == 0:
             appuifw.note(u"Nothing to kill", "info")
         else:
             appuifw.note(u"%d process(es) killed" % count, "info")
     else:
         appuifw.note(u"Miso not installed", "error")
Example #37
0
def press():
    index = listbox.current()
    list = [cn("查看编号"), cn("查看路径"), cn("启动程序")]
    index1 = appuifw.popup_menu(list, cn("查看信息"))
    if index1 == 0:
        appuifw.note(cn(str(list2[index])), "info")
    if index1 == 1:
        appuifw.note(cn(str(list3[index])), "info")
    if index1 == 2:
        try:
            e32.start_exe(list3[index], "")
        except:
            appuifw.note(cn("无法启动!"), "error")

    e32.Ao_lock().wait()
Example #38
0
 def call():
     c = appuifw.app.body.current()
     if c == 0: s.move('forward')
     elif c == 1: s.move('right')
     elif c == 2: s.move('backward')
     elif c == 3: s.move('left')
     elif c == 4:
         s.setspeed(
             appuifw.query(u'Set speed', 'number', s.speed) or s.speed)
     elif c == 5:
         s.sound(appuifw.query(u'Play sound 0-5', 'number'))
     elif c == 6:
         return appuifw.note(u'Not Functioning', 'error')
         from simon816.util import util
         f = util().select('file', extwhitelist=['mp3'])
         if f:
             f = open(f, 'rb')
             while 1:
                 buf = f.read(4096)
                 if not buf: break
                 s.sock.send(s._mk_code(6, 16, 2) + buf)
             s.sock.send(s._mk_code(7, 0, 1, 6))
Example #39
0
 def show_upload_time(self):
     v = self.daemon_query(
         """do local t = cl2.get_upload_time(); if t then return t else return "nil" end; end"""
     )
     if v is None:
         return
     if v == "nil":
         appuifw.note(u"No uploads", "info")
     else:
         try:
             t = int(v)
         except ValueError:
             appuifw.note(u"Failed to query time", "error")
             return
         tm = time.gmtime(t)
         ts = format_time(tm)
         appuifw.note(u"Last upload at %s" % ts, "info")
Example #40
0
 def open():
      appuifw.note(ar('Please Select a Sound '))
      filem = fm.manager()
      spa = filem.AskUser(path=u'e:\\sounds', find='file',ext=[(u'.amr'),(u'.wav'),(u'.mp3')])
      if spa:
             if spa[-1] == '\\':
                spa=spa[:-1]
             if spa[-1] == '\\':
                spa=spa[:-1]
      filename = spa
      global S
      try:
          S=audio.Sound.open(spa)
        
          S.play()
          appuifw.note(ar('Playing'),"info")
      except:
          appuifw.note(ar('Select a Sound!'),"error")
Example #41
0
 def get_sid(self):  #获取SID函数
     x, y = ui.multi_query(cn('乐讯帐号:'), cn('密码:'))
     if x and y:
         from urllib import urlencode
         data = urlencode({"Num": en(x), "PWD": en(y)})
         url = 'http://117.135.136.38/login/login.aspx'
         res = self.send(data, url)
         if res[0] == 200 and res[2]:
             import re
             re_get_sid = re.compile('\w{25}')
             sid = re_get_sid.findall(res[2])
             if sid:
                 self.setting[2] = cn(sid[0])
                 ui.note(cn('成功获取LXT并以设置成功!'))
             else:
                 ui.note(cn('获取LXT失败,请重试或手动设置!'))
         else:
             ui.note(cn('网络连接出错!请重试!'))
Example #42
0
 def OnFindMap(self):
     Log("viewer*", "Application::OnFindMap()")
     try:
         maps = self.FindMapsForPosition(self.pos)
         items = []
         if len(maps) > 0:
             keys = maps.keys()
             keys.sort()
             for key in keys:
                 items.append(u"%s" % key)
             index = ui.selection_list(items)
             if index != None:
                 ui.note(u"Loading map %s" % keys[index], "info")
                 self.LoadMap(keys[index])
         else:
             ui.note(u"No maps available", "info")
     except:
         DumpExceptionInfo()
         ui.note(u"Failure while trying to find map", "error")
Example #43
0
 def reconnect(self, func, *action):
     if self.login(self.handler) == 1:
         self.l.addtext(u'reconnected', 1)
         if action == []: func()
         else:
             self.chdir('')
             func(*action)
     else:
         if not self.retry == 1:
             ui.note(u'Connection was dropped but could not reconnect',
                     'error')
             ui.note(u'retrying...', 'info', 1)
             self.retry = 1
             self.reconnect(func, *action)
         else:
             ui.note('Could not make a data connection, returning to menu',
                     'error')
             self.retry = 0
             self.conscr()
def handle_selection():
    index = lb.current()
    code = choices[index][1]
    weather_url = weather_url_base + code + ".xml"
    lb.set_list([u"Please wait..."])
    appuifw.note(u"Fetching " + weather_url, 'info')
    try:
        urllib.urlretrieve(weather_url, tempfile)
        f = open(tempfile, 'r')
        weatherinfo = f.read()
        f.close()
        weather = find_value(weatherinfo, "weather")
        temperature_string = find_value(weatherinfo, "temperature_string")
        appuifw.popup_menu([(u"Weather", unicode(weather)),
                            (u"Temperature", unicode(temperature_string))],
                           unicode(code))
    except IOError:
        appuifw.note(u"Connection error to server", 'error')
    except:
        appuifw.note(u"Could not fetch information", 'error')
    lb.set_list(choices_labels)
Example #45
0
    def save_hook(self, form_list):
        # TODO save to DB
        # form is the user's form.
        # Has the structure [(u'field_name','type','data'), ... ]
        for i in form_list:
            field_name = str(i[0]).lower()
            field_name = field_name[(string.find(field_name, ":") + 1):]
            field_val = None
            if (i[1] != 'combo'):
                field_val = i[2]
            else:  # this is how you deal with combos
                List, Index = i[2]
                field_val = List[Index]
            if field_name in self.capture_dict:
                self.capture_dict[field_name] = field_val
            else:
                appuifw.note(u"bug: " + field_name + " not in dictionary.",
                             "error")

        # Check for self.picture_filename
        if self.picture_filename is not u'':
            self.capture_dict['picture_filename'] = self.picture_filename


#         appuifw.popup_menu([unicode(self.capture_dict['site']
#                                     +':'+str(self.capture_dict['ima'])
#                                     +':('+str(self.capture_dict['xcoord'])
#                                     +','+str(self.capture_dict['ycoord'])
#                                     +'):'+self.capture_dict['position'])],
#                            u'From save_hook')

        captureORM = Captures(self.db, self.id, **self.capture_dict)
        if self.id == None:
            # I was new
            appuifw.note(u'I am new')
            self.id = captureORM.id
        else:
            # I was old. So I have to update the DB
            captureORM.set(**self.capture_dict)
        appuifw.note(u"Saved to DB row id:" + str(self.id), "conf")
Example #46
0
    def sendCoinsBT(self):
        self.sock = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
        try:
            addr, services = socket.bt_discover()
        except Exception:
            appuifw.note(u'Bluetooth failed')
            return

        if len(services) > 0:
            choices = services.keys()
            choices.sort()
            choice = appuifw.popup_menu(
                [unicode(services[x]) + ": " + x for x in choices],
                u'Choose port:')
            port = services[choices[choice]]
        else:
            port = services[services.keys()[0]]
        address = (addr, port)
        self.sock.connect(address)
        appuifw.note(u'Bluetooth connected')
        self.sock.send('A coin \n')
        appuifw.note(u'Coin sent')
Example #47
0
 def do(self, files, function=None):
     self.delete_item('all')
     self.body.set_list([self.dtext['processing'] + ': 0%'])
     total = len(files)
     if self.format == 'JPEG':
         ext = '.jpg'
     elif self.format == 'PNG':
         ext = '.png'
     for t in xrange(total):
         try:
             im = graphics.Image.open(files[t])
         except SymbianError:
             appuifw.note(u'Could not to open: ' + path.split(files[t])[1],
                          'error')
             continue
         if function is None:
             newim = im
         else:
             newim = function(im)
         self.progress(((t * 100) / total))
         outname = path.splitext(
             path.join(self.outpath,
                       path.split(files[t])[1]))[0] + ext
         try:
             if self.format == 'PNG':
                 newim.save(outname,
                            bpp=self.bpp,
                            compression=self.compression,
                            format=self.format)
             else:
                 newim.save(outname,
                            quality=self.quality,
                            format=self.format)
         except:
             appuifw.note(self.dtext['cantsave'], 'error')
         im = None
         newim = None
     self.body.set_list([u''])
     appuifw.note(self.dtext['done'])
 def colorselect(self, d):
     i = appuifw.popup_menu(colors.values() + [u"> Custom"])
     if i == len(colors.values()):
         r = appuifw.query(u'Red (0-255)', 'number')
         if r in range(0, 256):
             g = appuifw.query(u'Green (0-255)', 'number')
             if g in range(0, 256):
                 b = appuifw.query(u'Blue (0-255)', 'number')
                 if b in range(0, 256):
                     return self.bintostr((r, g, b)).replace(" ", "")
                 else:
                     appuifw.note(u'Incorrect value', 'error')
                     return d
             else:
                 appuifw.note(u'Incorrect value', 'error')
                 return d
         else:
             appuifw.note(u'Incorrect value', 'error')
             return d
     elif i != None:
         return colors.values()[i]
     else:
         return d
Example #49
0
 def delete(self):
     self.sel = self.getsel()
     conf = ui.query(u"Delete " + self.sel[9] + "?", 'query')
     if conf == 1:
         try:
             if not self.sel[1][0] == 'd':
                 self.ftp.delete(self.pwd + '/' + self.sel[9])
                 ui.note(u'deleted', 'conf', 1)
             else:
                 try:
                     self.ftp.rmd(self.sel[9])
                     ui.note(u'deleted', 'conf', 1)
                 except all_errors, e:
                     if str(e) == '550 Directory not empty.':
                         if ui.query(
                                 u'Driectory is not empty, delete all sub directories and files?',
                                 'query') == 1:
                             self.dev('multi delete')
                             ui.note(u'deleted', 'conf', 1)
                     else:
                         raise e
             self.dispdir()
         except all_errors, e:
             self.disperr(str(e), [self.delete])
Example #50
0
 def fileinfo(self):
     s = ''
     for i in self.getsel():
         s += str(i) + '\n'
     ui.note(u(s))
     print s
Example #51
0
 def directional_pad(self, value):
     appuifw.app.directional_pad = value
     appuifw.note(
         u'Switching body to canvas to verify directional_pad operation')
     appuifw.app.body = self.canvas
     self.refresh((0, 0, 0, 0))
Example #52
0
 def about(self):
     ui.note(u'A FREE ' + self.appname + ' by ' + self.author +
             '\nFor more info, please visit:' + self.url +
             '\nCurrent version: ' + self.get_db('version'))
Example #53
0
def about():
    appuifw.note(cn("网页源码 v0.01\n八神智能天下\七七作品\n   zntx.org.cn"), "info")
Example #54
0
 def dev(self, feat):
     ui.note(
         u'This app is in development atm, feature "' + feat +
         '" has not yet been implemented', 'error')
Example #55
0
class ftpbrowser:
    def dev(self, feat):
        ui.note(
            u'This app is in development atm, feature "' + feat +
            '" has not yet been implemented', 'error')

    def mkdir(self, list):
        for dir in list:
            if not os.path.exists(dir):
                os.makedirs(dir)
                return 1
            else:
                return 0

    def __init__(self):
        self.appname = u"FTP Browser"
        self.author = u"Simon816"
        self.url = u'http://simon816.hostzi.com'
        d = 'e:\\python\\apps\\simon816\\ftpbrowser\\'
        try:
            f = open(d + 'db.dir', 'r+')
            dbDIR = f.read()
        except:
            f = open(d + 'db.dir', 'w')
            f.write(d)
            dbDIR = d
        f.close()
        self.db = e32dbm.open(dbDIR + 'db', 'cf')
        self.dd = dbDIR
        self.root = d
        try:
            s = self.db['status']
        except:
            self.reset()
        self.exit(self.quit)

    def form(self, args):
        return [(u'Conn. name', 'text', args[0]), (u'Host', 'text', args[1]),
                (u'Port', 'number', args[2]), (u'User nm.', 'text', args[3]),
                (u'Password', 'text', args[4]),
                (u'Initial Dir', 'text', args[5]),
                (u'Passive', 'combo', ([u'True', u'False'], args[6]))]

    def mod_db(self, key, value):
        s = ''
        if value == tuple(value):
            for v in value:
                try:
                    v = int(v)
                    s += str(v) + '\x01'
                except:
                    s += str(v) + '\x00'
            s = s[:len(s) - 1]
        elif value == list(value):
            for v in value:
                s += str(v) + '\x01'
        else:
            s = value
        self.db[str(key)] = str(s)

    def get_db(self, key, mode='str'):
        try:
            v = self.db[str(key)]
            if mode == 'str': return v
            elif mode == 'int': return int(float(v))
            elif mode == 'tuple':
                t = v.split('\x00')
                for v in range(t):
                    if t[v][len(t[v]) - 1:] == '\x01':
                        t[v] = int(float(t[v][:len(t[v]) - 1]))
                return tuple(t)
            elif mode == 'list':
                return tuple(v.split('\x01'))
        except:
            return None

    def decodestring(self, s, a):
        return decode(str(s[int(float(s[:1])) + 1:]),
                      int(float(a.find(s[1:2]) + 1)))

    def encodestring(self, s, a):
        K = random.randint(1,
                           len(a) - 1)
        k = encode(str(K), K, '', 'a')
        return encode(s, K,
                      str(len(k)) + k)

    def reset(self):
        try:
            for entry in self.db.items():
                if entry[0].find('acc_') == -1: del self.db[entry[0]]
            self.mod_db('settings_dir',
                        'e:\\python\\apps\\simon816\\ftpbrowser')
            self.mod_db('account_dir', self.db['settings_dir'] + '\\accounts')
            self.mod_db('cashe_dir', self.db['settings_dir'] + '\\cashe')
            self.mod_db('version', '0.0.1')
            self.mod_db('defaultdir', 'e:\\')
            self.mod_db('color', '0x000000')
            self.mod_db('font', (u"nokia hindi s60", 14, 16))
            self.mod_db('maxtrans', '1048576')
            self.mod_db('icons', "e:\\mbm.mbm")
            self.mod_db('status', 'ready')
            self.mod_db('debug', 'False')
            self.mod_db('mode', 'SQL')
            self.mod_db(
                'a', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\t')
            ui.note(u'Successfully reset', 'conf')
        except:
            ui.note(u'error', 'error')

    def quit(self):
        self.db.sync()
        self.db.close()
        lk.signal()

    def exit(self, action):
        app.exit_key_handler = action

    def disp(self, cback):
        return ui.Listbox(self.interface, cback)

    def dummy(self):
        pass

    def about(self):
        ui.note(u'A FREE ' + self.appname + ' by ' + self.author +
                '\nFor more info, please visit:' + self.url +
                '\nCurrent version: ' + self.get_db('version'))

    def run(self):
        self.mkdir([
            self.get_db('settings_dir'),
            self.get_db('account_dir'),
            self.get_db('cashe_dir')
        ])
        self.mainscr()

    def mainscr(self):
        self.exit(self.quit)
        self.menu = [(u'Select', self.handle), (u'About', self.about),
                     (u'Reset', self.reset), (u'Exit', self.quit)]
        self.interface = [u'Connect', u'Settings', u'Setup']
        app.menu = self.menu
        app.body = self.disp(self.handle)
        app.title = self.appname

    def activate(self):
        c = app.body.current()
        if self.connections[c] == u'New Connection': self.newcon()
        else: self.connect(self.connections[c])

    def handle(self):
        c = app.body.current()
        if c == 0: self.conscr()
        elif c == 1: self.settings()
        elif c == 2: self.setup()
        else: pass

    def conscr(self):
        self.exit(self.mainscr)
        self.menu = [(u'Connect', self.activate), (u'New', self.newcon),
                     (u'Edit', self.editcon), (u'Delete', self.delcon)]
        self.connections = [u'New Connection']
        if self.get_db('mode') == 'flatfile':
            for file in os.listdir(self.get_db('account_dir')):
                if len(file.split('.acc')) == 2:
                    self.connections.append(u(file).split('.acc')[0])
        elif self.get_db('mode') == 'SQL':
            l = []
            for arr in self.db.items():
                if not arr[0].find('acc_') == -1: l.append(u(arr[0][4:]))
            l.sort()
            self.connections += l
        self.interface = self.connections
        app.body = self.disp(self.activate)
        app.menu = self.menu
        app.title = u'Connect to...'

    def settings(self):
        self.interface = [(u'Settings Directory', u(self.db['settings_dir'])),
                          (u'Default Directory', u(self.db['defaultdir'])),
                          (u'Account Directory', u(self.db['account_dir'])),
                          (u'Cashe Directory', u(self.db['cashe_dir']))]
        app.body = self.disp(self.set)
        self.exit(self.mainscr)

    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 setup(self):
        self.exit(self.mainscr)
        self.interface = [(u'Debug Mode', u(self.get_db('debug'))),
                          (u'Database Directory', u(self.dd)),
                          (u'Account storage mode', u(self.db['mode'])),
                          (u'Alphabet string', u(self.get_db('a')))]
        app.body = self.disp(self.chset)

    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 newcon(self):
        flags = ui.FFormEditModeOnly
        f = self.form([u'', u'', 21, u'', u'', u'/', 0])
        f = ui.Form(f, flags)
        f.execute()
        self.savecon(f, 'true')

    def editcon(self):
        name = self.interface[app.body.current()]
        flags = ui.FFormEditModeOnly
        if self.get_db('mode') == 'flatfile':
            f = open(self.get_db('account_dir') + '\\' + name + '.acc')
            data = f.read()
            f.close()
            data = data.split('\n')
        elif self.get_db('mode') == 'SQL':
            data = self.get_db('acc_' + name, 'list')
        if data[5] == 'true': p = 0
        else: p = 1
        form = self.form([
            u(name),
            u(data[0]),
            int(float(data[1])),
            u(data[2]),
            u(self.decodestring(data[3], self.get_db('a'))),
            u(data[4]), p
        ])
        f = ui.Form(form, flags)
        f.execute()
        self.savecon(f)

    def savecon(self, f, append='false'):
        if f[6][2][1] == 0: p = 'true'
        else: p = 'false'
        #try:
        if f[0][2] == u'' or f[1][2] == u'': raise ValueError
        if self.get_db('mode') == 'flatfile':
            fi = open(
                self.get_db('account_dir') + '\\' + f[0][2] + '.acc', 'w')
            m = 'ff'
        elif self.get_db('mode') == 'SQL':
            fi = StringIO.StringIO()
            m = 'sql'
        for d in range(len(f) - 1):
            if d == 5: fi.write(p)
            elif d == 3:
                fi.write(
                    self.encodestring(f[d + 1][2], self.get_db('a')) + '\n')
            else:
                fi.write(str(f[d + 1][2]) + '\n')
        if m == 'ff': fi.close()
        elif m == 'sql':
            fi.seek(0)
            d = fi.read()
            fi.close()
            self.mod_db('acc_' + f[0][2], d.split('\n'))
        if append == 'true': self.connections.append(u(f[0][2]))
        ui.note(u'Saved', 'conf')
        self.conscr()

    #except:
    #ui.note(u'Did not save')

    def delcon(self):
        name = self.interface[app.body.current()]
        ok = ui.query(u'Are you sure you want to delete "' + name + '"',
                      'query')
        if ok == 1:
            if self.get_db('mode') == 'flatfile':
                os.unlink(self.db['account_dir'] + '/' + name + '.acc')
            elif self.get_db('mode') == 'SQL':
                del self.db['acc_' + name]
            self.connections.pop(app.body.current())
        self.conscr()

    def login(self):
        if self.get_db('mode') == 'flatfile':
            f = open(self.get_db('account_dir') + '\\' + self.name + '.acc')
            data = f.read()
            f.close()
            opts = data.split('\n')
        else:
            opts = self.get_db('acc_' + self.name, 'list')
        self.user = str(opts[2])
        self.host = str(opts[0])
        self.ftp = file()
        try:
            self.ftp.connect(self.host, int(float(opts[1])))
            self.ftp.set_pasv(opts[5])
            self.ftp.login(self.user,
                           self.decodestring(opts[3], self.get_db('a')))
            self.ftp.cwd(str(opts[4]))
            return 1
        except all_errors[1], e:
            ui.note(u'could not connect\n' + u(e), 'error')
            self.conscr()
        except all_errors[0], e:
            ui.note(u'could not login\n(Bad username/password)', 'error')
            self.disconnect()
            self.conscr()
Example #56
0
def event(event):
    global field, dx, dy, cx, cy, n, isinstalled, level, scores, canvas, buffer
    dx = dy = 0
    if event["type"] == 1:
        ev = event["keycode"]
        if (ev == key_codes.EKeyUpArrow) or (ev == key_codes.EKey2):
            dx = 0
            dy = -1
            #вверх
        elif ev == key_codes.EKeyRightArrow or (ev == key_codes.EKey6):
            dx = 1
            dy = 0
            #вправо
        elif ev == key_codes.EKeyDownArrow or (ev == key_codes.EKey8):
            dy = 1
            dx = 0
            #вниз
        elif ev == key_codes.EKeyLeftArrow or (ev == key_codes.EKey4):
            dy = 0
            dx = -1
            #влево
    if field[(cy)][(cx)] == 'ST' and field[(cy + dy)][(cx + dx)] == '0':
        field[(cy + dy)][(cx + dx)] = 'S'
        field[cy][cx] = 'T'
    elif field[(cy + dy)][(cx + dx)] == '0' and field[(cy)][(cx)] == 'S':
        field[(cy + dy)][(cx + dx)] = 'S'
        field[cy][cx] = '0'
        scores = scores - 1
    elif field[(cy + dy)][(cx + dx)] == 'T' and field[cy][cx] == 'S':
        field[(cy + dy)][(cx + dx)] = 'ST'
        field[cy][cx] = '0'
    elif field[(cy + dy)][(cx + dx)] == 'T' and field[cy][cx] == 'ST':
        field[(cy + dy)][(cx + dx)] = 'ST'
        field[cy][cx] = 'T'

    elif field[(cy + dy)][(cx +
                           dx)] == 'TB' and field[cy][cx] == 'S' and field[(
                               cy + 2 * dy)][(cx + 2 * dx)] == '0':
        isinstalled = isinstalled - 1
        field[(cy + dy)][(cx + dx)] = 'ST'
        field[cy][cx] = '0'
        field[(cy + 2 * dy)][(cx + 2 * dx)] = 'B'

    elif field[(cy + dy)][(cx +
                           dx)] == 'TB' and field[cy][cx] == 'ST' and field[(
                               cy + 2 * dy)][(cx + 2 * dx)] == 'T':
        field[(cy + dy)][(cx + dx)] = 'ST'
        field[cy][cx] = 'T'
        field[(cy + 2 * dy)][(cx + 2 * dx)] = 'TB'
    elif field[(cy + dy)][(cx +
                           dx)] == 'TB' and field[cy][cx] == 'S' and field[(
                               cy + 2 * dy)][(cx + 2 * dx)] == 'T':
        #      isinstalled=isinstalled-1
        field[(cy + dy)][(cx + dx)] = 'ST'
        field[cy][cx] = '0'
        field[(cy + 2 * dy)][(cx + 2 * dx)] = 'TB'

    elif (field[(cy + dy)][(cx + dx)]
          == 'B') and (field[(cy + 2 * dy)][(cx + 2 * dx)]
                       == '0') and field[(cy)][(cx)] == 'ST':
        field[(cy + 2 * dy)][(cx + 2 * dx)] = 'B'
        field[(cy + dy)][(cx + dx)] = 'S'
        field[cy][cx] = 'T'
    elif (field[(cy + dy)][(cx + dx)]
          == 'B') and (field[(cy + 2 * dy)][(cx + 2 * dx)]
                       == '0') and field[(cy)][(cx)] == 'S':
        field[(cy + 2 * dy)][(cx + 2 * dx)] = 'B'
        field[(cy + dy)][(cx + dx)] = 'S'
        field[cy][cx] = '0'

        scores = scores + 1
    elif (field[(cy + dy)][(cx + dx)]
          == 'B') and (field[(cy + 2 * dy)][(cx + 2 * dx)] == 'T'):
        scores = scores + 100
        field[(cy + 2 * dy)][(cx + 2 * dx)] = 'TB'
        field[(cy + dy)][(cx + dx)] = 'S'
        field[cy][cx] = '0'
        isinstalled = isinstalled + 1

    if (isinstalled == n):
        import os
        global path0
        if level < len(os.listdir(path0 + 'levels\\')):
            del os
            buffer.clear(0x0)
            level = level + 1
            field = levelloader.open(level)
            setresize()
        else:
            isinstalled = 0
            n = 0
            a.note(u'game over')
            main()
    if event['type'] == 1:
        redraw()
Example #57
0
import mymodule, appuifw

appuifw.note(u"This is the main program")
mymodule.askword()
Example #58
0
 def disconnect(self):
     try:
         ui.note(u'Disconnecting...', 'info', 1)
         self.ftp.quit()
     except all_errors, error:
         ui.note(u(error), 'error')
Example #59
0
import appuifw
def cn(x):return x.decode("utf-8")
#异常捕获,若不执行测试的内容就会捕获到异常
try:
    a,b=appuifw.multi_query(cn("乐讯昵称"), cn("乐讯ID"))
    appuifw.note(a+"\n"+b, "info")

except: 
   appuifw.note(cn("你选择了否"), "info")
Example #60
0
 def listbox_control(self):
     entries = [u'Item1', u'Item2', u'Item3']
     appuifw.app.body = self.list_box = \
                                 appuifw.Listbox(entries)
     appuifw.note(u'Listbox view should not have the Virtual KeyPad')