当前位置: 首页>>代码示例>>Python>>正文


Python ResourceReader.get方法代码示例

本文整理汇总了Python中pp_resourcereader.ResourceReader.get方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceReader.get方法的具体用法?Python ResourceReader.get怎么用?Python ResourceReader.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pp_resourcereader.ResourceReader的用法示例。


在下文中一共展示了ResourceReader.get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
    def button_pressed(self,button,edge):
        if button=='play': self.key_pressed("return")
        elif  button =='up': self.key_pressed("up")
        elif button=='down': self.key_pressed("down")
        elif button=='stop': self.key_pressed("escape")
        elif button=='pause': self.key_pressed('p')
        elif button=='PIR': self.key_pressed('pir')


    # kill or error
    def terminate(self,reason):
        if self.shower<>None:
            self.mon.log(self,"sent terminate to shower")
            self.shower.terminate(reason)
        elif self.player<>None:
            self.mon.log(self,"sent terminate to player")
            self.player.terminate(reason)
        else:
            self._end(reason,'terminated without terminating shower or player')

 
    def _tidy_up(self):
        if self._poll_for_continue_timer<>None:
                self.canvas.after_cancel(self._poll_for_continue_timer)
                self._poll_for_continue_timer=None
        if self._poll_for_interval_timer<>None:
                self.canvas.after_cancel(self._poll_for_interval_timer)
                self._poll_for_interval_timer=None
        if self._interval_timer<>None:
            self.canvas.after_cancel(self._interval_timer)
            self._interval_timer=None

    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            self.terminate("error")
        else:
            return value

# ***************************
# Respond to key/button presses
# ***************************

    def _stop(self,message):
        self._end_mediashow_signal=True
        if self._interval_timer<>None:
            self.canvas.after_cancel(self._interval_timer)

   
    def _next(self):
        # stop track if running and set signal
        self._next_track_signal=True
        if self.shower<>None:
            self.shower.key_pressed("escape")
        else:
            if self.player<>None:
                self.player.key_pressed("escape")

    def _previous(self):
        self._previous_track_signal=True
        if self.shower<>None:
            self.shower.key_pressed("escape")
        else:
            if self.player<>None:
                self.player.key_pressed("escape")
开发者ID:DennisTT,项目名称:pipresents,代码行数:70,代码来源:pp_mediashow.py

示例2: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
            # pass down if show or track running.
            if self.shower<>None:
                self.shower.key_pressed(key_name)
            elif self.player<>None:
                self.player.key_pressed(key_name)
 

    def button_pressed(self,button,edge):
        if button=='play': self.key_pressed("return")
        elif  button =='up': self.key_pressed("up")
        elif button=='down': self.key_pressed("down")
        elif button=='stop': self.key_pressed("escape")
        elif button=='pause': self.key_pressed('p')


       
    # kill or error
    def terminate(self,reason):
        if self.shower<>None:
            self.mon.log(self,"sent terminate to shower")
            self.shower.terminate(reason)
        elif self.player<>None:
            self.mon.log(self,"sent terminate to player")
            self.player.terminate(reason)
        else:
            self._end(reason,'terminated without terminating shower or player')

 
    def _tidy_up(self):
        pass


    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            self.terminate("error",'Cannot find resource')
        else:
            return value
        

# ***************************
# Respond to key/button presses
# ***************************

    def _stop(self,message):
        self._end_liveshow_signal=True

        
    def _play_child(self):
        self._play_child_signal=True
        if self.player<>None:
            self.player.key_pressed("escape")
      
        
# ***************************
# end of show functions
# ***************************

    def _end(self,reason,message):
        self._end_liveshow_signal=False
        self.mon.log(self,"Ending Liveshow: "+ self.show['show-ref'])
        self._tidy_up()
        self._end_callback(reason,message)
        self=None
        return
开发者ID:DennisTT,项目名称:pipresents,代码行数:70,代码来源:pp_liveshow.py

示例3: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
        elif symbol=='pp-shutdown':
            self.shutdown_pressed('delay')
        elif symbol=='pp-shutdownnow':
            self.shutdown_pressed('now')
        else:
            for show in self.show_manager.shows:
                show_obj=show[ShowManager.SHOW_OBJ]
                if show_obj<>None:
                    show_obj.input_pressed(symbol,edge,source)


