Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when a .repo file contain many repos #165

Closed
garywill opened this issue Dec 8, 2023 · 0 comments
Closed

Error when a .repo file contain many repos #165

garywill opened this issue Dec 8, 2023 · 0 comments

Comments

@garywill
Copy link

garywill commented Dec 8, 2023

.repo files allow multiple repos in one file, e.g.:

[TUNA-Backports-update]
name=TUNA-Backports
enabled=1
autorefresh=0
baseurl=http://mirrors.tuna.tsinghua.edu.cn/opensuse/update/leap/$releasever/backports/
path=/
priority=88
keeppackages=0
[TUNA-dist-nonoss]
name=TUNA-dist-non-oss
enabled=1
autorefresh=0
baseurl=http://mirrors.tuna.tsinghua.edu.cn/opensuse/distribution/leap/$releasever/repo/non-oss/
path=/
keeppackages=0

When using opi 4.1.0 I encounter this error:

File "/usr/bin/opi", line 145, in <module>
repo_query(args.query)
File "/usr/bin/opi", line 85, in repo_query
binaries = opi.search_local_repos(selected_name) + binaries
File "/usr/lib/python3.6/site-packages/opi/__init__.py", line 192, in search_local_repos
installable['repository'] = repos_by_name[repo_name]
KeyError: 'TUNA-dist-nonoss'

I guess here it needs a for loop to go through every section:

opi/opi/__init__.py

Lines 202 to 225 in 275c41b

def get_repos():
for repo_file in os.listdir(REPO_DIR):
if not repo_file.endswith('.repo'):
continue
try:
cp = configparser.ConfigParser()
cp.read(os.path.join(REPO_DIR, repo_file))
mainsec = cp.sections()[0]
if not bool(int(cp.get(mainsec, 'enabled'))):
continue
repo = {
'alias': mainsec,
'filename': re.sub(r'\.repo$', '', repo_file),
'name': cp[mainsec].get('name', mainsec),
'url': cp[mainsec].get('baseurl'),
'auto_refresh': bool(int(cp[mainsec].get('autorefresh', '0'))),
}
if cp.has_option(mainsec, 'gpgkey'):
repo['gpgkey'] = cp[mainsec].get('gpgkey')
yield repo
except Exception as e:
print(f"Error parsing '{repo_file}': {e}")
def get_enabled_repo_by_url(url):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant