如何阻止 file-roller 输出任何内容并挂起进程

如何阻止 file-roller 输出任何内容并挂起进程

我正在编写一个用于file-roller提取 ISO 文件的程序。但是我不断收到警告,我不想看到这个警告。出现file-roller这个警告后也会挂起。。Gtk-Message: GtkDialog mapped without transient parent. This is discouraged一旦出现,file-roller就会挂起而不执行任何操作。我正在使用file-roller命令行file-roller -e <PATH> <ISO IMAGE>。我的问题很简单,如何禁用命令上的警告和 stdout 并在出现警告时阻止进程挂起?

脚本:

def unzip_iso(filepath, verbose=False, directory_name="ISO_dir"):
    """
      Unzip the ISO file into a directory

      :param filepath: the path to the ISO file
      :param verbose: verbosity output
      :param directory_name: the name of the ISO directory
      :return: True if it worked, False if it didn't
    """
    def create_rand_dir_name(chars=string.ascii_letters, verbose=False):
        """
          Create a random directory name
        """
        if verbose: LOGGER.debug("Creating random directory name..")
        retval = set()
        for _ in range(8):
            retval.add(random.choice(chars))
        return ''.join(list(retval))

    dirname = create_rand_dir_name(verbose=verbose)
    if verbose: LOGGER.debug("Creating directory: {}/{}/*..".format(directory_name, dirname))
    create_dir(directory_name + "/" + dirname)
    full_dir_path = os.getcwd() + "/" + directory_name + "/" + dirname
    if verbose: LOGGER.debug("Directory created, full path being saved to: {}..".format(full_dir_path))

    cmd = "file-roller -e {} {}".format(full_dir_path, filepath)
    if verbose: LOGGER.debug("Starting command: {}..".format(cmd))
    stdout_data = subprocess.check_call(cmd, shell=True)

相关内容