summaryrefslogtreecommitdiff
path: root/examples/python/exception.py
blob: 9b7e6ec4a9f05c418aa8cd7bdce4b30a27ebac3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python

from zypp import TmpDir, RepoManagerOptions, RepoManager, RepoInfo, Url

tmp_root=TmpDir()
repo_manager = RepoManager(RepoManagerOptions(tmp_root.path()))

repo_info = RepoInfo()

repo_info.setAlias("factorytest")
repo_info.setName("Test Repo for Factory.")
repo_info.setEnabled(True)
repo_info.setAutorefresh(False)
repo_info.addBaseUrl(Url("file:///tmp/does-not-exist"))

try:
    repo_manager.addRepository(repo_info)
    repo_manager.refreshMetadata(repo_info)
    repo_manager.buildCache(repo_info)
except RuntimeError, strerror:
    print "RuntimeError"
    print strerror
else:
    print "Oh, no exception"