'Handle copying of http:// and ftp:// yum repos.'

def yum_sync(self, repo):

    repo_mirror = repo.mirror.strip()
    dest_path = os.path.join((self.settings.webdir + '/repo_mirror'), repo.name.strip())
    self.create_local_file(dest_path, repo)
    if (not repo.mirror_locally):
        return
    cmd = self.reposync_cmd()
    has_rpm_list = False
    if ((repo.rpm_list != '') and (repo.rpm_list != [])):
        has_rpm_list = True
    temp_path = os.path.join(dest_path, '.origin')
    if (not os.path.isdir(temp_path)):
        os.makedirs(temp_path)
    temp_file = self.create_local_file(temp_path, repo, output=False)
    if (not has_rpm_list):
        cmd = ('%s    %s    --config=%s    --repoid=%s    --download_path=%s' % (cmd, self.rflags, temp_file, repo.name, (self.settings.webdir + '/repo_mirror')))
        if (repo.arch != ''):
            if (repo.arch == 'x86'):
                repo.arch = 'i386'
            if (repo.arch == 'i386'):
                cmd = ('%s    -a    i686' % cmd)
            else:
                cmd = ('%s    -a    %s' % (cmd, repo.arch))
    else:
        if (not os.path.exists(dest_path)):
            os.makedirs(dest_path)
        use_source = ''
        if (repo.arch == 'src'):
            use_source = '--source'
        extra_flags = self.settings.yumdownloader_flags
        cmd = ''
        if os.path.exists('/usr/bin/dnf'):
            cmd = '/usr/bin/dnf    download'
        else:
            cmd = '/usr/bin/yumdownloader'
        cmd = ('%s    %s    %s    --disablerepo=*    --enablerepo=%s    -c    %s    --destdir=%s    %s' % (cmd, extra_flags, use_source, repo.name, temp_file, dest_path, '    '.join(repo.rpm_list)))
    rc = utils.subprocess_call(self.logger, cmd)
    if (rc != 0):
        utils.die(self.logger, 'cobbler    reposync    failed')
    repodata_path = os.path.join(dest_path, 'repodata')
    proxies = None
    if (repo.proxy == '<<inherit>>'):
        proxies = {'http': self.settings.proxy_url_ext}
    elif ((repo.proxy != '<<None>>') and (repo.proxy != '')):
        proxies = {'http': repo.proxy, 'https': repo.proxy}
    src = (repo_mirror + '/repodata/repomd.xml')
    dst = (temp_path + '/repomd.xml')
    urlgrab_ssl_opts = self.gen_urlgrab_ssl_opts(repo.yumopts)
    try:
        urlgrabber.grabber.urlgrab(src, filename=dst, proxies=proxies, **urlgrab_ssl_opts)
    except Exception as e:
        utils.die(self.logger, ((('failed    to    fetch    ' + src) + '    ') + e.args))
    if (not os.path.isdir(repodata_path)):
        os.makedirs(repodata_path)
    rmd = yum.repoMDObject.RepoMD('', ('%s/repomd.xml' % temp_path))
    for mdtype in rmd.repoData.keys():
        if (mdtype not in ['primary', 'primary_db', 'filelists', 'filelists_db', 'other', 'other_db']):
            mdfile = rmd.getData(mdtype).location[1]
            src = ((repo_mirror + '/') + mdfile)
            dst = ((dest_path + '/') + mdfile)
            try:
                urlgrabber.grabber.urlgrab(src, filename=dst, proxies=proxies, **urlgrab_ssl_opts)
            except Exception as e:
                utils.die(self.logger, ((('failed    to    fetch    ' + src) + '    ') + e.args))
    if repo.mirror_locally:
        os.path.walk(dest_path, self.createrepo_walker, repo)
