Example #1
0
 def Run(self):
     self.running = True
     count = 60
     while self.running:
         if not self.screensaver:
             e32.reset_inactivity()
         e32.ao_sleep(0.5)
Example #2
0
 def test_reset_inactivity(self):
     """Check for inactivity and reset_inactivity"""
     e32.ao_sleep(sleep_time)
     sec_inactive = e32.inactivity()
     e32.reset_inactivity()
     sec_after_active = e32.inactivity()
     self.failUnless(sec_inactive > sec_after_active)
def handle_screensaver():
    ''' Reset inactivity timer '''
    global g_screensaver_on
    e32.reset_inactivity()
    g_screensaver_on = True
    screen_timer.cancel()
    screen_timer.after(4, handle_screensaver)
def handle_screensaver():
    global g_screensaver_on
    if screensaver_on:
        e32.reset_inactivity()
        start_timer.cancel()
        start_timer.after(4, handle_screensaver)
    else:
        start_timer.cancel()
Example #5
0
  def update(self, dummy=(0, 0, 0, 0)):
    self.t.cancel()
#    self.canvas.clear()
#  	appuifw.app.exit_key_handler = self.parent.exit_key_handler
    self.canvas.blit(self.map)
    if self.active:
      e32.reset_inactivity()
      self.t.after(0.5, self.update)
Example #6
0
 def writer(self, data):
     e32.reset_inactivity()
     self.size += len(data)
     self.fh.write(data)
     self.download_textinfo.set(
         unicode(
             self.get_unit(self.size) + " of " +
             self.get_unit(self.selected_fsize) + " downloaded\n" +
             "(%.2f %%)" %
             (self.size / float(self.selected_fsize) * 100.0)))
Example #7
0
def handle_screensaver():
    ''' Callback to handle screensaver activation '''
    global g_screensaver_on
    if g_screensaver_on:
        # Reset inactivity timer to keep lights on
        e32.reset_inactivity()
        my_timer.cancel()
        # N82 Settings UI has minimum value 5 seconds
        # Guess: set timeout as 4 seconds
        my_timer.after(4, handle_screensaver)
    else:
        my_timer.cancel()
Example #8
0
def hide():
  # appuifw.app.body.set(u"")
  global __splash, __img
  if __img:
    del __img
    __img = None
    
  if __splash:
    appuifw.app.body = __appbody
    del __splash
    __splash = None

  e32.reset_inactivity()
  e32.ao_yield()
Example #9
0
def show(msg="Loading..."):
  # appuifw.app.body.set(u"Loading...")
  global __splash, __img, __msg
  __msg = unicode(msg)
  if not __splash:
    __splash = appuifw.Canvas(__draw)
    r = min(__splash.size[0],__splash.size[1])*2/3
    try:    img = graphics.Image.open(IMGFILE)
    except: img = graphics.Image.new((r,r)); img.clear(0)
    __img    = img.resize((r,r), keepaspect=True)
    appuifw.app.body = __splash
    del img
  __draw()
  e32.reset_inactivity()
  e32.ao_yield()
Example #10
0
def update_interval():
    ''' More paparazzis and faster '''
    timer_papa.cancel()
    # Add new paparazzis
    global my_interval
    if my_interval > 0.05:
        my_interval -= 0.05

    # BUG: should verify star and (x,y) are not overlapping
    x = random.choice(range(screen_x))
    y = random.choice(range(screen_y))
    g_papa.append((x, y))
    x = random.choice(range(screen_x))
    y = random.choice(range(screen_y))
    g_papa.append((x, y))
    global g_papa_count
    g_papa_count += 2

    timer_papa.after(my_interval, update_papa)
    timer_interval.after(1, update_interval)
    e32.reset_inactivity()
Example #11
0
def update_interval():
    ''' More paparazzis and faster '''
    timer_papa.cancel()
    # Add new paparazzis
    global my_interval
    if my_interval > 0.05:
        my_interval -= 0.05

    # BUG: should verify star and (x,y) are not overlapping
    x = random.choice(range(screen_x))
    y = random.choice(range(screen_y))
    g_papa.append((x, y))
    x = random.choice(range(screen_x))
    y = random.choice(range(screen_y))
    g_papa.append((x, y))
    global g_papa_count
    g_papa_count += 2

    timer_papa.after(my_interval, update_papa)
    timer_interval.after(1, update_interval)
    e32.reset_inactivity()