# **************************************
# respond to exit inputs by terminating
# **************************************

    def shutdown_pressed(self, when):
        if when=='delay':
            self.root.after(5000,self.on_shutdown_delay)
        else:
            self.shutdown_required=True
            self.exit_pressed()           

    def on_shutdown_delay(self):
        if self.ppio.shutdown_pressed():
            self.shutdown_required=True
            self.exit_pressed()

         
    def exit_pressed(self):
        self.mon.log(self, "kill received from user")
        #terminate any running shows and players     
        self.mon.log(self,"kill sent to shows")   
        self.terminate('killed')


     # kill or error
    def terminate(self,reason):
        needs_termination=False
        for show in self.show_manager.shows:
            if show[ShowManager.SHOW_OBJ]<>None:
                needs_termination=True
                self.mon.log(self,"Sent terminate to show "+ show[ShowManager.SHOW_REF])
                show[ShowManager.SHOW_OBJ].terminate(reason)
        if needs_termination==False:
            self.end(reason,'terminate - no termination of lower levels required')


# ******************************
# Ending Pi Presents after all the showers and players are closed
# **************************

    def end(self,reason,message):
        self.mon.log(self,"Pi Presents ending with message: " + reason + ' ' + message)
        if reason=='error':
            self.tidy_up()
            self.mon.log(self, "exiting because of error")
            #close logging files 
            self.mon.finish()
            exit()            
        else:
            self.tidy_up()
            self.mon.log(self,"no error - exiting normally")
            #close logging files 
            self.mon.finish()
            if self.shutdown_required==True:
                call(['sudo', 'shutdown', '-h', '-t 5','now'])
                exit()
            else:
                exit()


    
    # tidy up all the peripheral bits of Pi Presents
    def tidy_up(self):
        #turn screen blanking back on
        if self.options['noblank']==True:
            call(["xset","s", "on"])
            call(["xset","s", "+dpms"])
            
        # tidy up gpio
        if self.options['gpio']==True and self.ppio<>None:
            self.ppio.terminate()
            
        #tidy up time of day scheduler
        if self.tod<>None:
            self.tod.terminate()



# *****************************
# utilitities
# ****************************

    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            self.terminate("error")
        else:
            return value
开发者ID:PhillipNordwall,项目名称:pipresents-next,代码行数:104,代码来源:pipresents.py

示例4: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
                anchor=N
                justify=CENTER
            elif text_mode=='overlay' and self.show_params['menu-icon-mode']  in ('thumbnail','bullet'):
                anchor=CENTER
                justify=CENTER
            else:
                anchor=W
                justify=LEFT
            text_id=self.canvas.create_text(text_x,text_y,
                                       text=self.medialist.selected_track()['title'],
                                       anchor=anchor,
                                       fill=self.show_params['entry-colour'],
                                       font=self.show_params['entry-font'],
                                       width=self.text_width,
                                       justify=justify,
                                       tag='pp-content')
            return text_id
        

    def highlight_menu_entry(self,index,state):
        if self.show_params['menu-icon-mode']<>'none':
            if state==True:
                self.canvas.itemconfig(self.menu_entry_id[index][self.icon_id_index],
                                       outline=self.show_params['entry-select-colour'],
                                       width=4,
                                       )
            else:
                self.canvas.itemconfig(self.menu_entry_id[index][self.icon_id_index],
                                        outline='',
                                       width=1
                                       )
        else:
            if state==True:
                self.canvas.itemconfig(self.menu_entry_id[index][self.text_id_index],
                                       fill=self.show_params['entry-select-colour'])
            else:
                self.canvas.itemconfig(self.menu_entry_id[index][self.text_id_index],
                                    fill=self.show_params['entry-colour'])
                

    
    def display_eggtimer(self,text):
        # print "display eggtimer"
        self.canvas.create_text(int(self.canvas['width'])/2,
                                              int(self.canvas['height'])/2,
                                                  text= text,
                                                  fill='white',
                                                  font="Helvetica 20 bold",
                                                   tag='pp-eggtimer')
        self.canvas.update_idletasks( )


    def delete_eggtimer(self):
        # print"delete eggtimer"
        self.canvas.delete('pp-eggtimer')
        self.canvas.update_idletasks( )


