# Path: dput/core.py
# CONFIG_LOCATIONS = {
#     "/usr/share/dput-ng/": 30,
#     "/etc/dput.d/": 20,
#     os.path.expanduser("~/.dput.d"): 10,
#     "skel/": 100
# }
# DPUT_CONFIG_LOCATIONS = {
#     "/etc/dput.cf": 15,
#     os.path.expanduser("~/.dput.cf"): 5
# }
# SCHEMA_DIRS = [
#     "/usr/share/dput-ng/schemas",
#     "skel/schemas"
# ]
# def _write_upload_log(logfile, full_log):
# def _enable_debugging(level):
# def mangle_sys():
# def maybe_print_traceback(debug_level, stack):
# def get_local_username():
# 
# Path: dput/util.py
# def run_command(command, env=None):
#     """
#     Run a synchronized command. The argument must be a list of arguments.
#     Returns a triple (stdout, stderr, exit_status)
# 
#     If there was a problem to start the supplied command, (None, None, -1) is
#     returned
#     """
#     if not isinstance(command, list):
#         command = shlex.split(command)
#     try:
#         pipe = subprocess.Popen(command,
#                                 env=env,
#                                 shell=False,
#                                 stdout=subprocess.PIPE,
#                                 stderr=subprocess.PIPE)
#     except OSError as e:
#         logger.error("Could not execute %s: %s" % (" ".join(command), e))
#         return (None, None, -1)
#     (output, stderr) = pipe.communicate()
#     output = output.decode('utf-8', errors='replace')
#     stderr = stderr.decode('utf-8', errors='replace')
#     #if pipe.returncode != 0:
#     #   error("Command %s returned failure: %s" % (" ".join(command), stderr))
#     return (output, stderr, pipe.returncode)
# 
# Path: dput/exceptions.py
# class ChangesFileException(DputError):
#     """
#     Thrown when there's an error processing / verifying a .changes file
#     (most often via the :class:`dput.changes.Changes` object)
#     """
# 
#     def __init__(self, message, gpg_stderr=None):
#         super(ChangesFileException, self).__init__(message)
#         self.gpg_stderr = gpg_stderr


import sys
import os.path
import hashlib
from debian import deb822
from dput.core import logger
from dput.util import run_command
from dput.exceptions import ChangesFileException
            self._directory = directory
        else:
            self._directory = ""

    def validate(self, check_hash="sha1", check_signature=True):
        """
        See :meth:`validate_checksums` for ``check_hash``, and
        :meth:`validate_signature` if ``check_signature`` is True.
        """
        self.validate_checksums(check_hash)
        if check_signature:
            self.validate_signature(check_signature)
        else:
            logger.info("Not checking signature")

    def validate_signature(self, check_signature=True):
        """
        Validate the GPG signature of a .changes file.

        Throws a :class:`dput.exceptions.ChangesFileException` if there's
        an issue with the GPG signature. Returns the GPG key ID.
        """
        gpg_path = "gpg"

        (gpg_output, gpg_output_stderr, exit_status) = run_command([
            gpg_path, "--status-fd", "1", "--verify",
            "--batch", self.get_changes_file()
        ])

        if exit_status == -1:

# Path: dput/core.py
# CONFIG_LOCATIONS = {
#     "/usr/share/dput-ng/": 30,
#     "/etc/dput.d/": 20,
#     os.path.expanduser("~/.dput.d"): 10,
#     "skel/": 100
# }
# DPUT_CONFIG_LOCATIONS = {
#     "/etc/dput.cf": 15,
#     os.path.expanduser("~/.dput.cf"): 5
# }
# SCHEMA_DIRS = [
#     "/usr/share/dput-ng/schemas",
#     "skel/schemas"
# ]
# def _write_upload_log(logfile, full_log):
# def _enable_debugging(level):
# def mangle_sys():
# def maybe_print_traceback(debug_level, stack):
# def get_local_username():
# 
# Path: dput/util.py
# def run_command(command, env=None):
#     """
#     Run a synchronized command. The argument must be a list of arguments.
#     Returns a triple (stdout, stderr, exit_status)
# 
#     If there was a problem to start the supplied command, (None, None, -1) is
#     returned
#     """
#     if not isinstance(command, list):
#         command = shlex.split(command)
#     try:
#         pipe = subprocess.Popen(command,
#                                 env=env,
#                                 shell=False,
#                                 stdout=subprocess.PIPE,
#                                 stderr=subprocess.PIPE)
#     except OSError as e:
#         logger.error("Could not execute %s: %s" % (" ".join(command), e))
#         return (None, None, -1)
#     (output, stderr) = pipe.communicate()
#     output = output.decode('utf-8', errors='replace')
#     stderr = stderr.decode('utf-8', errors='replace')
#     #if pipe.returncode != 0:
#     #   error("Command %s returned failure: %s" % (" ".join(command), stderr))
#     return (output, stderr, pipe.returncode)
# 
# Path: dput/exceptions.py
# class ChangesFileException(DputError):
#     """
#     Thrown when there's an error processing / verifying a .changes file
#     (most often via the :class:`dput.changes.Changes` object)
#     """
# 
#     def __init__(self, message, gpg_stderr=None):
#         super(ChangesFileException, self).__init__(message)
#         self.gpg_stderr = gpg_stderr


# Path: dput/changes.py
import sys
import os.path
import hashlib
from debian import deb822
from dput.core import logger
from dput.util import run_command
from dput.exceptions import ChangesFileException

            self._directory = directory
        else:
            self._directory = ""

    def validate(self, check_hash="sha1", check_signature=True):
        """
        See :meth:`validate_checksums` for ``check_hash``, and
        :meth:`validate_signature` if ``check_signature`` is True.
        """
        self.validate_checksums(check_hash)
        if check_signature:
            self.validate_signature(check_signature)
        else:
            logger.info("Not checking signature")

    def validate_signature(self, check_signature=True):
        """
        Validate the GPG signature of a .changes file.

        Throws a :class:`dput.exceptions.ChangesFileException` if there's
        an issue with the GPG signature. Returns the GPG key ID.
        """
        gpg_path = "gpg"

        (gpg_output, gpg_output_stderr, exit_status) = run_command([
            gpg_path, "--status-fd", "1", "--verify",
            "--batch", self.get_changes_file()
        ])

        if exit_status == -1:

            raise ChangesFileException(