示例#1
0
    def on_profile_copy_dialog_confirm(self, filelist):
        if len(filelist)==0:
            self.update_status('FAILED: Copy Profile')
            OKDialog('Copy Profile','Error: No profile selected').show(self)
            return    
        self.copy_from=filelist[0]
        self.from_basename=os.path.basename(self.copy_from)
        self.copy_to=self.pp_profiles_dir+os.sep+self.from_basename
        # print self.copy_from, self.copy_to, self.top_dir
        if not self.copy_from.startswith(self.top_dir):
            self.update_status('FAILED: Copy Profile')
            OKDialog('Copy Profile','Error: Access to source prohibited: ' + self.copy_from).show(self)
            return
        if not os.path.isdir(self.copy_from):
            self.update_status('FAILED: Copy Profile')
            OKDialog('Copy Profile','Error: Source is not a directory: ' + self.copy_from).show(self)
            return
        if not os.path.exists(self.copy_from + os.sep + 'pp_showlist.json'):
            self.update_status('FAILED: Copy Profile')
            OKDialog('Copy Profile','Error: Source is not a profile: ' + self.copy_from).show(self)            
            return
        if os.path.exists(self.copy_to):
            OKCancelDialog('Copy Profile','Profile already exists, overwrite?',self.copy_profile_confirm).show(self)

        else:
            self.copy_profile_confirm(True)
 def add_medialist_confirm(self,name):
     # print 'add medialist',name
     if name == "":
         OKDialog("Add Medialist","Name is blank").show(self)
         return  ''           
     if self.current_showlist.index_of_show(name) != -1:
         OKDialog("Add Medialist","A medialist with this name already exists").show(self)
         return ''
     if not name.endswith(".json"):
         name=name+(".json")
            
     path = self.pp_profile_dir + os.sep + name
     if os.path.exists(path) is  True:
         OKDialog("Add Medialist","Medialist file exists<br>(%s)" % path).show(self)
         return ''
     nfile = open(path,'wb')
     nfile.write("{")
     nfile.write("\"issue\":  \""+self.editor_issue+"\",\n")
     nfile.write("\"tracks\": [")
     nfile.write("]")
     nfile.write("}")
     nfile.close()
     # append it to the list
     self.medialists.append(copy.deepcopy(name))
     # print 'medialists',self.medialists
     # add title to medialists display
     # self.medialists_display.insert(END, name)  
     # and set it as the selected medialist
     self.refresh_medialists_display()
     # print 'returning medilaist name',name
     return name
 def new_profile_confirm(self,name):
     if name == "":
         OKDialog("New Profile","Name is blank").show(self)
         return
     to = self.pp_home_dir + os.sep + "pp_profiles"+ self.pp_profiles_offset + os.sep + name
     if os.path.exists(to) is  True:
         OKDialog( "New Profile","Profile exists\n(%s)" % to ).show(self)
         return
     shutil.copytree(self.new_profile_template, to, symlinks=False, ignore=None)
     self.open_profile(to)
示例#4
0
 def on_editor_run_menu_clicked(self):
     if os.name== 'nt':
         self.update_status('FAILED, Server on Windows')
         return
     command = self.manager_dir+'/pp_web_editor.py'
     self.ed_options=''
     success=self.ed.run_ed(command,self.ed_options)
     if success is True:
         OKDialog('Run Editor','Open new tab to run the editor').show(self)
     else:
         OKDialog('Run Editor','Error: Editor already Running').show(self)
示例#5
0
 def confirm(self):
     if OSCConfig.current_unit_type == 'remote':
         if self.get_field('e_home').get_value().strip() != '':
             if os.path.exists( self.get_field('e_home').get_value()) is  False:
                 OKDialog("Pi Presents Remote","Data Home not found").show(self)
                 return
         if self.get_field('e_offset').get_value().strip() != '':
             if os.path.exists(self.e_home.get()+os.sep+'pp_profiles'+self.get_field('e_offset').get_value()) is  False:
                 OKDialog("Pi Presents Remote","Current Profles directory not found").show(self)
                 return
     # print 'try save'
     self.hide()
     self.save()