# *********************
# utilities
# *********************

    def complete_path(self,track_file):
        #  complete path of the filename of the selected entry
        if track_file<>'' and track_file[0]=="+":
                track_file=self.pp_home+track_file[1:]
        return track_file     

    def parse_menu_window(self,line):
            if line<>'':
                fields = line.split()
                if len(fields) not in  (1, 2,4):
                    return 'error','wrong number of fields',0,0,0,0
                if len(fields)==1:
                    if fields[0]=='fullscreen':
                        return 'normal','',0,0,self.screen_width - 1, self.screen_height - 1
                    else:
                        return 'error','single field is not fullscreen',0,0,0,0
                if len(fields)==2:                    
                    if fields[0].isdigit() and fields[1].isdigit():
                        return 'normal','',int(fields[0]),int(fields[1]),self.screen_width, self.screen_height
                    else:
                        return 'error','field is not a digit',0,0,0,0
                if len(fields)==4:                    
                    if fields[0].isdigit() and fields[1].isdigit() and fields[2].isdigit() and fields[3].isdigit():
                        return 'normal','',int(fields[0]),int(fields[1]),int(fields[2]),int(fields[3])
                else:
                     return 'error','field is not a digit',0,0,0,0
            else:
                     return 'error','line is blank',0,0,0,0


    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            # timers may be running so need terminate
            self.terminate("error")
        else:
            return value
开发者ID:KenT2,项目名称:pipresents-next,代码行数:104,代码来源:pp_menushow.py

示例5: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]
class LiveShow:
    """ plays a set of tracks the content of which is dynamically specified by plaacing track files
                in one of two directories. Tracks are played in file leafname alphabetical order.
                Can be interrupted
    """
            
# *******************
# External interface
# ********************

    def __init__(self,
                            show_params,
                             root,
                            canvas,
                            showlist,
                             pp_dir,
                            pp_home,
                            pp_profile):

        self.mon=Monitor()
        self.mon.on()
        
        #instantiate arguments
        self.show_params =show_params
        self.showlist=showlist
        self.root=root
        self.canvas=canvas
        self.pp_dir=pp_dir
        self.pp_home=pp_home
        self.pp_profile=pp_profile

        # open resources
        self.rr=ResourceReader()

        #create and instance of TimeOfDay scheduler so we can add events
        self.tod=TimeOfDay()


        # Init variables
        self.player=None
        self.shower=None
        self.end_liveshow_signal=False
        self.end_trigger_signal= False
        self.play_child_signal = False
        self.error=False
        self.egg_timer=None
        self.duration_timer=None
        self.state='closed'
        self.livelist=None
        self.new_livelist= None



    def play(self,show_id,end_callback,ready_callback, top=False,command='nil'):
	global defaultDur
	if defaultDur == None:
		defaultDur = self.showlist.get_dur()

        #instantiate the arguments
        self.show_id=show_id
        self.end_callback=end_callback
        self.ready_callback=ready_callback
        self.top=top
        self.mon.log(self,"Starting show: " + self.show_params['show-ref'])



        # check  data files are available.
        self.media_file = self.pp_profile + os.sep + self.show_params['medialist']
        if not os.path.exists(self.media_file):
            self.mon.err(self,"Medialist file not found: "+ self.media_file)
            self.end_liveshow_signal=True

            
        self.options=command_options()
               
        self.pp_live_dir1 = self.pp_home + os.sep + 'pp_live_tracks'
        if not os.path.exists(self.pp_live_dir1):
            os.mkdir(self.pp_live_dir1)
            os.mkdir(self.pp_live_dir1+os.sep+ 'Archive')

        self.pp_live_dir2=''   
        if self.options['liveshow'] <>"":
            self.pp_live_dir2 = self.options['liveshow']
            if not os.path.exists(self.pp_live_dir2):
                self.mon.err(self,"live tracks directory not found " + self.pp_live_dir2)
                self.end('error',"live tracks directory not found")

        #create a medialist for the liveshow and read it.
        # it should be empty of anonymous tracks but read it to check its version.
        self.medialist=MediaList()

        if self.medialist.open_list(self.media_file,self.showlist.sissue())==False:
            self.mon.err(self,"Version of medialist different to Pi Presents")
            self.end('error',"Version of medialist different to Pi Presents")

        #get control bindings for this show if top level
        controlsmanager=ControlsManager()
        if self.top==True:
            self.controls_list=controlsmanager.default_controls()
#.........这里部分代码省略.........
开发者ID:jamie314159,项目名称:pipresents-next,代码行数:103,代码来源:pp_liveshow.py

