'Upload a full directory. Depending on the upload path, the appropriate
method for that protocol is called. Currently this copies the whole
tmp package directory to the target directory.
This assumes that the web server is running on the same machine where
the method is being called from. The upload_path\'s files are
basically served by that web server.'

def upload_pkg_dir(self, dir_path, upload_path):

    local_path = os.path.join(dir_path, '*')
    try:
        if upload_path.startswith('ssh://'):
            (hostline, remote_path) = parse_ssh_path(upload_path)
            try:
                utils.run(('scp    %s    %s:%s' % (local_path, hostline, remote_path)))
                ssh_path = os.path.join(remote_path, '*')
                utils.run(("ssh    %s    'chmod    644    %s'" % (hostline, ssh_path)))
            except error.CmdError:
                logging.error('Error    uploading    to    repository:    %s', upload_path)
        else:
            utils.run(('cp    %s    %s    ' % (local_path, upload_path)))
            up_path = os.path.join(upload_path, '*')
            utils.run(('chmod    644    %s' % up_path))
    except (IOError, os.error) as why:
        raise error.PackageUploadError(('Upload    of    %s    to    %s    failed:    %s' % (dir_path, upload_path, why)))