Example #12
0
def pasek():
    global screen
    global img
    global ekran
    global mp3
    global ladow
    while 1:
        e32.Ao_timer().after(1)
        (rok, mies, dz, godz, min, sek, x, x, x) = time.localtime()
        godz = '%02d' % (godz)
        min = '%02d' % (min)
        sek = '%02d' % (sek)
        if (godz == ustaw[51:53]) and (min == ustaw[53:55]) and (
                sek == '00') and (pb <> 'None'):
            e32.reset_inactivity()
            try:
                appuifw.e32.start_exe(
                    u'c:\\sys\\bin\\' + unicode(pb) + u'.exe', '')
            except:
                try:
                    appuifw.e32.start_exe(
                        u'e:\\sys\\bin\\' + unicode(pb) + u'.exe', '')
                except:
                    try:
                        appuifw.e32.start_exe(
                            u'z:\\sys\\bin\\' + unicode(pb) + u'.exe', '')
                    except:
                        pass
        try:
            if (int(ustaw[36:39]) <> 0) and (sysinfo.active_profile() <>
                                             u'silent'):
                if ((int(min) == 0) and (int(sek) == 0)
                        or (int(sysinfo.battery()) == 100) and (ladow > 0)):
                    if (int(sysinfo.battery()) == 100) and (ladow > 0):
                        ladow = 0
                    if os.path.isdir(sciezkaplik):
                        if (int(min) == 0) and (int(sek) == 0):
                            mp3 = audio.Sound.open(
                                unicode(sciezkaplik + '\\' + str(godz) +
                                        '.mp3'))
                        else:
                            mp3 = audio.Sound.open(
                                unicode(sciezkaplik + '\\' + '24.mp3'))
                    else:
                        mp3 = audio.Sound.open(unicode(sciezkaplik))
                    if (int(ustaw[39:42]) < int(ustaw[42:45])) and (
                            int(godz) >= int(ustaw[39:42])) and (
                                int(godz) <= int(ustaw[42:45])):
                        mp3.play()
                    elif (int(ustaw[39:42]) > int(ustaw[42:45])) and (
                        (int(godz) >= int(ustaw[39:42])) or
                        (int(godz) <= int(ustaw[42:45]))):
                        mp3.play()
                    elif int(godz) == int(ustaw[39:42]):
                        mp3.play()
                    audio.Sound.set_volume(
                        mp3,
                        int(
                            audio.Sound.max_volume(mp3) *
                            (float(int(ustaw[36:39])) / float(100))))
            if audio.Sound.state(mp3) <> 2: mp3 = 0
            if (int(min) == 0) and (int(sek) == 0):
                if (int(ustaw[39:42]) < int(ustaw[42:45])) and (
                        int(godz) >= int(ustaw[39:42])) and (int(godz) <= int(
                            ustaw[42:45])):
                    miso.vibrate(500, 100)
                elif (int(ustaw[39:42]) > int(ustaw[42:45])) and (
                    (int(godz) >= int(ustaw[39:42])) or
                    (int(godz) <= int(ustaw[42:45]))):
                    miso.vibrate(500, 100)
                elif int(godz) == int(ustaw[39:42]):
                    miso.vibrate(500, 100)
        except:
            pass
        if int(ustaw[18:21]) == 888:
            img.blit(ima, ((0, 0), (int(ustaw[0:3]), int(ustaw[3:6]))))
        else:
            img.rectangle(
                [(0, 0), (int(ustaw[0:3]), int(ustaw[3:6]))],
                (int(ustaw[18:21]), int(ustaw[21:24]), int(ustaw[24:27])),
                fill=(int(ustaw[18:21]), int(ustaw[21:24]), int(ustaw[24:27])))
        if pb <> 'None':
            img.line([(0, 0), (0, int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), 0),
                      (-1 + int(ustaw[0:3]), int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if fpp[int(ustaw[56:57])] <> 'None':
            img.line([(0, 0), (0, 4)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(0, 0), (4, 0)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), 0), (-1 + int(ustaw[0:3]), 4)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), 0),
                      (-1 - 4 + int(ustaw[0:3]), 0)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), -1 + int(ustaw[3:6])),
                      (-1 - 4 + int(ustaw[0:3]), -1 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), -1 + int(ustaw[3:6])),
                      (-1 + int(ustaw[0:3]), -1 - 4 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(0, -1 + int(ustaw[3:6])),
                      (0, -1 - 4 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(0, -1 + int(ustaw[3:6])), (4, -1 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if ekran > 0:
            e32.reset_inactivity()
            img.line([(0, -1 + int(ustaw[3:6])),
                      (int(ustaw[0:3]), -1 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if ladow > 0:
            img.line([(0, 0), (int(ustaw[0:3]), 0)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if int(ustaw[45:48]) / 10 > 0:
            if int(ustaw[45:48]) / 10 == 1:
                k = unicode(str(godz) + ':' + str(min) + ':' + str(sek))
            elif int(ustaw[45:48]) / 10 == 2:
                k = unicode('%02i' % (dz) + '.' + '%02i' % (mies) + '.' +
                            str(rok))
            elif int(ustaw[45:48]) / 10 == 3:
                k = unicode('%06.3f' %
                            (float(sysinfo.free_ram()) / float(1000000)))
            elif int(ustaw[45:48]) / 10 == 4:
                k = unicode('%03i' % (sysinfo.signal_dbm()) + ' dBm')
            elif int(ustaw[45:48]) / 10 == 5:
                k = unicode('%03i' % (sysinfo.battery()) + ' %')
            if int(ustaw[45:48]) % 10 == 1:
                q = (None, None, graphics.FONT_BOLD | graphics.FONT_ANTIALIAS)
            elif int(ustaw[45:48]) % 10 == 2:
                q = (None, None,
                     graphics.FONT_ITALIC | graphics.FONT_ANTIALIAS)
            elif int(ustaw[45:48]) % 10 == 3:
                q = (None, None, graphics.FONT_BOLD | graphics.FONT_ITALIC
                     | graphics.FONT_ANTIALIAS)
            else:
                q = (None, None, graphics.FONT_ANTIALIAS)
            img.text(
                (int(ustaw[12:15]), int(ustaw[15:18])),
                k,
                font=q,
                fill=(int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            screen.background_color = 0xffffff
        else:
            screen.hide()
Example #13
0
	def writer(self, data):
		e32.reset_inactivity()
		self.size += len(data)
		self.fh.write(data)
		self.download_textinfo.set(unicode(self.get_unit(self.size) + " of " + self.get_unit(self.selected_fsize) + " downloaded\n" + "(%.2f %%)" % (self.size / float(self.selected_fsize) * 100.0)))
	def backlight_on(self):
		print "Backlight On received"
		e32.reset_inactivity()
Example #15
0
def handle_screensaver():
    ''' Reset inactivity timer to disable screen saver '''
    e32.reset_inactivity()
    t_screen.after(4, handle_screensaver)

#Main
data = ( 0, 0, 0 )
prev = (40, 40, 40) #initial zero values for 'previous values' of the data
canvas = appuifw.Canvas() #create a new Canvas object
appuifw.app.body = canvas
appuifw.app.screen = "full" #go 'fullscreen'
appuifw.app.orientation = "landscape" # draw in landscape orientation
appuifw.app.title = u"Activity Monitor" #name the program
app_lock = e32.Ao_lock() #locking system

connect() #open the BT socket
e32.ao_sleep(1) # sleep for 1 second in case of graphical slowness
reset() # initially reset the screen to draw the canvas

while 1: #loop the following code infinitely 
    e32.reset_inactivity() #keep the screensaver away
    graph_data( getData() ) # poll the BT data passing it to the grapher.
    
    #test the movement level between the last two samples
    if ( (abs(data[0] - prev[0]) > sensitivity ) \
    or (abs(data[1] - prev[1]) > sensitivity ) \
    or (abs(data[2] - prev[2]) > sensitivity ) ):
    
        fall() #if too much, take action
        app_lock.wait() #pause this loop until fall() finishes
        e32.ao_sleep(1)
        reset()
        
    prev = data #move current data into previous data buffer
Example #17
0
 def Run(self):
     self.running = True
     while self.running:
         if not self.screensaver:
             e32.reset_inactivity()
         e32.ao_sleep(0.5)
Example #18
0
def handle_screensaver():
    ''' Reset inactivity timer to disable screen saver '''
    e32.reset_inactivity()
    t_screen.after(4, handle_screensaver)
Example #19
0
def handle_screensaver():
    ''' Reset inactivity timer '''
    global g_screensaver_off
    g_screensaver_off = True
    e32.reset_inactivity()
    timer_screen.after(4, handle_screensaver)
Example #20
0
                while pause_timer > 0 and running and pause:
                    cv.clear()
                    cv.text((10,50),_("M_seconds_to_start") % pause_timer)
                    e32.ao_sleep(1)
                    pause_timer -= 1
                if pause_timer == 0: pause = False
                pause_timer = 0    
            e32.ao_sleep(.2)
        continue 
    if (time.time() - last_motion_check) > 5:
        motion.reset()
    last_motion_check = time.time()
    im, stat = motion.get_motion(mark = True)
    if stat:
        if snd <> None  and config.get("audio","enable",0) and (snd.state() & audio.EOpen):
            snd.play()
        check_alarm()
        presence_timer = time.time()
        e32.reset_inactivity()
    check_presence()
    last_photo = None
    cv.blit(im)
    e32.ao_sleep(.2) # Lets relax your phone ;-)
    
if snd:
    snd.close()
        
        
        
    
Example #21
0
def gcgo(gcdir, dirmc):
    import struct, random, lite_fm, uidcrc

    def copy_file(from_dir, to_dir):
        global running
        try:
            f = open(INIpath, 'r')
            Content = f.read()
            f.close()
            R = re.compile('\\[(.*?)->(.*?)\\]')
            ToBeRenamed = R.findall(Content)
            try:
                FN = re.compile('#\\[FileName:(.*?)]')
                Filename = FN.findall(Content)[0]
                MB = re.compile('#\\[MadeBy:(.*?)]')
                Madeby = MB.findall(Content)[0]
                CT = re.compile('#\\[Contact:(.*?)]')
                Contact = CT.findall(Content)[0]
                Filename = cn(Filename)
                Madeby = cn(Madeby)
                Contact = cn(Contact)
                if (running == 0):
                    pt((u'%s\n' % Filename))
                    e32.ao_sleep(1)
                    pt((cn('制作:') + (u'%s\n' % Madeby)))
                    e32.ao_sleep(2)
                    pt((cn('联系方式') + (u'%s' % Contact)))
                    pt(cn('正在读取...'))
                    running = 1
                    e32.ao_sleep(2)
            except:
                pt(cn('未发现作者相关信息'))
        except:
            ToBeRenamed = None
        All_files = os.listdir(en(from_dir))
        pt((cn('创建文件夹:%s') % to_dir))
        os.mkdir(en(to_dir))
        for i in range(0, len(All_files)):
            if (ToBeRenamed != None):
                for ti in ToBeRenamed:
                    if (ti[0].lower() == All_files[i].lower()):
                        try:
                            RenameTo = (ti[1] % ASK_path)
                        except:
                            RenameTo = ti[1]
                        break
                    else:
                        RenameTo = All_files[i]

            else:
                RenameTo = All_files[i]
            if (os.path.isfile(((en(from_dir) + '\\') + All_files[i])) == 1):
                try:
                    pt((cn('复制%s到%s') % (cn(All_files[i]), cn(RenameTo))))
                except:
                    pt((cn('复制%s到%s') % (cn(All_files[i]), RenameTo)))
                try:
                    e32.file_copy(((to_dir + '\\') + cn(RenameTo)),
                                  ((from_dir + '\\') + cn(All_files[i])))
                except:
                    e32.file_copy(((to_dir + '\\') + RenameTo),
                                  ((from_dir + '\\') + cn(All_files[i])))
            else:
                try:
                    RenameTo1 = cn(RenameTo)
                except:
                    RenameTo1 = RenameTo
                copy_file(((from_dir + '\\') + cn(All_files[i])),
                          ((to_dir + '\\') + RenameTo1))


#

    try:
        Capps_path = 'c:\\system\\apps\\'
        Eapps_path = 'e:\\system\\apps\\'

        Source_path = gcdir
        pt((cn('源程序:%s') % cn(Source_path)))
        ASK_path = A.query(cn('请输入共存的程序路径名称(支持中文,但尽量不要中文…)'), 'text', dirmc)
        Source_path = cn(Source_path)
        To_path = (Eapps_path + ASK_path)
        if A.query(cn('使用共存配置文件?(百阅,掌迅通等确认,其它取消!)'), 'query'):
            INIpath = lite_fm.manager(
                u'e:\\system\\apps\\lbcl\\data\\Additionals\\', 'file')
        pt((cn('正在复制%s内所有文件到%s') % (Source_path, To_path)))
        if (os.path.exists(en((Capps_path + ASK_path)))
                or os.path.exists(en((Eapps_path + ASK_path)))):
            A.note((cn('已存在 %s 文件夹,创建取消!') % To_path), 'error')
            return False
        copy_file(Source_path, To_path)
        pt(cn('文件夹内所有文件复制完成!'))
        pt(cn('正在改名...'))
        AppName = Source_path.split(u'\\')[-1]
        NewName = To_path.split(u'\\')[-1]
        pt((cn('源程序名:%s') % AppName))
        try:
            os.rename(en((((To_path + u'\\') + AppName) + u'.app')),
                      en((((To_path + u'\\') + NewName) + u'.app')))
            pt(cn('app文件已经改名完成:)'))
        except:
            pt(cn('app文件改名失败:('))
        try:
            os.rename(en((((To_path + u'\\') + AppName) + u'.aif')),
                      en((((To_path + u'\\') + NewName) + u'.aif')))
            pt(cn('aif文件已经改名完成:)'))
        except:
            pt(cn('aif文件改名失败:('))
        try:
            os.rename(en((((To_path + u'\\') + AppName) + u'.rsc')),
                      en((((To_path + u'\\') + NewName) + u'.rsc')))
            pt(cn('rsc文件已经改名完成:)'))
        except:
            pt(cn('rsc文件改名失败:('))
        try:
            name = A.query(cn('输入显示在功能表里的软件名称'), 'text', cn('不知道…'))
            name1 = (name.encode('utf-16'))[2:]
            len4 = str(hex(((8 + len(name1)) + len(name1))))[2:]
            crsc = open(en((((To_path + u'\\') + NewName) + '_caption.rsc')),
                        'w+')
            crsc.write(((((((((((((len4 + '000500') + '0') + str(
                (len(name1) / 2))) + 'ab') + name1.encode('hex')) + '0') + str(
                    (len(name1) / 2))) + 'ab') + name1.encode('hex')) + '0400')
                         + len4) + '00').decode('hex'))
            crsc.close()
            pt(cn('_caption.rsc文件已经改名完成:)'))
        except:
            pt(cn('_caption.rsc文件改名失败:('))
        pt(cn('\napp,aif,rsc,_caption文件已经改名完成,如果其他文件需要修改,请手动修改.'))
        pt(cn('读取程序数据...'))
        Fan = file(en((((To_path + u'\\') + NewName) + u'.app')))
        app_content = Fan.read()
        Fan.close()
        Fuid = app_content[8:12]
        Ruid = (((Fuid[3:4] + Fuid[2:3]) + Fuid[1:2]) + Fuid[0:1])
        pt((cn('获取到源程序uid:%s') % (Ruid.encode('hex'))))
        uid = hex(random.randrange(16777216, 33554431, 1))
        uid = A.query(cn('请输入8位不同源程序的UID码(建议使用这个)'), 'text', cn(uid[2:]))
        if (uid == None):
            iii('制作取消')
            return False
        uid_int = 0
        try:
            uid_int = int(uid, 16)
        except:
            iii('错误的UID,劝你还是用自动分配的吧')
            return False
        AifFile = [cn('默认图标文件')]
        if os.path.exists(
                en((os.path.split(A.app.full_name())[0] + u'\\data\\Aif\\'))):
            aif_list = os.listdir(
                en((os.path.split(A.app.full_name())[0] + u'\\data\\Aif\\')))
            for i in range(0, len(aif_list)):
                if (cn(aif_list[i]).split('.')[-1] == 'aif'):
                    AifFile.append(cn(aif_list[i]))
                else:
                    continue

        slt = A.popup_menu(AifFile, cn('请选择aif图标文件--'))
        if (slt == 0):
            aif_path = ((os.path.split(A.app.full_name())[0] + u'\\') +
                        u'lbcl.aif')
        else:
            aif_path = (
                (os.path.split(A.app.full_name())[0] + u'\\data\\Aif\\') +
                AifFile[slt])
        pt(cn('读取图标文件...'))
        aif_file = open(en(aif_path), 'r')
        aif_content = aif_file.read()
        aif_file.close()
        pt(cn('请稍候!正在写入图标文件...'))
        uid_1 = int(268435511)
        uid_2 = int(268450360)
        crc = uidcrc.sum(uid_1, uid_2, long(uid, 16))
        aif_file = open(en((((To_path + u'\\') + NewName) + '.aif')), 'w')
        aif_file.write(aif_content[0:8])
        aif_file.write(struct.pack('i', uid_int))
        aif_file.write(crc)
        aif_file.write(aif_content[16:])
        aif_file.close()
        pt(cn('写入图标完成,请稍候!'))
        uid_1 = int(268435577)
        uid_2 = int(268450254)
        crc = uidcrc.sum(uid_1, uid_2, long(uid, 16))
        crc2 = (uid_int + int(932))
        try:
            f = open(INIpath, 'r')
            Content = f.read()
            f.close()
            R = re.compile('ChangeAllUnicode\\[(.*?)->(.*?)\\]')
            RA = re.compile('ChangeAllAscii\\[(.*?)->(.*?)\\]')
            MD = re.compile('MkDir\\[(.*?)\\]')
            ToBeChangedUnicode = R.findall(Content)
            ToBeChangedAscii = RA.findall(Content)
            MakeDirPath = MD.findall(Content)
        except:
            ToBeChangedUnicode = None
            ToBeChangedAscii = None
            MakeDirPath = None
        if (MakeDirPath != None):
            for m in MakeDirPath:
                try:
                    os.mkdir(m)
                    pt((cn('创建文件夹:') + cn(m)))
                except:
                    pt(((cn('不能创建文件夹:') + cn(m)) + cn('\n请自行创建')))
                    e32.ao_sleep(2)

        app_content = (
            ((((app_content[0:8] + struct.pack('i', uid_int)) + crc) +
              app_content[16:24]) + struct.pack('i', crc2)) +
            app_content[28:].replace(Fuid, struct.pack('i', uid_int)))
        app_content_hex = app_content.encode('hex')
        if (ToBeChangedUnicode != None):
            for i in ToBeChangedUnicode:
                try:
                    Ts = (i[1] % ASK_path)
                    try:
                        ASK_path.encode('ascii')
                        A_path = ASK_path
                        Ts = (i[1] % A_path)
                    except:
                        A_path = A.query(cn('您指定的软件名含有中文字符,请指定一个英文名称'),
                                         'query')
                        Ts = (i[1] % A_path)
                except:
                    Ts = i[1]
                UnicodeString = i[0].encode('utf-16').encode('hex')[4:]
                ToUnicodeString = Ts.encode('utf-16').encode('hex')[4:]
                app_content_hex = app_content_hex.replace(
                    UnicodeString, ToUnicodeString)
                pt((cn('已经替换') + (u'%s-->%s' %
                                  (UnicodeString, ToUnicodeString))))

        if (ToBeChangedAscii != None):
            for i in ToBeChangedAscii:
                try:
                    Tsa = (i[1] % ASK_path)
                    try:
                        ASK_path.encode('ascii')
                        A_path = ASK_path
                        Tsa = (i[1] % A_path)
                    except:
                        A_path = A.query(cn('您指定的软件名含有中文字符,请指定一个英文名称'),
                                         'query')
                        Tsa = (i[1] % A_path)
                except:
                    Tsa = i[1]
                AsciiString = i[0].encode('utf-8').encode('hex')
                ToAsciiString = Tsa.encode('utf-8').encode('hex')
                app_content_hex = app_content_hex.replace(
                    AsciiString, ToAsciiString)
                pt((cn('已经替换') + (u'%s-->%s' % (AsciiString, ToAsciiString))))

        app_content = app_content_hex.decode('hex')
        pt(cn('正在写入app程序...\n完成之前切勿进行*任何*其他操作!'))
        pt(cn('请勿切换到其他界面(关键时刻!)'))
        app_file = open(en((((To_path + u'\\') + NewName) + u'.app')), 'w')
        ActivateScreen = 0
        for i in range(0, ((len(app_content) / 10000) + 1)):
            ActivateScreen += 1
            if (ActivateScreen == 3):
                e32.reset_inactivity()
                ActivateScreen = 0
            nowSize = os.path.getsize(
                en((((To_path + u'\\') + NewName) + u'.app')))
            A.app.title = (cn('(操作中,勿动!)\n进度:%s/%s') %
                           (nowSize, len(app_content)))
            if (app_content[(i * 10000):((i + 1) * 10000)] != ''):
                app_file.write(app_content[(i * 10000):((i + 1) * 10000)])

        app_file.close()
        pt(cn('写入app程序完成!'))
        A.app.title = old
        try:
            f = open(INIpath, 'r')
            Content = f.read()
            f.close()
            OT = re.compile('#\\[Others:(.*?)\\]')
            OtherInfo = OT.findall(Content)[0]
            pt((cn('其他信息:\n') + cn(OtherInfo)))
        except:
            A.note(cn("操作成功"), 'conf')
            A.app.title = old
        return True
    except:
        iii("共存取消")
        A.app.title = old
    del struct, random, lite_fm, uidcrc
 def backlight_on(self):
     print "Backlight On received"
     e32.reset_inactivity()
Example #23
0
def _finder_call_back(image_frame):
    global _backlight_on
    global _my_call_back
    if (_backlight_on):
        e32.reset_inactivity()
    _my_call_back(graphics.Image.from_cfbsbitmap(image_frame))
Example #24
0
File: camera.py Project: pymo/pymo
def _finder_call_back(image_frame):
    global _backlight_on
    global _my_call_back
    if(_backlight_on):
        e32.reset_inactivity()
    _my_call_back(graphics.Image.from_cfbsbitmap(image_frame))
Example #25
0
def _handle_request_in_UI_thread(self, channel, method, path, header):
	try:
		try:
			# this is not safe!
			params = (string.join(path.split("?")[1:], "?")).split("&")
			path = path.split("?")[0]
			while path[:1] == "/":
				path = path[1:]
			if path == 'quit':
				print "Exiting ..."
				self.shutdown = 1
				self.close()
				ap.stop()	
				appuifw.app.orientation = 'portrait'				
				appuifw.app.set_exit()
				filename = ""
			elif path == 'takepicture.jpg':			
				print "[camera] => takepicture.jpg ..."					
				e32.reset_inactivity()
				if appuifw.app.orientation == 'portrait':
					print "switching to landscape"
					appuifw.app.orientation = 'landscape'
				size = max(camera.image_sizes("JPEG_Exif"))	
				filename = os.path.join("D:\\", path)
				flash = "none"
				if "&flash=forced" in "&"+"&".join(params):
					flash = "forced"
				appuifw.app.orientation = 'landscape'
				take_picture(filename, size, flash)
				file = open(filename, "rb")
			elif os.path.splitext(path)[1] == '.jpg':
				filename = os.path.join(ROOT, path)
				print path, "=>", filename
				file = open(filename, "rb")				
			else:
				filename = os.path.join(ROOT, path)
				print path, "=>", filename
				file = open(filename, "rb")		
		except IOError:
			print "404 not found"
			channel.pushstatus(404, "Not found")
			channel.push("Content-type: text/html\r\n")
			channel.push("\r\n")
			channel.push("<html><body>File not found.</body></html>\r\n")
		else:
			print "200 OK"
			channel.pushstatus(200, "OK")
			if os.path.splitext(filename)[1] == '.jpg':
				channel.push("Content-type: image/jpeg\r\n")
			elif os.path.splitext(filename)[1] == '.zip':
				channel.push("Content-type: application/x-zip-compressed\r\n")
			else:
				channel.push("Content-type: text/html\r\n")
			fileSize = os.lstat(filename).st_size
			print "sending %d bytes" % (fileSize,)
			channel.push("Content-length: %d\r\n" % (fileSize,))
			channel.push("\r\n")
			channel.push_with_producer(FileProducer(file))
	finally:
		#print "done doing stuff in UI thread"
		self.handle_request_in_UI_thread_executing = 1  # let HTTP server's handle_request() know we're done
Example #26
0
def _handle_request_in_UI_thread(self, channel, method, path, header):
    try:
        try:
            # this is not safe!
            params = (string.join(path.split("?")[1:], "?")).split("&")
            path = path.split("?")[0]
            while path[:1] == "/":
                path = path[1:]
            if path == 'quit':
                print "Exiting ..."
                self.shutdown = 1
                self.close()
                ap.stop()
                appuifw.app.orientation = 'portrait'
                appuifw.app.set_exit()
                filename = ""
            elif path == 'takepicture.jpg':
                print "[camera] => takepicture.jpg ..."
                e32.reset_inactivity()
                if appuifw.app.orientation == 'portrait':
                    print "switching to landscape"
                    appuifw.app.orientation = 'landscape'
                size = max(camera.image_sizes("JPEG_Exif"))
                filename = os.path.join("D:\\", path)
                flash = "none"
                if "&flash=forced" in "&" + "&".join(params):
                    flash = "forced"
                if "&picSize=1600" in "&" + "&".join(params):
                    size = (1600, 1200)
                if "&picSize=1024" in "&" + "&".join(params):
                    size = (1024, 768)
                if "&picSize=640" in "&" + "&".join(params):
                    size = (640, 480)
                appuifw.app.orientation = 'landscape'
                take_picture(filename, size, flash)
                file = open(filename, "rb")
            elif os.path.splitext(path)[1] == '.jpg':
                filename = os.path.join(ROOT, path)
                print path, "=>", filename
                file = open(filename, "rb")
            else:
                filename = os.path.join(ROOT, path)
                print path, "=>", filename
                file = open(filename, "rb")
        except IOError:
            print "404 not found"
            channel.pushstatus(404, "Not found")
            channel.push("Content-type: text/html\r\n")
            channel.push("\r\n")
            channel.push("<html><body>File not found.</body></html>\r\n")
        else:
            print "200 OK"
            channel.pushstatus(200, "OK")
            if os.path.splitext(filename)[1] == '.jpg':
                channel.push("Content-type: image/jpeg\r\n")
            elif os.path.splitext(filename)[1] == '.zip':
                channel.push("Content-type: application/x-zip-compressed\r\n")
            else:
                channel.push("Content-type: text/html\r\n")
            fileSize = os.lstat(filename).st_size
            print "sending %d bytes" % (fileSize, )
            channel.push("Content-length: %d\r\n" % (fileSize, ))
            channel.push("\r\n")
            channel.push_with_producer(FileProducer(file))
    finally:
        #print "done doing stuff in UI thread"
        self.handle_request_in_UI_thread_executing = 1  # let HTTP server's handle_request() know we're done
def ooo():
    if (oo0000 != AIlPLAY):
        return
    e32.reset_inactivity()
    nmn.after(4, ooo)