示例6: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
        self.mon.log(self,"Pi Presents ending with message: " + message)
        self.show=None
        if reason=='error':
            self.mon.log(self, "exiting because of error")
            self.tidy_up()
            exit()            
        if reason=='killed':
            self.mon.log(self,"kill received - exiting")
            self.on_kill_callback()
        else:
            # should never be here or fatal error
            self.mon.log(self, "exiting because invalid end reasosn")
            self.tidy_up()
            exit()

             

# *********************
# EXIT APP
# *********************

    # kill or error
    def terminate(self,reason):
        if self.shower<>None:
            self.mon.log(self,"sent terminate to shower")
            self.shower.terminate(reason)
        else:
            self._end(reason,message)



    def tidy_up(self):
        #turn screen blanking back on
        if self.options['noblank']==True:
            call(["xset","s", "on"])
            call(["xset","s", "+dpms"])
        if self.options['gpio']==True:
            self.buttons.kill()
        #close logging files 
        self.mon.finish()

    def on_kill_callback(self):
        self.tidy_up()
        if self.shutdown_required==True:
            call(['sudo', 'shutdown', '-h', '-t 5','now'])
        else:
            exit()


    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            self.terminate("error")
        else:
            return value

# *********************
# Key and button presses
# ********************

    def shutdown_pressed(self):
        self.root.after(5000,self.on_shutdown_delay)

    def on_shutdown_delay(self):
        if self.buttons.is_pressed(self.Buttons.SHUTDOWN):
            self.shutdown_required=True
            self.on_break_key()

    def button_pressed(self,index,button,edge):
        self.mon.log(self, "Button Pressed: "+button)
        if button=="shutdown":
            self.shutdown_pressed()
        else:
            if self.show<>None:
                self.show.button_pressed(button,edge)
  
    # key presses
    def _escape_pressed(self,event): self._key_pressed("escape")              
    def _up_pressed(self,event): self._key_pressed("up")  
    def _down_pressed(self,event): self._key_pressed("down")  
    def _return_pressed(self,event): self._key_pressed("return")
    def _pause_pressed(self,event): self._key_pressed("p")
        

    def _key_pressed(self,key_name):
        self.mon.log(self, "Key Pressed: "+ key_name)
        # if a show is running pass the key to it.
        if self.show<>None:
            self.show.key_pressed(key_name)
         
    def on_break_key(self):
        self.mon.log(self, "kill received from user")
        #terminate any running shows and players     
        if self.show<>None:
            self.mon.log(self,"kill sent to show")   
            self.show.terminate('killed')
    
    def e_on_break_key(self,event):
        self.on_break_key()
开发者ID:DennisTT,项目名称:pipresents,代码行数:104,代码来源:pipresents.py

示例7: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
    def end(self,reason,message):
        self.end_mediashow_signal=False
        self.mon.log(self,self.show_params['show-ref']+ ' '+ str(self.show_id)+ ": Ending Mediashow")
        self.tidy_up()
        self.end_callback(self.show_id,reason,message)
        self=None
        return

    def tidy_up(self):
        #clear outstanding time of day events for this show
        # self.tod.clear_times_list(id(self))
        if self.poll_for_continue_timer<>None:
                self.canvas.after_cancel(self.poll_for_continue_timer)
                self.poll_for_continue_timer=None
        if self.poll_for_interval_timer<>None:
                self.canvas.after_cancel(self.poll_for_interval_timer)
                self.poll_for_interval_timer=None
        if self.interval_timer<>None:
            self.canvas.after_cancel(self.interval_timer)
            self.interval_timer=None
        if self.duration_timer<>None:
            self.canvas.after_cancel(self.duration_timer)
            self.duration_timer=None


# ***************************
# displaying things
# ***************************
    
    def display_eggtimer(self,text):
        self.canvas.create_text(int(self.canvas['width'])/2,
                                              int(self.canvas['height'])/2,
                                                  text= text,
                                                  fill='white',
                                                  font="Helvetica 20 bold",
                                                tag='pp-eggtimer')
        self.canvas.update_idletasks( )


    def delete_eggtimer(self):
        self.canvas.delete('pp-eggtimer')
        self.canvas.update_idletasks( )


    # used to display internal messages in situations where a medialist entry could not be used.
    def display_message(self,canvas,source,content,duration,_display_message_callback):
            self.display_message_callback=_display_message_callback
            tp={'duration':duration,'message-colour':'white','message-font':'Helvetica 20 bold','background-colour':'',
                'message-justify':'left','background-image':'','show-control-begin':'','show-control-end':'',
                'animate-begin':'','animate-clear':'','animate-end':'','message-x':'','message-y':'',
                'display-show-background':'no','display-show-text':'no','show-text':'','track-text':'',
                'plugin':''}
            self.player=MessagePlayer(self.show_id,self.root,canvas,tp,tp,self.pp_dir,self.pp_home,self.pp_profile)
            self.player.play(content,self.showlist,self.display_message_end,None,False)

    def   display_message_end(self,reason,message):
        self.player=None
        if reason in ('error','killed'):
            self.end(reason,message)
        else:
            self.display_message_callback()



