'upstream_tag': 'upstream/%(upstreamversion)s',
'squash_patches_until': '',
},
- 'remotebuild': {
- 'build_server': 'https://api.tizen.org',
- 'user': '',
- 'passwd': '',
- },
'build': {
'build_cmd': '/usr/bin/build',
'distconf': '/usr/share/gbs/tizen-1.0.conf',
return options
+ def has_section(self, section):
+ 'indicate whether a section exists'
+ for parser in self._cfgparsers:
+ if parser.has_section(section):
+ return True
+ return False
+
def get(self, opt, section='general'):
'get item value. return plain text of password if item is passwd'
if opt == 'passwd':
def _build_profile_by_name(self, name):
'''return profile object by a given section'''
if not name.startswith('profile.'):
- raise msger.error('profile section name must start '
- 'with "profile.": %s' % name)
+ raise errors.ConfigError('section name specified by general.profile '
+ 'must start with string "profile.": %s' % name)
+ if not self.has_section(name):
+ raise errors.ConfigError('no such section: %s' % name)
user = self.get_optional_item(name, 'user')
password = self.get_optional_item(name, 'passwd')
obs = self.get_optional_item(name, 'obs')
if obs:
if not obs.startswith('obs.'):
- msger.error('obs section name should start '
- 'with "obs.": %s' % obs)
+ raise errors.ConfigError('obs section name should start '
+ 'with string "obs.": %s' % obs)
obsconf = OBSConf(profile, obs,
self._get_url_options(obs),
for repo in repos.split(','):
repo = repo.strip()
if not repo.startswith('repo.'):
- msger.warning('repo section name should start '
- 'with "repo.": %s' % repo)
+ msger.warning('ignore %s, repo section name should start '
+ 'with string "repo."' % repo)
continue
repoconf = RepoConf(profile, repo,
profile = Profile('profile.current', None, None)
sec = 'remotebuild'
- addr = self.get('build_server', sec)
- user = self.get_optional_item(sec, 'user')
- password = self.get_optional_item(sec, 'passwd')
+ addr = self.get_optional_item(sec, 'build_server')
+ if addr:
+ user = self.get_optional_item(sec, 'user')
+ password = self.get_optional_item(sec, 'passwd')
- try:
- url = SafeURL(addr, user, password)
- except ValueError, err:
- raise errors.ConfigError('%s for %s' % (str(err), addr))
+ try:
+ url = SafeURL(addr, user, password)
+ except ValueError, err:
+ raise errors.ConfigError('%s for %s' % (str(err), addr))
- obsconf = OBSConf(profile, 'obs.%s' % sec, url,
- self.get_optional_item('remotebuild', 'base_prj'),
- self.get_optional_item('remotebuild', 'target_prj'))
- profile.set_obs(obsconf)
+ obsconf = OBSConf(profile, 'obs.%s' % sec, url,
+ self.get_optional_item('remotebuild', 'base_prj'),
+ self.get_optional_item('remotebuild', 'target_prj'))
+ profile.set_obs(obsconf)
repos = self._parse_build_repos()
for key, item in repos:
from mock import patch, MagicMock, Mock
import gitbuildsys.conf
+from gitbuildsys.errors import ConfigError
from test_config import Fixture
from test_passwdx import FakeFile
@Fixture(home='no_such_profile_section_name.ini')
def test_no_such_profile(self):
- 'test get a empty profile when name does not exist'
+ 'test profile name does not exist'
+ self.assertRaises(ConfigError, get_profile)
+
+ @Fixture(home='empty_profile.ini')
+ def test_empty_profile(self):
+ 'test get a empty profile'
profile = get_profile()
+
self.assertEquals(None, profile.obs)
self.assertEquals([], profile.repos)