示例#6
0
 def on_run_button_pressed(self):
     if os.name== 'nt':
         self.update_status('FAILED, Server on Windows')
         return
     if self.current_profile != '':
         command = self.manager_dir+'/pipresents.py'
         success=self.pp.run_pp(command,self.current_profile,self.options)
         if success is True:
             self.update_status('Pi Presents Started')
         else:
             self.update_status('FAILED, Pi Presents Not Started')
             OKDialog('Run Pi Presents','Error: Pi Presents already Running').show(self)
     else:
         OKDialog('Run Pi Presents','Error: No profile selected').show(self)
         self.update_status('FAILED, No profile selected')
 def open_showlist(self,profile_dir):
     showlist_file = profile_dir + os.sep + "pp_showlist.json"
     if os.path.exists(showlist_file) is False:
         OKDialog('Open Profile',"showlist file not found at " + profile_dir + "<br><br>Hint: Have you opened the profile directory?").show(self)
         return False
     self.current_showlist=ShowList()
     self.current_showlist.open_json(showlist_file)
     if float(self.current_showlist.sissue())<float(self.editor_issue):
         self.update_profile()
         OKDialog('Open Profile',"Version of profile has been updated to "+self.editor_issue+", please re-open").show(self)
         return False
     if float(self.current_showlist.sissue())>float(self.editor_issue):
         OKDialog('Open Profile',"Version of profile is greater than editor").show(self)
         return False
     self.refresh_shows_display()
     return True
    def copy_medialist_file(self,from_file,to_file):
        if not to_file.endswith(".json"):
            to_file+=(".json")
                
        to_path = self.pp_profile_dir + os.sep + to_file
        if os.path.exists(to_path) is  True:
            OKDialog("Copy Medialist","Medialist file exists\n(%s)" % to_path).show(self)
            return ''
        
        from_path= self.pp_profile_dir + os.sep + from_file
        if os.path.exists(from_path) is  False:
            OKDialog("Copy Medialist","Medialist file not found\n(%s)" % from_path).show(self)
            return ''

        shutil.copy(from_path,to_path)
        return to_file
 def open_existing_profile(self):
     initial_dir=self.pp_home_dir+os.sep+"pp_profiles"+self.pp_profiles_offset
     if os.path.exists(initial_dir) is False:
         OKDialog('Open Profile',"Profiles directory not found: " + initial_dir + "<br><br>Hint: Data Home option must end in pp_home").show(self)
         return
     open_existing_profile_dialog = gui.FileSelectionDialog('Open Profile','Select profile',False, initial_dir) #width=600,height=200,
     open_existing_profile_dialog.set_on_confirm_value_listener(self, 'open_existing_profile_dialog_confirm')
     open_existing_profile_dialog.show(self)
 def add_track_from_file_dialog_confirm(self, filelist):
     if len(filelist)==0:
         OKDialog('Add Track',"Nothing Selected").show(self)
         return
     for file_path in filelist:
         file_path=os.path.normpath(file_path)
         # print "file path ", file_path
         self.add_track(file_path)
     self.save_medialist()
 def add_show_confirm(self,name):
     # print 'show name',name
     if name == "":
         OKDialog("Add Show","Name is blank").show(self)
         return             
     if self.current_showlist.index_of_show(name) != -1:
         OKDialog("Add Show","A Show with this name already exists").show(self)
         return
     # print 'copy show template',self.default_show,name
     copied_show=self.current_showlist.copy(self.default_show,name)
     # print 'add mediafile from show',name
     mediafile=self.add_medialist(name)
     # print 'mediafile added',mediafile
     if mediafile != '':
         copied_show['medialist']=mediafile
     self.current_showlist.append(copied_show)
     self.save_showlist(self.pp_profile_dir)
     self.refresh_shows_display()
示例#12
0
 def on_editor_exit_menu_clicked(self):
     if os.name== 'nt':
         self.update_status('FAILED, Server on Windows')
         return
     success=self.ed.exit_ed()
     if success is True:
         self.update_status('Editor Stopped')
     else:
         OKDialog('Exit Editor','Error: Editor Not Running').show(self)
    def on_fileselection_dialog_callback(self,flist):
        # a list() of filenames and folders is returned
        if len(flist)==0:
            OKDialog('Select File','nothing selected').show(self._base_app_instance)
            return
        file_path=os.path.normpath(flist[0])
        # print "file path ", file_path

        result=calculate_relative_path(file_path,self.pp_home_dir,self.pp_profile_dir)
        self.field_objs[self.browse_field_index].set_value(result)
示例#14
0
    def on_media_copy_dialog_confirm(self, filelist):
        if len(filelist)==0:
            self.update_status('FAILED: Copy Media')
            OKDialog('Copy Media','Error: No file selected').show(self)
            return    
        self.copy_list=filelist
        copy_from1=filelist[0]
        self.copy_to=self.media_dir
        if not copy_from1.startswith(self.top_dir):
            self.update_status('FAILED: Copy Media')
            OKDialog('Copy Media','Error: Access to source prohibited: ' + copy_from1).show(self)
            return
        if not os.path.exists(self.copy_to):
            self.update_status('FAILED: Copy Media')
            OKDialog('Copy Media',' Error: Media directory does not exist: ' + self.copy_to).show(self)
            return

        # print self.copy_list, self.copy_to
        OKCancelDialog('Copy Media','Files will be ovewritten even if newer',self.copy_media_confirm).show(self)