# ***************************
# utilities
# ***************************

    def calculate_duration(self,line):
        fields=line.split(':')
        if len(fields)==1:
            secs=fields[0]
            minutes='0'
            hours='0'
        if len(fields)==2:
            secs=fields[1]
            minutes=fields[0]
            hours='0'
        if len(fields)==3:
            secs=fields[2]
            minutes=fields[1]
            hours=fields[0]
        self.duration=3600*long(hours)+60*long(minutes)+long(secs)
        return ''

    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            self.terminate("error")
        else:
            return value
        
    def complete_path(self,selected_track):
        #  complete path of the filename of the selected entry
        track_file = selected_track['location']
        if track_file<>'' and track_file[0]=="+":
                track_file=self.pp_home+track_file[1:]
        self.mon.log(self,self.show_params['show-ref']+ ' '+ str(self.show_id)+ ": Track to play is: "+ track_file)
        return track_file     
开发者ID:drewkeller,项目名称:pipresents-next,代码行数:104,代码来源:pp_mediashow.py

示例8: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........

            elif selected_show['type']=="menu": 
                self.shower= MenuShow(selected_show,
                                                          self.root,
                                                        self.canvas,
                                                        self.showlist,
                                                        self.pp_dir,
                                                        self.pp_home,
                                                        self.pp_profile)
                self.shower.play(self.show_id,self.end_shower,self.ready_callback,top=False,command='nil')                    
            else:
                self.mon.err(self,"Unknown Show Type: "+ selected_show['type'])
                self.end("Unknown show type")  
                
        else:
            self.mon.err(self,"Unknown Track Type: "+ track_type)
            self.end("Unknown track type")

    
    # callback from when player ends
    def end_player(self,reason,message):
        self.mon.log(self,"Returned from player with message: "+ message)
        self.player=None
        # this does not seem to change the colour of the polygon
        # self.canvas.itemconfig('pp-click-area',state='hidden')
        self.canvas.update_idletasks( )
        if reason in("killed","error"):
            self.end(reason,message)
        else:
            #self.display_eggtimer(self.resource('radiobuttonshow','m02'))
            self.what_next()

    # callback from when shower ends
    def end_shower(self,show_id,reason,message):
        self.mon.log(self,"Returned from shower with message: "+ message)
        self.shower=None
        # self.canvas.itemconfig('pp-click-area',state='hidden')
        self.canvas.update_idletasks( )
        if reason in ("killed","error"):
            self.end(reason,message)
        else:
            #self.display_eggtimer(self.resource('radiobuttonshow','m03'))
            self.what_next()  


# *********************
# End the show
# *********************
    # finish the player for killing, error or normally
    # this may be called directly sub/child shows or players are not running
    # if they might be running then need to call terminate.

    def end(self,reason,message):
        self.mon.log(self,"Ending radiobuttonshow: "+ self.show_params['show-ref'])  
        self.end_callback(self.show_id,reason,message)
        self=None
        return




# *********************
# displaying things
# *********************

    def display_eggtimer(self,text):
        #self.egg_timer=self.canvas.create_text(int(self.canvas['width'])/2,
                                              #int(self.canvas['height'])/2,
                                                  #text= text,
                                                # fill='white',
                                               # font="Helvetica 20 bold")
        #self.canvas.update_idletasks( )
        pass


    def delete_eggtimer(self):
        if self.egg_timer!=None:
            self.canvas.delete(self.egg_timer)

# *********************
# utilities
# *********************

    def complete_path(self,selected_track):
        #  complete path of the filename of the selected entry
        track_file = selected_track['location']
        if track_file<>'' and track_file[0]=="+":
                track_file=self.pp_home+track_file[1:]
        self.mon.log(self,"Track to play is: "+ track_file)
        return track_file     


    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            # players or showers may be running so need terminate
            self.terminate("error")
        else:
            return value
