def upload(fqdn, login, incoming, files_to_upload, # pylint: disable=too-many-arguments
        debug, dummy, progress=None):
    """Upload the files via WebDAV."""
    assert sys.version_info >= (2, 5), "Your snake is a rotting corpse (Python 2.5+ required)"
    trace.debug = bool(debug)

    try:
        host_config, cli_params = _get_config_data(fqdn)
        login = _resolve_credentials(fqdn, login)

        # Handle .changes file
        changes_file = [i for i in files_to_upload if i.endswith(".changes")]
        if not changes_file:
            log("WARN: No changes file found in %(n)d files to upload", n=len(files_to_upload))
            changes_file = None
        else:
            if len(changes_file) > 1:
                log("WARN: More than one changes file found in %(n)d files to upload,"
                    " taking the 1st:\n    %(changes)s",
                    n=len(files_to_upload), changes="\n    ".join(changes_file))
            changes_file = changes_file[0]

        # Prepare for uploading
        incoming, matrix_params, repo_params = _resolve_incoming(fqdn, login, incoming, changes=changes_file,
            cli_params=cli_params, repo_mappings=host_config.get("repo_mappings", ""))
        log("INFO: Destination base URL is\n    %(url)s", url=urllib2.quote(incoming, safe=":/~;#"))
        repo_params.update(cli_params)
        mindepth = int(repo_params.get("mindepth", "0"), 10)
        overwrite = int(repo_params.get("overwrite", "0"), 10)
        # TODO: Add ability to enter missing password via terminal
        #   auth_handler = PromptingPasswordMgr(login)

        # Special handling for integration test code
        if "integration-test" in cli_params:
            import pprint
            print("upload arguments = ", end="")
            pprint.pprint(dict((k, v) for k, v in locals().iteritems() if k in (
                "fqdn", "login", "incoming", "files_to_upload", "debug", "dummy", "progress")))
            print("host config = ", end="")
            pprint.pprint(host_config)
            print("host arguments = ", end="")
            pprint.pprint(cli_params)
        else:
            # TODO: "bintray" REST API support
            #   POST /packages/:subject/:repo
            #   POST /packages/:subject/:repo/:package/versions

            # Check if .changes file already exists
            if not overwrite and changes_file:
                try:
                    _check_url(_file_url(changes_file, incoming), login, [404])
                except urllib2.HTTPError, exc:
                    raise dputhelper.DputUploadFatalException("Overwriting existing changes at '%s' not allowed: %s" % (
                        _file_url(changes_file, incoming), exc))

            # Check for existence of target path with minimal depth
            if mindepth:
                try:
                    _check_url(incoming, login, range(200, 300), mindepth=mindepth)
                except urllib2.HTTPError, exc:
                    raise dputhelper.DputUploadFatalException("Required repository path '%s' doesn't exist: %s" % (
                        exc.filename, exc))

            # Upload the files in the given order
            for filepath in files_to_upload:
                if "simulate" in cli_params:
                    log("WOULD upload '%(filename)s'", filename=os.path.basename(filepath))
                else:
                    _dav_put(filepath, incoming, matrix_params, login, progress)
    except (dputhelper.DputUploadFatalException, socket.error, urllib2.URLError, EnvironmentError), exc:
        log("FATAL: %(exc)s", exc=exc)
        sys.exit(1)
dataset/ETHPy150Open jhermann/artifactory-debian/dput-webdav/webdav.py/upload/original