downloading builds from koji and added some print statements: Committed
by Rakesh Pandit
>From 8806f906cf450d5d0f5e76d009753a5b30443fd1 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Mon, 6 Jul 2009 14:01:16 +0530
Subject: [PATCH] * GachApplication.py (rm_rf, run): Added new function for tmp
directories, added koji builder to GachApplication run method
* GachBugzillaFeeder.py: replaced feed with downloadurl method.
* GachGenericFeeder.py (downloadurl): New function.
* GachKojiBuilder.py (build): Using downloadurl from feeder,
more print messages.
(getState, retrieve): fixed logic and more print statements.
---
GachApplication.py | 21 +++++++++++++++++----
GachBugzillaFeeder.py | 8 ++++----
GachGenericFeeder.py | 38 ++++++++++++++++++++++++++++++++++++++
GachKojiBuilder.py | 26 +++++++++++++++-----------
4 files changed, 74 insertions(+), 19 deletions(-)
diff --git a/GachApplication.py b/GachApplication.py
index 911e8ee..5e6fcc3 100644
--- a/GachApplication.py
+++ b/GachApplication.py
@@ -20,6 +20,7 @@
import os
import sys
import imp
+import time
import tempfile
from Spec import Spec
@@ -34,6 +35,15 @@ from GachReporter import GachReporter
from GachReviewer import runRpmlint
+def rm_rf(d):
+ for path in (os.path.join(d,f) for f in os.listdir(d)):
+ if os.path.isdir(path):
+ rm_rf(path)
+ else:
+ os.unlink(path)
+ os.rmdir(d)
+
+
class NoBugId(Exception):
"""
No Bug Id
@@ -88,6 +98,8 @@ class GachApplication:
# TODO: Need to put bugzilla URL in rom.config file
bzfeeder = GachBugzillaFeeder()
srpm_spec_downdir = tempfile.mkdtemp(prefix='gach')
+ koji_downdir = tempfile.mkdtemp(prefix='koji', dir=srpm_spec_downdir)
+
print "Downloading ..."
file_path = bzfeeder.feed(bugid, srpm_spec_downdir)
@@ -96,7 +108,6 @@ class GachApplication:
for file in file_path:
print file
- print "Started review:"
reporter = GachReporter()
spec = Spec(file_path[0])
pkg = Pkg(file_path[1])
@@ -108,11 +119,13 @@ class GachApplication:
reporter.printDividerInfo("Pkg rpmlint output")
runRpmlint(reporter, pkg)
+ builder = GachKojiBuilder()
+ builder.build(file_path[1], 'dist-f12', wait=True)
+
+ downloaded_files = builder.retrieve(koji_downdir)
print reporter.getReport()
- for file in file_path:
- os.unlink(file)
- os.rmdir(srpm_spec_downdir)
+ rm_rf(srpm_spec_downdir)
return
diff --git a/GachBugzillaFeeder.py b/GachBugzillaFeeder.py
index 937c253..a0e0c12 100644
--- a/GachBugzillaFeeder.py
+++ b/GachBugzillaFeeder.py
@@ -52,10 +52,10 @@ class
GachBugzillaFeeder(GachGenericFeeder.GachGenericFeeder):
uris = self._filterUris(uris)
file_paths = []
if uris:
- file_paths.append(GachGenericFeeder.GachGenericFeeder.feed( \
- self, uris[0], dest))
- file_paths.append(GachGenericFeeder.GachGenericFeeder.feed( \
- self, uris[1], dest))
+
file_paths.append(GachGenericFeeder.GachGenericFeeder.downloadurl( \
+ self, uris[0], dest, basename=True))
+
file_paths.append(GachGenericFeeder.GachGenericFeeder.downloadurl( \
+ self, uris[1], dest, basename=True))
return file_paths
return None
diff --git a/GachGenericFeeder.py b/GachGenericFeeder.py
index 828ad20..e3eaf32 100644
--- a/GachGenericFeeder.py
+++ b/GachGenericFeeder.py
@@ -18,6 +18,9 @@
import os
import urllib2
+from urlparse import urlparse, parse_qs
+import urlgrabber.grabber as grabber
+import urlgrabber.progress as progress
import GachFeeder
@@ -34,6 +37,39 @@ class GachGenericFeeder(GachFeeder.GachFeeder):
GachFeeder.GachFeeder.__init__(self)
self.bs = bs
+ # Alternate method for downloading
+ def downloadurl(self, url, downloaddir, basename=False):
+ """Download url using grabber
+ """
+ pg = progress.TextMeter()
+ urldict = urlparse(url)
+ querydict = parse_qs(urldict.query)
+
+ if not os.path.exists(downloaddir):
+ os.mkdir(downloaddir)
+
+ if basename:
+ filename = os.path.basename(url)
+ else:
+ filename = querydict['name'][0]
+
+ path = downloaddir + '/' + filename
+ out = os.open(path, os.O_WRONLY|os.O_CREAT|os.O_TRUNC, 0666)
+ file = grabber.urlopen(url, progress_obj = pg, text = "%s" \
+ %(filename))
+
+ try:
+ while 1:
+ buf = file.read(4096)
+ if not buf:
+ break
+ os.write(out, buf)
+ finally:
+ os.close(out)
+ file.close()
+
+ return path
+
def feed(self, item, dest):
"""
item: Spec/SRPM URI.
@@ -43,6 +79,7 @@ class GachGenericFeeder(GachFeeder.GachFeeder):
try:
uri = urllib2.urlopen(item)
except IOError, urllib2.URLError:
+ print "Error while downloading .."
return None
file_path = dest + "/" + os.path.basename(item)
@@ -65,3 +102,4 @@ class GachGenericFeeder(GachFeeder.GachFeeder):
file.close()
uri.close()
return file_path
+
diff --git a/GachKojiBuilder.py b/GachKojiBuilder.py
index decb787..4f63806 100644
--- a/GachKojiBuilder.py
+++ b/GachKojiBuilder.py
@@ -22,6 +22,7 @@ import random
import string
import time
import tempfile
+
import GachBuilder
from GachGenericFeeder import GachGenericFeeder
@@ -79,21 +80,25 @@ class GachKojiBuilder(GachBuilder.GachBuilder):
"""
self.__create_session()
server_dir = _unique_path("gach-build")
+ print "Uploading source %s ... " %(source),
self._session.uploadWrapper(source, server_dir)
+ print "done."
server_source = server_dir + "/" + os.path.basename(source)
build_opts = {"scratch": True, "skip_tag": None}
+ print "Started koji build with",
self.taskId = self._session.build(server_source, target, build_opts)
self.__logout_session()
-
+ print "taskid", self.taskId, ".. waiting ..."
if wait:
while True:
- state = self.get_state()
- print state
+ state = self.getState()
if state in ["CLOSED"]:
+ print "Job CLOSED."
return True
elif state in ["CANCELED", "FAILED"]:
+ print "Job either CANCELED or FAILED."
return False
- time.sleep(2)
+ time.sleep(0.2)
def getState(self):
"""Return state
@@ -108,10 +113,9 @@ class GachKojiBuilder(GachBuilder.GachBuilder):
"""Check is job done
"""
state = self.getState()
- if state in ["CLOSED"]:
+ if state in ["CLOSED", "CANCELED", "FAILED"]:
return True
- elif state in ["CANCELED", "FAILED"]:
- return False
+ return False
def retrieve(self, builddir):
"""Download all build rpms and logs for each child build
@@ -133,10 +137,10 @@ class GachKojiBuilder(GachBuilder.GachBuilder):
print "Downloading ..."
for eachtaskid in output:
- for eachfile in output[eachtaskid]:
- print eachfile + " ... ",
- path = builddir + "/" + str(eachtaskid)
- filepath.append(feeder.feed(eachfile, path))
+ for eachfileurl in output[eachtaskid]:
+ print eachfileurl + " ... ",
+ outdir = builddir + "/" + str(eachtaskid)
+ filepath.append(feeder.downloadurl(eachfileurl, outdir))
print "done."
self.__logout_session()
--
1.6.2.2
14 years, 9 months
written retrieve method for GachKojiBuilder: Committed
by Rakesh Pandit
>From fc3b8ecba38e94fa23f4432bb98c4c18ed33b997 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Sun, 5 Jul 2009 23:54:42 +0530
Subject: [PATCH] * GachKojiBuilder: New retrieve function downloads
rpm and logs of child
tasks
---
GachKojiBuilder.py | 107 ++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 83 insertions(+), 24 deletions(-)
diff --git a/GachKojiBuilder.py b/GachKojiBuilder.py
index a5dcb4d..decb787 100644
--- a/GachKojiBuilder.py
+++ b/GachKojiBuilder.py
@@ -21,7 +21,9 @@ import os
import random
import string
import time
+import tempfile
import GachBuilder
+from GachGenericFeeder import GachGenericFeeder
def _unique_path(prefix):
@@ -53,34 +55,91 @@ class GachKojiBuilder(GachBuilder.GachBuilder):
self.sslCert = os.path.expanduser(ssl_cert)
self.sslCa = os.path.expanduser(ssl_ca)
self.sslServerCa = os.path.expanduser(ssl_serverca)
+ self._session = None
+ self._url = "http://koji.fedoraproject.org/koji/getfile?taskID="
- def build(self, source, target):
+ def __create_session(self):
+ """Create koji session
+ """
+ if self._session is None:
+ session_opts = {}
+ self._session = koji.ClientSession(self.kojiServer, session_opts)
+ self._session.ssl_login(self.sslCert, self.sslCa, self.sslServerCa)
+
+ def __logout_session(self):
+ """Logout session
+ """
+ if self._session is not None:
+ self._session.logout()
+
+ def build(self, source, target, wait=False):
"""
source: Path to a source RPM.
target: Koji tag to build against. eg., dist-f11.
"""
- session_opts = {}
- session = koji.ClientSession(self.kojiServer, session_opts)
- session.ssl_login(self.sslCert, self.sslCa, self.sslServerCa)
-
- server_dir = _unique_path("rom-build")
- session.uploadWrapper(source, server_dir)
+ self.__create_session()
+ server_dir = _unique_path("gach-build")
+ self._session.uploadWrapper(source, server_dir)
server_source = server_dir + "/" + os.path.basename(source)
build_opts = {"scratch": True, "skip_tag": None}
- self.taskId = session.build(server_source, target, build_opts)
-
- session.logout()
-
- while True:
- task_info = session.getTaskInfo(self.taskId, request=True)
- if task_info is None:
- raise Exception()
- state = koji.TASK_STATES[task_info["state"]]
- if state in ["CLOSED"]:
- return True
- elif state in ["CANCELED", "FAILED"]:
- return False
- time.sleep(2)
-
- def retrieve(self):
- raise NotImplementedError()
+ self.taskId = self._session.build(server_source, target, build_opts)
+ self.__logout_session()
+
+ if wait:
+ while True:
+ state = self.get_state()
+ print state
+ if state in ["CLOSED"]:
+ return True
+ elif state in ["CANCELED", "FAILED"]:
+ return False
+ time.sleep(2)
+
+ def getState(self):
+ """Return state
+ """
+ task_info = self._session.getTaskInfo(self.taskId, request=True)
+ if task_info is None:
+ raise Exception()
+ state = koji.TASK_STATES[task_info["state"]]
+ return state
+
+ def isdone(self):
+ """Check is job done
+ """
+ state = self.getState()
+ if state in ["CLOSED"]:
+ return True
+ elif state in ["CANCELED", "FAILED"]:
+ return False
+
+ def retrieve(self, builddir):
+ """Download all build rpms and logs for each child build
+ """
+ self.__create_session()
+ tasks = self._session.listTasks(opts={'parent': self.taskId})
+ output = {}
+ for eachtask in tasks:
+ id = eachtask['id']
+ files = self._session.listTaskOutput(id)
+ output[id] = files
+ for index in range(len(files)):
+ output[id][index] = self._url + str(id) + "&name=" + \
+ output[id][index]
+
+ filepath = []
+ # Using feeder feed function for downloading
+ feeder = GachGenericFeeder()
+
+ print "Downloading ..."
+ for eachtaskid in output:
+ for eachfile in output[eachtaskid]:
+ print eachfile + " ... ",
+ path = builddir + "/" + str(eachtaskid)
+ filepath.append(feeder.feed(eachfile, path))
+ print "done."
+
+ self.__logout_session()
+ return filepath
+
+
--
1.6.2.5
14 years, 9 months
some more moddification to GachApplication: Committed
by Rakesh Pandit
>From b7258246dad404fb47aa137f3669da0d0756046a Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Sun, 5 Jul 2009 11:11:51 +0530
Subject: [PATCH] * GachApplication.py (run): Added Spec & Pkg Usage
and added rpmlint output
to report.
* GachReporter.py (printDividerInfo): New method to add report section header
information.
* Pkg.py (getFilePath): Fixed missing self before path.
---
GachApplication.py | 24 +++++++++++++++++++++---
GachReporter.py | 7 +++++++
Pkg.py | 2 +-
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/GachApplication.py b/GachApplication.py
index 63e6fe1..911e8ee 100644
--- a/GachApplication.py
+++ b/GachApplication.py
@@ -22,12 +22,16 @@ import sys
import imp
import tempfile
+from Spec import Spec
+from Pkg import Pkg
from GachBugzillaFeeder import GachBugzillaFeeder
from GachRPMReviewer import GachRPMReviewer
from GachSpecReviewer import GachSpecReviewer
from GachSrcRPMReviewer import GachSrcRPMReviewer
from GachBugzillaReporter import GachBugzillaReporter
from GachKojiBuilder import GachKojiBuilder
+from GachReporter import GachReporter
+from GachReviewer import runRpmlint
class NoBugId(Exception):
@@ -84,13 +88,27 @@ class GachApplication:
# TODO: Need to put bugzilla URL in rom.config file
bzfeeder = GachBugzillaFeeder()
srpm_spec_downdir = tempfile.mkdtemp(prefix='gach')
+ print "Downloading ..."
+
file_path = bzfeeder.feed(bugid, srpm_spec_downdir)
- # TODO: Review
+ print "Downloaded files are at: "
+ for file in file_path:
+ print file
+
+ print "Started review:"
+ reporter = GachReporter()
+ spec = Spec(file_path[0])
+ pkg = Pkg(file_path[1])
+
+ # TODO Test expecution and building via builders
+ reporter.printDividerInfo("Spec file rpmlint output")
+ runRpmlint(reporter, spec)
- # TODO: Building
+ reporter.printDividerInfo("Pkg rpmlint output")
+ runRpmlint(reporter, pkg)
- # TODO: Reporting
+ print reporter.getReport()
for file in file_path:
os.unlink(file)
diff --git a/GachReporter.py b/GachReporter.py
index 68dc50d..090dd6c 100644
--- a/GachReporter.py
+++ b/GachReporter.py
@@ -90,6 +90,13 @@ class GachReporter(object):
self.report +="\n"
+ def printDividerInfo(self, msg):
+ """
+ """
+ self.report +=
"===========================================================================\n"
+ self.report += msg + ":\n"
+ self.report +=
"===========================================================================\n"
+
def printInfo(self, reason, **details):
"""
reason: message
diff --git a/Pkg.py b/Pkg.py
index e665df3..432cb1c 100644
--- a/Pkg.py
+++ b/Pkg.py
@@ -59,7 +59,7 @@ class Pkg(object):
def getFilePath(self):
"""Return pkg file path
"""
- return path
+ return self.path
class Rpm(Pkg):
--
1.6.2.5
14 years, 9 months
minor fix - Removed 'self' arg from runRpmlint.: Committed
by Rakesh Pandit
>From 03a96f6b35e784e337b8306e35e554491971a737 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Sun, 5 Jul 2009 08:57:16 +0530
Subject: [PATCH] * GachReviewer: Removed 'self' arg from runRpmlint.
---
GachReviewer.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/GachReviewer.py b/GachReviewer.py
index cd43de4..f79ca81 100644
--- a/GachReviewer.py
+++ b/GachReviewer.py
@@ -23,7 +23,7 @@ import imp
import Check
-def runRpmlint(self, reporter, *details):
+def runRpmlint(reporter, *details):
"""
Returns rpmlint messages on spec, srpm, rpm.
"""
--
1.6.2.5
14 years, 9 months
initial version of missing Pkg class: committed
by Rakesh Pandit
>From e99e9e7250a0db81e4354df525ff57785223f01f Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Sun, 5 Jul 2009 08:40:39 +0530
Subject: [PATCH 2/2] * Pkg.py: New file
---
Pkg.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 70 insertions(+), 0 deletions(-)
create mode 100644 Pkg.py
diff --git a/Pkg.py b/Pkg.py
new file mode 100644
index 0000000..e665df3
--- /dev/null
+++ b/Pkg.py
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os
+import rpm
+import string
+
+
+class Pkg(object):
+ """Pkg file class
+ """
+
+ def __init__(self, file):
+ """
+ """
+ self.file = file
+ self.filename = os.path.basename(file)
+ self.path = os.path.dirname(file)
+ self._hdr = None
+
+ self.__readPkg()
+
+ def __readPkg(self):
+ """Read Pkg file
+ """
+ ts = rpm.ts()
+ ts.setVSFlags(rpm._RPMVSF_NOSIGNATURES)
+
+ fdno = os.open(self.file, os.O_RDONLY)
+ self._hdr = ts.hdrFromFdno(fdno)
+ os.close(fdno)
+
+ def __getitem__(self, key):
+ """Operator overloading - read
+ """
+ key = string.lower(key)
+ return self._hdr[key]
+
+ def getFileName(self):
+ """Return pkg file name
+ """
+ return self.filename
+
+ def getFilePath(self):
+ """Return pkg file path
+ """
+ return path
+
+
+class Rpm(Pkg):
+ pass
+
+
+class Srpm(Pkg):
+ pass
--
1.6.2.5
14 years, 9 months
initial app module and gach script: Committed
by Rakesh Pandit
>From 2ee6c4014fabe05e52297464c24b9f90ca13b19e Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Fri, 3 Jul 2009 15:29:19 +0530
Subject: [PATCH] * GachApplication.py: Minimal app module, new file.
* gach: new script file.
---
GachApplication.py | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++++
gach | 62 ++++++++++++++++++++++++++++++++
2 files changed, 163 insertions(+), 0 deletions(-)
create mode 100644 GachApplication.py
create mode 100644 gach
diff --git a/GachApplication.py b/GachApplication.py
new file mode 100644
index 0000000..63e6fe1
--- /dev/null
+++ b/GachApplication.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#
+# Copyright 2009 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+import os
+import sys
+import imp
+import tempfile
+
+from GachBugzillaFeeder import GachBugzillaFeeder
+from GachRPMReviewer import GachRPMReviewer
+from GachSpecReviewer import GachSpecReviewer
+from GachSrcRPMReviewer import GachSrcRPMReviewer
+from GachBugzillaReporter import GachBugzillaReporter
+from GachKojiBuilder import GachKojiBuilder
+
+
+class NoBugId(Exception):
+ """
+ No Bug Id
+ """
+
+ def __str__(self):
+ """
+ """
+ return "Missing bugzilla bug id."
+
+
+class GachApplication:
+ """
+ Implements main app class.
+ """
+
+ def __init__(self, glinedir=None):
+ """
+ """
+ self.checks = ['BuildRootCheck',
+ 'SampleCheck']
+ if glinedir:
+ self._directories = [guidelinedir]
+ else:
+ self._directories = ["", "/usr/share/gach/"]
+
+ # Load all default checks
+ self._loadchecks(self.checks)
+
+ def _loadchecks(self, list=[]):
+ """Loads all checks
+ """
+ for name in list:
+ loaded = sys.modules.get(name)
+ if loaded:
+ return loaded
+ (f, pathname, description) = imp.find_module(name, \
+ self._directories)
+ try:
+ imp.load_module(name, f, pathname, description)
+ finally:
+ f.close()
+ return
+
+
+ def run(self, bugid=None):
+ """Main programme to be run
+ """
+ if not bugid:
+ raise NoBugId()
+
+ # TODO: Need to put bugzilla URL in rom.config file
+ bzfeeder = GachBugzillaFeeder()
+ srpm_spec_downdir = tempfile.mkdtemp(prefix='gach')
+ file_path = bzfeeder.feed(bugid, srpm_spec_downdir)
+
+ # TODO: Review
+
+ # TODO: Building
+
+ # TODO: Reporting
+
+ for file in file_path:
+ os.unlink(file)
+ os.rmdir(srpm_spec_downdir)
+
+ return
+
+# GachApplication ends here
diff --git a/gach b/gach
new file mode 100644
index 0000000..01fa7b4
--- /dev/null
+++ b/gach
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# Copyright 2009 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+import sys
+from optparse import OptionParser
+
+from GachApplication import GachApplication
+
+VERSION='0.1'
+
+
+def usage():
+ """Usage
+ """
+ return "Usage: gach [<options>]"
+
+
+def check_options(argv = []):
+ """Option details
+ """
+ version = "Gach version " + VERSION
+ parser = OptionParser(usage=usage(), version=version)
+
+ # Add options here: parser.add_options(<details>)
+ parser.add_option("-b", "--bugid", action="store", dest="bugid", \
+ help="bugzilla id which needs review")
+ parser.add_option("-G", "--guidelinedir", action="store", \
+ dest="guiddir", help="Guideline directory")
+ return parser.parse_args(args=argv)
+
+
+def main(argv):
+ """Main program
+ """
+ (options, args) = check_options(sys.argv[1:])
+ app = GachApplication(glinedir=options.guiddir)
+
+ if not options.bugid:
+ print "Error: No bug id found (enter with -b )."
+ sys.exit(1)
+
+ app.run(bugid=options.bugid)
+ return
+
+if __name__ == '__main__':
+ main(sys.argv)
--
1.6.2.2
14 years, 10 months
some adjustments in SampleCheck and BuildRootCheck to make them work with new modules: Committed
by Rakesh Pandit
>From 359da472023bac5eefcfbf491bf5819d988bf943 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Fri, 3 Jul 2009 15:07:50 +0530
Subject: [PATCH] * BuildRootCheck.py, GachReporter.py,
SampleCheck.py: Adjustment in
accordance with GachReporter. Changed Filter and ReviewSpec module
usage with GachReporter to make existing test and sample test working.
---
BuildRootCheck.py | 18 +++++++++---------
GachReporter.py | 24 ++++++++++++++++++++++++
SampleCheck.py | 11 ++++++-----
3 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/BuildRootCheck.py b/BuildRootCheck.py
index e63a95e..4a6b8a9 100644
--- a/BuildRootCheck.py
+++ b/BuildRootCheck.py
@@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import SpecCheck
-import ReviewSpec
-from Filter import *
+from GachReporter import GachReporter
+
import re
# Allowed expressions for the buildroot tag by Fedora:
@@ -34,6 +34,7 @@ buildroot_regex = re.compile(r"""
""", re.VERBOSE)
prep_regex = re.compile(r"^[ \t]*%{?prep}?")
+reporter = GachReporter()
class BuildRootCheck(SpecCheck.SpecCheck):
"""Check the buildroot tag of the spec file to see if it matches
the guidelines."""
@@ -45,7 +46,7 @@ class BuildRootCheck(SpecCheck.SpecCheck):
def check(self, spec):
"""Buildroot Check"""
# Parse the spec file and get the buildroot(s)
- #printInfo(spec, "buildroot-check")
+ #reporter.printInfo(spec, "buildroot-check")
file=open(spec.filename, "r")
result = file.readlines()
file.close()
@@ -58,24 +59,23 @@ class BuildRootCheck(SpecCheck.SpecCheck):
buildroot = buildroot_tag_separator.split(i)[1]
if number_of_specified_buildroots > 1:
- printError(spec, "multiple-buildroots")
+ reporter.printError(spec, "multiple-buildroots")
return
elif number_of_specified_buildroots == 0:
- printError(spec, "no-buildroot")
+ reporter.printError(spec, "no-buildroot")
return
if buildroot_regex.match(buildroot):
- printInfo(spec, "buildroot-check", "passed")
+ reporter.printInfo(spec, "buildroot-check", "passed")
else:
- printError(spec, "bad-buildroot", buildroot)
+ reporter.printError(spec, "bad-buildroot", buildroot)
# An object to autoregister the check
check=BuildRootCheck()
-if ReviewSpec.info:
- addDetails(
+reporter.addDetails(
'buildroot-check',
'''Check the buildroot tag of the spec file to see if it matches the
guidelines.\n
It needs to be one of these three:\n
diff --git a/GachReporter.py b/GachReporter.py
index 87cad4e..68dc50d 100644
--- a/GachReporter.py
+++ b/GachReporter.py
@@ -35,6 +35,30 @@ class GachReporter(object):
"""
"""
self.report = ""
+ self._details = {}
+ self.info = True
+
+ def addDetails(self, *details):
+ """Add test info details
+ """
+ for idx in range(len(details)/2):
+ self._details[details[idx*2]] = details[idx*2+1]
+
+ def setVerbose(self, value):
+ """Set verbose
+ """
+ self.info = value
+
+ def _printDescriptions(self, reason):
+ """Just for debugging
+ """
+ try:
+ d = self._details[reason]
+ if d and d != '' and d != "\n":
+ sys.stdout.write(fill(d, 78))
+ sys.stdout.write("\n\n")
+ except KeyError:
+ pass
def getReport(self):
"""
diff --git a/SampleCheck.py b/SampleCheck.py
index 78307a5..ddf0f61 100644
--- a/SampleCheck.py
+++ b/SampleCheck.py
@@ -17,8 +17,10 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import SpecCheck
-import ReviewSpec
-from Filter import *
+from GachReporter import GachReporter
+
+
+reporter = GachReporter()
class SampleCheck(SpecCheck.SpecCheck):
@@ -30,13 +32,12 @@ class SampleCheck(SpecCheck.SpecCheck):
def check(self, spec):
"""Sample Check"""
- printInfo(spec, "sample-testing")
+ reporter.printInfo(spec, "sample-testing")
# An object to autoregister the check
check=SampleCheck()
-if ReviewSpec.info:
- addDetails(
+reporter.addDetails(
'sample-testing',
'''The is a sample check''')
--
1.6.2.2
14 years, 10 months
Removed flags from already compiled regx: Committed
by Rakesh Pandit
>From c2574156df1effb5c9f75ab502ade9aada1cff6b Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Fri, 3 Jul 2009 14:05:55 +0530
Subject: [PATCH] * GachBugzillaFeeder.py: Removed flags from already
compiled regx.
---
GachBugzillaFeeder.py | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/GachBugzillaFeeder.py b/GachBugzillaFeeder.py
index 7e6bf1e..937c253 100644
--- a/GachBugzillaFeeder.py
+++ b/GachBugzillaFeeder.py
@@ -69,7 +69,7 @@ class GachBugzillaFeeder(GachGenericFeeder.GachGenericFeeder):
filtrates = []
for uri in uris:
- filtrate = re.findall(spec_srpm_pattern, uri, flags=re.IGNORECASE)
+ filtrate = re.findall(spec_srpm_pattern, uri)
if filtrate:
filtrates += filtrate
@@ -97,5 +97,5 @@ class GachBugzillaFeeder(GachGenericFeeder.GachGenericFeeder):
')') % ('|'.join(url_schemes),)
uri_pattern = re.compile(url_format, flags=re.IGNORECASE)
- uris = re.findall(uri_pattern, text, flags=re.IGNORECASE)
+ uris = re.findall(uri_pattern, text)
return uris
--
1.6.2.2
14 years, 10 months
fixed import : Committed
by Rakesh Pandit
>From 3136ff89d57f96ea0988cfbf09cc4279da8fb1c4 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Fri, 3 Jul 2009 13:13:48 +0530
Subject: [PATCH] * GachRPMReviewer.py: Fixed import GachReviewer.
---
GachRPMReviewer.py | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/GachRPMReviewer.py b/GachRPMReviewer.py
index 786bde4..7a820cb 100644
--- a/GachRPMReviewer.py
+++ b/GachRPMReviewer.py
@@ -16,7 +16,7 @@
# along with translate; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-import Reviewer
+import GachReviewer
import RPMCheck
--
1.6.2.2
14 years, 10 months