开发者ID:KenT2,项目名称:pipresents-next,代码行数:104,代码来源:pp_radiobuttonshow.py

示例9: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
        for start_show in self.start_shows:
            if start_show[PiPresents.SHOW]<>None:
                needs_termination=True
                self.mon.log(self,"Sent terminate to show "+ start_show[PiPresents.NAME])
                start_show[PiPresents.SHOW].terminate(reason)
        if needs_termination==False:
            self._end(reason)



    def tidy_up(self):
        #turn screen blanking back on
        if self.options['noblank']==True:
            call(["xset","s", "on"])
            call(["xset","s", "+dpms"])
        # tidy up gpio
        if self.options['gpio']==True and self.ppio<>None:
            self.ppio.terminate()
        #tidy up time of day scheduler
        if self.tod<>None:
            self.tod.terminate()
        #close logging files 
        self.mon.finish()

        
    def on_kill_callback(self):
        self.tidy_up()
        if self.shutdown_required==True:
            call(['sudo', 'shutdown', '-h', '-t 5','now'])
        else:
            exit()

    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            self.terminate("error")
        else:
            return value

# *********************
# Key and button presses
# ********************

    def shutdown_pressed(self):
        self.root.after(5000,self.on_shutdown_delay)

    def on_shutdown_delay(self):
        if self.ppio.is_pressed('shutdown'):
            self.shutdown_required=True
            self.on_break_key()

    def button_pressed(self,index,button,edge):
        self.mon.log(self, "Button Pressed: "+button)
        if button=="shutdown":
            self.shutdown_pressed()
        else:
            for start_show in self.start_shows:
                print "sending to show" , start_show[PiPresents.NAME]
                start_show[PiPresents.SHOW].button_pressed(button,edge)                 

  
    # key presses - convert from events to call to _key_pressed
    def _escape_pressed(self,event): self._key_pressed("escape")              
    def _up_pressed(self,event): self._key_pressed("up")  
    def _down_pressed(self,event): self._key_pressed("down")  
开发者ID:papiertiger,项目名称:pipresents-next,代码行数:70,代码来源:pipresents.py

示例10: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
        
# *******************
# internal functions
# *******************

    def _stop(self):
        self.quit_signal=True
        
    def _error(self):
        self.error=True
        self.quit_signal=True
  
     #called when back porch has completed or quit signal is received
    def _end(self,reason,message):
        if self._tick_timer<>None:
            self.canvas.after_cancel(self._tick_timer)
            self._tick_timer=None
        self.quit_signal=False
        # self.canvas.delete(ALL)
        self.canvas.update_idletasks( )
        self.state=self.NO_SLIDE
        if self.error==True:
            self.end_callback("error",message)
            self=None          
        elif self.kill_required_signal==True:
            self.end_callback("killed",message)
            self=None           
        else:
            self.end_callback(reason,message)
            self=None


    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            self._error()
        else:
            return value



    def _start_front_porch(self):
        self.state=ImagePlayer.SLIDE_IN
        self.porch_counter=0
        if self.ready_callback<>None: self.ready_callback()

        if self.transition=="cut":
            #just display the slide full brightness. No need for porch but used for symmetry
            if self.pil_image<>None:
                self.tk_img=PIL.ImageTk.PhotoImage(self.pil_image)
                self.drawn = self.canvas.create_image(self.centre_x, self.centre_y,
                                                      image=self.tk_img, anchor=CENTER)

  
        elif self.transition=="fade":
            #experimental start black and increase brightness (controlled by porch_counter).
            self._display_image()

        elif self.transition == "slide":
            #experimental, start in middle and move to right (controlled by porch_counter)
            if self.pil_image<>None:
                self.tk_img=PIL.ImageTk.PhotoImage(self.pil_image)
                self.drawn = self.canvas.create_image(self.centre_x, self.centre_y,
                                                  image=self.tk_img, anchor=CENTER)
            
开发者ID:DennisTT,项目名称:pipresents,代码行数:69,代码来源:pp_imageplayer.py

示例11: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
                self.player.key_pressed(key_name)
 
 
    def button_pressed(self,button,edge):
        if button=='play': self.key_pressed("return")
        elif  button =='up': self.key_pressed("up")
        elif button=='down': self.key_pressed("down")
        elif button=='stop': self.key_pressed("escape")
        elif button=='pause': self.key_pressed('p')

        
    # kill or error
    def terminate(self,reason):
        if self.shower<>None:
            self.mon.log(self,"sent terminate to shower")
            self.shower.terminate(reason)
        elif self.player<>None:
            self.mon.log(self,"sent terminate to player")
            self.player.terminate(reason)
        else:
            self._end(reason,'terminated without terminating shower or player')



