# Path: pgp/commands/gpg/exceptions.py
# class FatalException(Exception):
# 
#     def __init__(self, exit_code):
#         self.exit_code


import datetime
import os
import re
import shlex
import subprocess
import sys
import tempfile
from io import BytesIO
from six import text_type
from pgp.commands.gpg.exceptions import FatalException
        try:
            if self.status_fd:
                stdout = os.fdopen(self.attribute_fd, 'wb')
                close = True
            if self.status_file:
                stdout = self.open_filename(self.attribute_file, 'wb')
                close = True
            stdout.write(attribute.encode(self.display_charset))
        except (IOError, OSError, TypeError, ValueError):
            if self.exit_on_status_write_error:
                self.exit(1)
        finally:
            if close:
                stdout.close()

    def write_output(self, output, stdout=None, output_filename=None):
        if self.max_output:
            limit = self.max_output
        if output_filename is None:
            output_filename = self.output_file
        if output_filename:
            stdout = self.open_file(output_filename, 'wb')
        if stdout is None:
            stdout = self.stdout
        written_bytes = 1
        total_bytes = 0
        while written_bytes:
            written_bytes = stdout.write(output.read(1024))
            total_bytes += written_bytes
            if limit and total_bytes > limit:

# Path: pgp/commands/gpg/exceptions.py
# class FatalException(Exception):
# 
#     def __init__(self, exit_code):
#         self.exit_code


# Path: pgp/commands/gpg/io_helper.py
import datetime
import os
import re
import shlex
import subprocess
import sys
import tempfile
from io import BytesIO
from six import text_type
from pgp.commands.gpg.exceptions import FatalException

        try:
            if self.status_fd:
                stdout = os.fdopen(self.attribute_fd, 'wb')
                close = True
            if self.status_file:
                stdout = self.open_filename(self.attribute_file, 'wb')
                close = True
            stdout.write(attribute.encode(self.display_charset))
        except (IOError, OSError, TypeError, ValueError):
            if self.exit_on_status_write_error:
                self.exit(1)
        finally:
            if close:
                stdout.close()

    def write_output(self, output, stdout=None, output_filename=None):
        if self.max_output:
            limit = self.max_output
        if output_filename is None:
            output_filename = self.output_file
        if output_filename:
            stdout = self.open_file(output_filename, 'wb')
        if stdout is None:
            stdout = self.stdout
        written_bytes = 1
        total_bytes = 0
        while written_bytes:
            written_bytes = stdout.write(output.read(1024))
            total_bytes += written_bytes
            if limit and total_bytes > limit:

                raise FatalException(1)