示例#15
0
 def on_exit_button_pressed(self):
     if os.name== 'nt':
         self.update_status('FAILED, Server on Windows')
         return
     success=self.pp.exit_pp()
     if success is True:
         self.update_status('Pi Presents Exited')
     else:
         self.update_status('FAILED, Pi Presents Not Exited')
         OKDialog('Exit Pi Presents','Pi Presents Not Running').show(self)
示例#16
0
 def copy_media_confirm(self,result):
     if result:
         for item in self.copy_list:
             if os.path.isdir(item):
                 self.update_status('FAILED: Copy Media')
                 OKDialog('Copy Media',' Error: Cannot copy a directory').show(self)
             else:
                 shutil.copy2(item, self.copy_to)
         self.update_status('Media copy sucessful: ')
     else:
         self.update_status('Media copy cancelled: ')
    def medialist_selected(self,key):
        """
        user clicks on a medialst in a profile so try and select it.
        """
        # print 'selected',type(self.medialists_display.get_key()),self.medialists_display.get_key()
        if len(self.medialists)>0:
            self.current_medialists_index=self.medialists_display.get_key()

            self.current_medialist=MediaList('ordered')
            if not self.current_medialist.open_list(self.pp_profile_dir+ os.sep + self.medialists[self.current_medialists_index],self.current_showlist.sissue()):
                OKDialog(self,"medialist is a different version to showlist: "+ self.medialists[self.current_medialists_index]).show(self)
                #self.app_exit()
                return
            self.refresh_tracks_display()
            self.refresh_medialists_display()
示例#18
0
 def on_profile_download_clicked(self):
     if self.current_profile != '':
         dest=self.upload_dir_path+os.sep+self.current_profile_name
         base=self.pp_home_dir+os.sep+'pp_profiles'+self.current_profile
         shutil.make_archive(dest,'zip',base)
         self.profile_download_dialog=gui.GenericDialog(width=500,height=200,title='<b>Download Profile</b>',
                                                        message='',autohide_ok=False)
         self.profile_download_button = gui.FileDownloader('Click Link to Download', dest+'.zip', width=200, height=30)
         self.profile_download_status=gui.Label('', width=450, height=30)
         self.profile_download_dialog.add_field('1',self.profile_download_button)
         self.profile_download_dialog.add_field('2',self.profile_download_status)
         self.profile_download_dialog.show(self)
         self.profile_download_dialog.set_on_confirm_dialog_listener(self,'on_profile_download_dialog_confirm')
     else:
         OKDialog('Download Profile', 'Error: No profile selected').show(self)