# *********************
# INTERNAL FUNCTIONS
# ********************

# *********************
# language resources
# *********************

    def resource(self,section,item):
        value=self.rr.get(section,item)
        if value==False:
            self.mon.err(self, "resource: "+section +': '+ item + " not found" )
            # timers may be running so need terminate
            self.terminate("error")
        else:
            return value


# *********************
# Sequencing
# *********************

    def _timeout_menu(self):
        self._end('normal','menu timeout')
        return
        
    
    # finish the player for killing, error or normally
    # this may be called directly sub/child shows or players are not running
    # if they might be running then need to call terminate.
    
    def _end(self,reason,message):
        # self.canvas.delete(ALL)
        # self.canvas.update_idletasks( )
        self.mon.log(self,"Ending menushow: "+ self.show_params['show-ref'])  
        if self.menu_timeout_running<>None:
            self.canvas.after_cancel(self.menu_timeout_running)
            self.menu_timeout_running=None
        self.end_callback(self.show_id,reason,message)
        self=None
        return
开发者ID:papiertiger,项目名称:pipresents-next,代码行数:69,代码来源:pp_menushow.py

示例12: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
                self.end_callback(reason,message)
                self=None
            else:
                #display content
                reason,message=self.display_content()
                if reason == 'error':
                    self.mon.err(self,message)
                    self.end_callback(reason,message)
                    self=None
                else:
                    # create animation events
                    reason,message=self.ppio.animate(self.animate_begin_text,id(self))
                    if reason=='error':
                        self.mon.err(self,message)
                        self.end_callback(reason,message)
                        self=None
                    else:                              
                        # start dwelling
                        self.mon.log(self,'playing track from show Id: '+str(self.show_id))
                        self.start_dwell()

        
    def input_pressed(self,symbol):
        if symbol =='pause':
            self.pause()
        elif symbol=='stop':
            self.stop()
            return

    def terminate(self,reason):
        # no lower level things to terminate so just go to end
        self.end(reason,'kill or error')

    def get_links(self):
        return self.track_params['links']
      
# *******************
# internal functions
# *******************

    def pause(self):
        if not self.paused:
            self.paused = True
        else:
            self.paused=False

        #print "self.paused is "+str(self.paused)

    def stop(self):
        self.quit_signal=True
        


        
# ******************************************
# Sequencing
# ********************************************

    def start_dwell(self):

        if self.ready_callback<>None:
            self.ready_callback()
        self.state=ImagePlayer.SLIDE_DWELL
        self.tick_timer=self.canvas.after(self.tick, self.do_dwell)

        
开发者ID:najoshi,项目名称:pipresents-next-digital-photo-frame,代码行数:68,代码来源:pp_imageplayer.py

示例13: __init__

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]

#.........这里部分代码省略.........
            if self.shower <> None:
                self.shower.key_pressed("escape")
            elif self.player <> None:
                self.player.key_pressed("escape")

    # kill or error
    def terminate(self, reason):
        if self.shower <> None:
            self.mon.log(self, "sent terminate to shower")
            self.shower.terminate(reason)
        elif self.player <> None:
            self.mon.log(self, "sent terminate to player")
            self.player.terminate(reason)
        else:
            self._end(reason, "terminated without terminating shower or player")

    def _tidy_up(self):
        # clear outstanding time of day events for this show
        self.tod.clear_times_list(id(self))
        if self._poll_for_continue_timer <> None:
            self.canvas.after_cancel(self._poll_for_continue_timer)
            self._poll_for_continue_timer = None
        if self._poll_for_interval_timer <> None:
            self.canvas.after_cancel(self._poll_for_interval_timer)
            self._poll_for_interval_timer = None
        if self._interval_timer <> None:
            self.canvas.after_cancel(self._interval_timer)
            self._interval_timer = None
        if self.duration_timer <> None:
            self.canvas.after_cancel(self.duration_timer)
            self.duration_timer = None

    def resource(self, section, item):
        value = self.rr.get(section, item)
        if value == False:
            self.mon.err(self, "resource: " + section + ": " + item + " not found")
            self.terminate("error")
        else:
            return value

    # ***************************
    # Do actions as a result of events
    # ***************************

    def _stop(self, message):
        self._end_mediashow_signal = True
        if self._interval_timer <> None:
            self.canvas.after_cancel(self._interval_timer)

    def _next(self):
        # stop track if running and set signal
        self._next_track_signal = True
        if self.shower <> None:
            self.shower.key_pressed("escape")
        else:
            if self.player <> None:
                self.player.key_pressed("escape")

    def _previous(self):
        self._previous_track_signal = True
        if self.shower <> None:
            self.shower.key_pressed("escape")
        else:
            if self.player <> None:
                self.player.key_pressed("escape")
