def get_exe(exe_name): valid_exes = ["ffmpeg.exe", "ffprobe.exe", "ffplay.exe"] exe_name = exe_name + ".exe" if not exe_name.endswith(".exe") else exe_name if exe_name in valid_exes: candidates = io.get_files(get_current_folder(), extensions=[".exe"], filters=[exe_name]) if candidates: return candidates[0]
def play_video(self): """ Plays the selected video in the player. """ if self.video_player.is_ready(): try: self.video_player.media_object.finished.disconnect(self.loop) except Exception as e: logger.warning(("Signal disconnect Fail -> %s" % e), level=0) try: self.video_player.media_object.stateChanged.disconnect(self.video_player_state_changed) except Exception as e: logger.warning(("Signal disconnect Fail -> %s" % e), level=0) self.set_video_player_state(False) # Searches the video file item = self.lw_video.currentItem() candidates = io.get_files(self.current_folder, extensions=self.allowed_extensions, filters=[item.text()]) # If exists, plays it in the player. if candidates: video_file = candidates[0] self.video_player.clear_urls() self.video_player.add_url(video_file) self.video_player.set_current_url(0, reset=True) self.set_video_player_state(self.video_player.is_ready()) if self.video_player.is_ready(): self.lb_playing_name.setText("Playing: %s" % os.path.basename(video_file)) self.video_player.media_object.finished.connect(self.loop) self.video_player.media_object.stateChanged.connect(self.video_player_state_changed) self.video_player.play()
def pack_module(source_file, pack_folder=None, custom_name=None, remove_previous=True, compiled=True, standalone=True, **kwargs): """Packs a python file and all depedencies in and independent module folder. Args: source_file (string): Path to the file to use as root. pack_folder (string): The path to the folder to use as pack folder. custom_name (string, optional): Custom name for the packed module folder structure. remove_previous (bool, optional): Indicates if it has to remove the previous pack folder. compiled (bool, optional): Indicates if it has to compile the .py files into .pyc. standalone (bool, optional): Indicates if it has to be executable standalone or needs python installed. **kwargs: Extra arguments like custom dependencies, etc. """ # Initial info. logger.info("Searching -> %s" % source_file) logger.info("Pack Folder Given -> %s" % pack_folder) # If source file exists, can start the packaging. if os.path.exists(source_file): logger.info(("File Exists -> %s" % source_file)) # This will be the module name. Uses the given file name as module name if a custom name is not provided module_name = os.path.basename(os.path.splitext(source_file)[0]) if not custom_name else custom_name # pack_installer_folder = os.path.join(pack_folder, module_name) pack_module_folder = os.path.join(pack_folder, module_name) # Creates the installer # The real pack folder is a new folder with the name of the module in the provided pack folder. # pack_installer(source_file, pack_folder=pack_installer_folder, level=1, remove_previous=remove_previous) # Packs the file. Creates one more level folder to contain the actual application. # pack_module_folder = os.path.join(pack_folder, module_name, module_name) # pack_module_folder = os.path.join(pack_folder, module_name) pack_file(source_file, pack_folder=pack_module_folder, level=1, remove_previous=remove_previous, standalone=standalone, compiled=compiled) # Compiles the .py into .pyc and deletes the .py files if requested. if compiled: compileall.compile_dir(pack_module_folder, force=True) py_files = io.get_files(pack_module_folder, extensions=[".py"]) for py_file in py_files: os.remove(py_file) # Creates the python dist in case the mode is standalone: if standalone: pack_dist(pack_folder=pack_module_folder, level=1, remove_previous=remove_previous) logger.info("Packaging Finished -> %s" % source_file) else: logger.error(("Source File must be provided -> %s" % source_file)) return None
def fill_video_list(self): """ Fills the list of videos availables, using the selected category and the filters. """ if not self.updating_ui: self.updating_ui = True if self.current_folder and os.path.exists(self.current_folder): # Gets all the videos in that category. current_category = self.cbx_categories.currentText() filters = re.findall(r"[\w']+", self.le_filter.text()) video_files = io.get_files(current_category, extensions=self.allowed_extensions, filters=filters) video_files = [os.path.basename(video_file) for video_file in video_files] video_files.sort() self.lw_video.clear() if video_files: for video_file in video_files: self.lw_video.addItem(os.path.basename(video_file)) self.updating_ui = False
def get_image_files(folder, recursive=True): return io.get_files(folder, extensions=[".png", ".jpg", ".gif"], recursive=recursive)
def get_style_files(): style_files = io.get_files(get_current_folder(), extensions=[".qss"], recursive=True) return style_files
def get_font_files(): font_files = io.get_files(get_current_folder(), extensions=[".ttf"], recursive=True) return font_files
def get_ui_files(folder, recursive=True): return io.get_files(folder, extensions=[".ui"], recursive=recursive)