def on_profile_upload_success(self,filename): #filename is leafname of uploaded file # uploaded zip file goes into as specified in the widget constructor self.profile_upload_filename=filename # xxxx.zip self.profile_upload_directory='/'+self.profile_upload_filename.split('.')[0] # /xxxx source_file_path =self.upload_dir_path+os.sep+self.profile_upload_filename # unzip it into a directory in pp_temp with the uploaded filename if not zipfile.is_zipfile(source_file_path): self.profile_upload_status.set_text('ERROR: Uploaded file is not a Zip archive') os.remove(source_file_path) return zzip=zipfile.ZipFile(source_file_path) zzip.extractall(self.upload_dir_path) os.remove(source_file_path) # check temp directory is a profile if not os.path.exists(self.upload_dir_path+self.profile_upload_directory+os.sep+'pp_showlist.json'): self.profile_upload_status.set_text('ERROR: Uploaded Zip is not a profile') shutil.rmtree(self.upload_dir_path+self.profile_upload_directory) else: # warn if profile already exists if os.path.exists(self.pp_profiles_dir+self.profile_upload_directory): OKCancelDialog('Profile Upload','Profile already exists, overwrite?',self.on_profile_replace_ok).show(self) else: self.on_profile_replace_ok(True)
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 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)
def remove_track(self): if self.current_medialist is not None and self.current_medialist.length()>0 and self.current_medialist.track_is_selected(): OKCancelDialog("Delete Track","Are you sure?",self.remove_track_confirm).show(self)
def remove_medialist(self): if self.current_medialist is not None: OKCancelDialog("Delete Medialist","Are you sure?",self.remove_medialist_confirm).show(self)
def remove_show(self): if self.current_showlist is not None and self.current_showlist.length()>0 and self.current_showlist.show_is_selected(): OKCancelDialog("Delete Show","Are you sure?",self.remove_show_confirm).show(self)