# 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
        elif gpg_output.count('[GNUPG:] BADSIG'):
            raise ChangesFileException("Bad signature", gpg_output_stderr)
        elif gpg_output.count('[GNUPG:] ERRSIG'):
            raise ChangesFileException("Error verifying signature",
                                       gpg_output_stderr)
        elif gpg_output.count('[GNUPG:] NODATA'):
            raise ChangesFileException("No signature on", gpg_output_stderr)
        else:
            raise ChangesFileException(
                "Unknown problem while verifying signature", gpg_output_stderr
            )

        key = None
        for line in gpg_output.split("\n"):
            if line.startswith('[GNUPG:] VALIDSIG'):
                key = line.split()[2]
        return key

    def validate_checksums(self, check_hash="sha1"):
        """
        Validate checksums for a package, using ``check_hack``'s type
        to validate the package.

        Valid ``check_hash`` types:

            * sha1
            * sha256
            * md5
            * md5sum
        """

# 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

        elif gpg_output.count('[GNUPG:] BADSIG'):
            raise ChangesFileException("Bad signature", gpg_output_stderr)
        elif gpg_output.count('[GNUPG:] ERRSIG'):
            raise ChangesFileException("Error verifying signature",
                                       gpg_output_stderr)
        elif gpg_output.count('[GNUPG:] NODATA'):
            raise ChangesFileException("No signature on", gpg_output_stderr)
        else:
            raise ChangesFileException(
                "Unknown problem while verifying signature", gpg_output_stderr
            )

        key = None
        for line in gpg_output.split("\n"):
            if line.startswith('[GNUPG:] VALIDSIG'):
                key = line.split()[2]
        return key

    def validate_checksums(self, check_hash="sha1"):
        """
        Validate checksums for a package, using ``check_hack``'s type
        to validate the package.

        Valid ``check_hash`` types:

            * sha1
            * sha256
            * md5
            * md5sum
        """

        logger.debug("validating %s checksums" % (check_hash))