# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import os
+import string
+import sys
import shutil
import tempfile
import time
import urlparse
import urllib2
+import M2Crypto
import xml.etree.cElementTree as ElementTree
+from collections import defaultdict
+
import errors
from osc import conf, core
new_prj = True
else:
raise errors.ObsError("%s" % e)
- except urllib2.URLError, e:
+ except (urllib2.URLError, M2Crypto.m2urllib2.URLError, \
+ M2Crypto.SSL.SSLError), e:
raise errors.ObsError("%s" % e)
return new_prj
def get_buildconfig(self, prj, repository):
return core.get_buildconfig(self.apiurl, prj, repository)
- def get_repos(self, prj):
- repos = []
- for repo in core.get_repos_of_project(self.apiurl, prj):
- repos.append(repo)
- return repos
-
def get_ArchitectureList(self, prj, target):
"""
return the list of Archictecture of the target of the projectObsName for a OBS server.
return result
+ def get_results(self, prj, package):
+ try:
+ results = defaultdict(dict)
+ build_status = core.get_results(self.apiurl, prj, package)
+ for res in build_status:
+ repo, arch, status = res.split()
+ results[repo][arch] = status
+ return results
+ except (M2Crypto.m2urllib2.URLError, M2Crypto.SSL.SSLError), err:
+ raise errors.ObsError(str(err))
+
+ def get_buildlog(self, prj, package, repository, arch, offset = 0):
+ """prints out the buildlog on stdout"""
+ all_bytes = string.maketrans('', '')
+ remove_bytes = all_bytes[:10] + all_bytes[11:32]
+ try:
+ log = self.getBuildLog(prj, '%s/%s' % (repository, arch), package)
+ sys.stdout.write(log.translate(all_bytes, remove_bytes))
+ except (M2Crypto.m2urllib2.URLError, M2Crypto.SSL.SSLError), err:
+ raise errors.ObsError(str(err))
import msger
from conf import configmgr
+import buildservice
import obspkg
import errors
import utils
def do(opts, args):
- workdir = os.getcwd()
- if len(args) > 1:
- msger.error('only one work directory can be specified in args.')
- if len(args) == 1:
+ obs_repo = None
+ obs_arch = None
+
+ if len(args) == 0:
+ workdir = os.getcwd()
+ elif len(args) == 1:
+ workdir = os.path.abspath(args[0])
+ elif len(args) == 2 and opts.buildlog:
+ workdir = os.getcwd()
+ obs_repo = args[0]
+ obs_arch = args[1]
+ elif len(args) == 3 and opts.buildlog:
workdir = os.path.abspath(args[0])
+ obs_repo = args[1]
+ obs_arch = args[2]
+ else:
+ msger.error('Invalid arguments, see gbs remotebuild -h for more info')
+
try:
repo = RpmGitRepository(workdir)
except GitRepositoryError:
else:
target_prj = opts.target_obsprj
+ if opts.buildlog:
+ bs = buildservice.BuildService(apiurl=APISERVER, oscrc=oscrcpath)
+ archlist = []
+ status = bs.get_results(target_prj, spec.name)
+ for repository in status.keys():
+ for arch in status[repository]:
+ archlist.append('%-15s%-15s' % (repository, arch))
+ if not obs_repo or not obs_arch or obs_repo not in status.keys() or \
+ obs_arch not in status[obs_repo].keys():
+ msger.info('please specify correct repo / arch for buildlog')
+ msger.info('valid arguments of repo and arch are:\n%s' % \
+ '\n'.join(archlist))
+ return 1
+ if status[obs_repo][obs_arch] not in ['failed', 'succeeded', \
+ 'building']:
+ msger.error('build status of %s for %s/%s is %s, no build log.' % \
+ (spec.name, obs_repo, obs_arch, status[obs_repo][obs_arch]))
+ bs.get_buildlog(target_prj, spec.name, obs_repo, obs_arch)
+ return 0
+
+ if opts.status:
+ bs = buildservice.BuildService(apiurl=APISERVER, oscrc=oscrcpath)
+ results = []
+ status = bs.get_results(target_prj, spec.name)
+ for repository in status.keys():
+ for arch in status[repository]:
+ stat = status[repository][arch]
+ results.append('%-15s%-15s%-15s' % (repository, arch, stat))
+ msger.info('build results from build server:\n%s' % '\n'.join(results))
+ return 0
+
prj = obspkg.ObsProject(target_prj, apiurl = APISERVER, oscrc = oscrcpath)
msger.info('checking status of obs project: %s ...' % target_prj)
if prj.is_new():
default=None,
dest='commit',
help='Specify a commit ID to build')
+ @cmdln.option('--buildlog',
+ action='store_true',
+ default=False,
+ dest='buildlog',
+ help='Get buildlog from build sever')
+ @cmdln.option('--status',
+ action='store_true',
+ default=False,
+ dest='status',
+ help='Get build status from build server')
+
def do_remotebuild(self, subcmd, opts, *args):
"""${cmd_name}: remote build package