开发者ID:papiertiger,项目名称:pipresents-next,代码行数:69,代码来源:pp_mediashow.py

示例14: tracks

# 需要导入模块: from pp_resourcereader import ResourceReader [as 别名]
# 或者: from pp_resourcereader.ResourceReader import get [as 别名]
class HyperlinkShow:
    """
        Aimed at touchscreens but can be used for any purpose where the user is required to follow hyperlinks between tracks
        Profiles for media tracks (message, image, video, audio ) specify links to other tracks
        in a link a symbolic name of an input is associated with a track-reference
        The show begins at first-track and then uses events (GPIO, keypresses etc.) to link to other tracks via their symbolic names
        If using 'call' keeps a record of the tracks it has visited so the 'return' command can go back.
        Executes timeout-track if no user input is received.

        links are of the form:
           symbolic-name command [track-ref]
        
        link commands:
          call <track-ref> play track-ref and add it to the path
          return - return 1 back up the path removing the track from the path, stops at home-track.
          return n - return n tracks back up the path removing the track from the path, stops at home-track.
          return <track-ref> return to <track-ref> removing tracks from the path
          home  - return to home-track removing tracks from the path
          jump <track-ref-> - play trck-ref forgetting the path back to home-track
          goto <track-ref> - play track-ref, forget the path 
          exit - end the hyperlink show
          null - inhibits the link defined in the show with the same symbolic name.

          reserved symbolic names
          pp-onend command  - pseudo symbolic name for end of a track

        interface:
         * play - selects the first track to play (first-track) 
         * input_pressed,  - receives user events passes them to a Shower/Player if a track is playing,
                otherwise actions them depending on the symbolic name supplied
    """

# *********************
# external interface
# ********************

    def __init__(self,
                            show_params,
                            root,
                            canvas,
                            showlist,
                             pp_dir,
                            pp_home,
                            pp_profile):
        """ canvas - the canvas that the tracks of the event show are to be written on
            show_params - the name of the configuration dictionary section for the hyperlinkshow
            showlist  - the showlist, to enable runningnof show type tracks.
            pp_home - Pi presents data_home directory
            pp_profile - Pi presents profile directory
        """
        
        self.mon=Monitor()
        self.mon.on()
        
        #instantiate arguments
        self.show_params=show_params
        self.root=root
        self.showlist=showlist
        self.canvas=canvas
        self.pp_dir=pp_dir
        self.pp_home=pp_home
        self.pp_profile=pp_profile

        # open resources
        self.rr=ResourceReader()

        #create a path stack
        self.path = PathManager()
        
        # init variables
        self.drawn  = None
        self.player=None
        self.shower=None
        self.timeout_running=None
        self.error=False



    def play(self,show_id,end_callback,ready_callback,top=False,command='nil'):
        """ starts the hyperlink show at start-track 
              end_callback - function to be called when the show exits
              ready_callback - callback when event-show is ready to display its forst track (not used?)
              top is True when the show is top level (run from [start] or from show control)
              command is not used
        """
        
        #instantiate arguments
        self.show_id=show_id
        self.end_callback=end_callback
        self.ready_callback=ready_callback
        self.top=top
        self.command=command

        # check data files are available.
        self.medialist_file = self.pp_profile + "/" + self.show_params['medialist']
        if not os.path.exists(self.medialist_file):
            self.mon.err(self,"Medialist file not found: "+ self.medialist_file)
            self.end('error',"Medialist file not found")
        
        #create a medialist object for the hyperlinkshow and read the file into it.
#.........这里部分代码省略.........
开发者ID:PhillipNordwall,项目名称:pipresents-next,代码行数:103,代码来源:pp_hyperlinkshow.py


注:本文中的pp_resourcereader.ResourceReader.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。