示例#19
0
    def confirm_dialog(self, emitter):

        if self.get_field('e_this_unit_name').get_value() == '':
            OKDialog('OSC Config',
                     'This Unit OSC Name must not be blank').show(
                         self._base_app_instance)
            return

        slave_enabled = self.get_field('e_slave_enabled').get_value().strip()

        if slave_enabled not in ('yes', 'no'):
            OKDialog('OSC Config', 'Slave Enabled must be yes or no').show(
                self._base_app_instance)
            return

        if slave_enabled == 'yes':
            if not self.get_field('e_listen_port').get_value().isdigit():
                OKDialog('OSC Config',
                         'Listen Port must be a positive integer').show(
                             self._base_app_instance)
                return

        master_enabled = self.get_field('e_master_enabled').get_value().strip()

        if master_enabled not in ('yes', 'no'):
            OKDialog('OSC Config', 'Master Enabled must be yes or no').show(
                self._base_app_instance)
            return

        if master_enabled == 'yes':
            if not self.get_field('e_reply_listen_port').get_value().isdigit():
                OKDialog('OSC Config',
                         'Reply Listen Port must be a positive integer').show(
                             self._base_app_instance)
                return

            if self.get_field('e_slave_units_name').get_value() == '':
                OKDialog('OSC Config',
                         'Slave Units OSC Name must not be blank').show(
                             self._base_app_instance)
                return

            if self.get_field('e_slave_units_ip').get_value() == '':
                OKDialog('OSC Config',
                         'Slave Units IP must not be blank').show(
                             self._base_app_instance)
                return
        self.save()
        self.hide()
 def open_profile(self,dir_path):
     showlist_file = dir_path + os.sep + "pp_showlist.json"
     #print 'open profile',showlist_file
     if os.path.exists(showlist_file) is False:
         OKDialog('Open Profile',"Not a Profile: " + dir_path).show(self)
         return
     self.pp_profile_dir = dir_path
     OSCConfig.options_file=self.pp_profile_dir+ os.sep+'pp_io_config'+os.sep+'osc.cfg'
     # print 'profile direcotry',self.pp_profile_dir
     # self.root.title("Editor for Pi Presents - "+ self.pp_profile_dir)
     if self.open_showlist(self.pp_profile_dir) is False:
         self.init()
         self.empty_lists()
         return
     
     self.open_medialists(self.pp_profile_dir)
     self.refresh_tracks_display()
     self.osc_config_file=self.pp_profile_dir+os.sep+'pp_io_config'+os.sep+'osc.cfg'
    def copy_medialist_confirm(self,to_file):
        # print self.from_file,to_file
        if to_file == "":
            OKDialog("Copy Medialist","Name is blank").show(self)
            return ''

        success_file = self.copy_medialist_file(self.from_file,to_file)
        if success_file =='':
            return ''

        # append it to the list
        self.medialists.append(copy.deepcopy(success_file))
        # add title to medialists display
        # self.medialists_display.insert(END, success_file)
        # and reset  selected medialist
        self.current_medialist=None
        self.refresh_medialists_display()
        self.refresh_tracks_display()
        return success_file
 def add_track(self,afile):
     relpath = os.path.relpath(afile,self.pp_home_dir)
     # print "relative path ",relpath
     common = os.path.commonprefix([afile,self.pp_home_dir])
     # print "common ",common
     if common.endswith("pp_home")  is  False:
         location = afile
     else:
         location = "+" + os.sep + relpath
         location = string.replace(location,'\\','/')
         # print "location ",location
     (root,title)=os.path.split(afile)
     (root,ext)= os.path.splitext(afile)
     if ext.lower() in PPdefinitions.IMAGE_FILES:
         self.new_track(PPdefinitions.new_tracks['image'],{'title':title,'track-ref':'','location':location})
     elif ext.lower() in PPdefinitions.VIDEO_FILES:
         self.new_track(PPdefinitions.new_tracks['video'],{'title':title,'track-ref':'','location':location})
     elif ext.lower() in PPdefinitions.AUDIO_FILES:
         self.new_track(PPdefinitions.new_tracks['audio'],{'title':title,'track-ref':'','location':location})
     elif ext.lower() in PPdefinitions.WEB_FILES:
         self.new_track(PPdefinitions.new_tracks['web'],{'title':title,'track-ref':'','location':location})
     else:
         OKDialog('Add Track',afile + " - cannot determine track type, use menu track>new").show(self)
 def add_tracks_from_dir_dialog_confirm(self, result):
     image_specs =[PPdefinitions.IMAGE_FILES,PPdefinitions.VIDEO_FILES,PPdefinitions.AUDIO_FILES,
                   PPdefinitions.WEB_FILES,('All files', '*')]
     # last one is ignored in finding files in directory, for dialog box only
     if len(result) == 0:
         OKDialog('Add Tracks',"Nothing Selected").show(self)
         return
     directory=result[0]
     # make list of exts we recognise
     exts = []
     for image_spec in image_specs[:-1]:
         image_list=image_spec[1:]
         for ext in image_list:
             exts.append(copy.deepcopy(ext))
     for this_file in os.listdir(directory):
         (root_file,ext_file)= os.path.splitext(this_file)
         if ext_file.lower() in exts:
             file_path=directory+os.sep+this_file
             # print "file path before ", file_path
             file_path=os.path.normpath(file_path)
             # print "file path after ", file_path
             self.add_track(file_path)
     self.save_medialist()
 def show_help (self):
     OKDialog("Help","Please Read 'manual.pdf'",width=400,height=200).show(self)
 def show_about (self):
     OKDialog("About","Web Editor for Pi Presents Profiles<br>"
                           +"For profiles of version: " + self.editor_issue + "<br>Author: Ken Thompson"
                           +"<br>Website: http://pipresents.wordpress.com/<br>",width=400,height=200).show(self)
 def open_existing_profile_dialog_confirm(self, filelist):
     if len(filelist)==0:
         OKDialog('Open Profile',"Nothing Selected").show(self)
         return
     # print 'filelist',filelist[0]
     self.open_profile(filelist[0])