[review-o-matic] [PATCH] RomBugzillaFeeder.py
by Debarshi Ray
Here [1] is a patch to implement RomBugzillaFeeder. This is a
deviation from the class design where RomBugzillaFeeder is derived
from RomFeeder and not RomGenericFeeder.
>From 0ebc7f7c9c943978ba82d205113a46b694ee712c Mon Sep 17 00:00:00 2001
From: Debarshi Ray <rishi(a)fedoraproject.org>
Date: Sat, 20 Dec 2008 12:16:47 +0530
Subject: [PATCH] * RomBugzillaFeeder.py: New file.
---
RomBugzillaFeeder.py | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 101 insertions(+), 0 deletions(-)
create mode 100644 RomBugzillaFeeder.py
diff --git a/RomBugzillaFeeder.py b/RomBugzillaFeeder.py
new file mode 100644
index 0000000..c97fa81
--- /dev/null
+++ b/RomBugzillaFeeder.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Debarshi Ray <rishi(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 bugzilla
+import os
+import re
+import urllib2
+
+import RomGenericFeeder
+
+
+class RomBugzillaFeeder(RomGenericFeeder.RomGenericFeeder):
+ """
+ Implements a Bugzilla feeder.
+ """
+
+ def __init__(self,
bugzilla_server="https://bugzilla.redhat.com/xmlrpc.cgi"):
+ """
+ bugzilla_server: URI of a Bugzilla instance. Default is
+ https://bugzilla.redhat.com/xmlrpc.cgi
+ """
+ RomGenericFeeder.RomGenericFeeder.__init__(self)
+ self.bugzillaServer = bugzilla_server
+
+ def feed(self, item, dest):
+ """
+ item: Review request bug number.
+ dest: Path to a destination directory.
+ """
+ bz = bugzilla.Bugzilla(url=self.bugzillaServer)
+ bug = bz.getbug(item)
+ size = len(bug.longdescs)
+
+ for each in reversed(bug.longdescs):
+ comment = each["body"]
+ uris = self._scrapeUris(comment)
+ uris = self._filterUris(uris)
+ file_paths = []
+ if uris:
+ file_paths.append(RomGenericFeeder.RomGenericFeeder.feed( \
+ self, uris[0], dest))
+ file_paths.append(RomGenericFeeder.RomGenericFeeder.feed( \
+ self, uris[1], dest))
+ return file_paths
+
+ return None
+
+ def _filterUris(self, uris):
+ """
+ uris: List of URIs to be filtered.
+ """
+ spec_srpm_re = ".*\.spec$|.*\.src\.rpm$"
+ spec_srpm_pattern = re.compile(spec_srpm_re, flags=re.IGNORECASE)
+
+ filtrates = []
+ for uri in uris:
+ filtrate = re.findall(spec_srpm_pattern, uri, flags=re.IGNORECASE)
+ if filtrate:
+ filtrates += filtrate
+
+ return filtrates
+
+ def _scrapeUris(self, text):
+ """
+ text: Text that might contain URIs.
+ """
+ # http://www.parsed.org/tip/458/
+ url_schemes = ('http', 'https', 'ftp', 'mailto', 'news', 'gopher', \
+ 'nntp', 'telnet', 'wais', 'prospero', 'aim', \
+ 'webcal')
+ # Note: fragment id is uchar | reserved, see rfc 1738 page 19
+ # %% for % because of string formating
+ # puncuation = ? , ; . : !
+ # if punctuation is at the end, then don't include it
+ url_format = (r'(?<!\w)((?:%s):' # protocol + :
+ '/*(?!/)(?:' # get any starting /'s
+ '[\w$\+\*@&=\-/]' # reserved | unreserved
+ '|%%[a-fA-F0-9]{2}' # escape
+ '|[\?\.:\(\),;!\'](?!(?:\s|$))' # punctuation
+ '|(?:(?<=[^/:]{2})#)' # fragment id
+ '){2,}' # at least two characters in the main url part
+ ')') % ('|'.join(url_schemes),)
+
+ uri_pattern = re.compile(url_format, flags=re.IGNORECASE)
+ uris = re.findall(uri_pattern, text, flags=re.IGNORECASE)
+ return uris
--
1.5.6.5
Comments?
Happy hacking,
Debarshi
----
[1] http://rishi.fedorapeople.org/0002--RomBugzillaFeeder.py-New-file.patch
15 years, 4 months
[review-o-matic] [PATCH] RomFeeder and RomGenericFeeder
by Debarshi Ray
Here [1] is a patch to implement the RomFeeder adn RomGenericFeeder
classes. Pretty basic stuff and zero error handling at the moment, but
I guess that is fine for the time being.
>From 56ca501ccd6e3b3fc13c65d1e21e684c0d5b6521 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <rishi(a)fedoraproject.org>
Date: Fri, 19 Dec 2008 14:48:32 +0530
Subject: [PATCH] * RomFeeder.py, RomGenericFeeder.py: New files.
---
RomFeeder.py | 32 +++++++++++++++++++++++++++++++
RomGenericFeeder.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/RomFeeder.py b/RomFeeder.py
new file mode 100644
index 0000000..beb7b5e
--- /dev/null
+++ b/RomFeeder.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Debarshi Ray <rishi(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
+
+class RomFeeder:
+ """
+ Abstract feeder interface to be implemented by derived classes.
+ """
+
+ def __init__(self):
+ pass
+
+ def feed(self, item, dest):
+ """
+ item: Review request bug number or Spec/SRPM URI.
+ dest: Path to a destination directory.
+ """
+ raise NotImplementedError()
diff --git a/RomGenericFeeder.py b/RomGenericFeeder.py
new file mode 100644
index 0000000..cc45678
--- /dev/null
+++ b/RomGenericFeeder.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Debarshi Ray <rishi(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 urllib2
+import RomFeeder
+
+class RomGenericFeeder(RomFeeder.RomFeeder):
+ """
+ Implements a generic URI (eg., file://, ftp://, http://, etc.) feeder.
+ """
+
+ def __init__(self, bs=4096):
+ """
+ bs: Read bs bytes at a time. Default is 4096.
+ """
+ RomFeeder.RomFeeder.__init__(self)
+ self.bs = bs
+
+ def feed(self, item, dest):
+ """
+ item: Spec/SRPM URI.
+ dest: Path to a destination directory.
+ """
+ uri = urllib2.urlopen(item)
+ file_path = dest + "/" + os.path.basename(item)
+ file = open(file_path, "wb")
+
+ buf = ""
+ buf = uri.read(self.bs)
+ while buf:
+ file.write(buf)
+ buf = uri.read(self.bs)
+
+ file.close()
+ uri.close()
+ return file_path
--
1.4.0
Comments?
Happy hacking,
Debarshi
----
[1] http://rishi.fedorapeople.org/0001-RomFeeder.py-RomGenericFeeder.py-New-f...
15 years, 4 months
[review-o-matic] [PATCH] PEP8 and PEP2 guideline changes.
by Rakesh Pandit
Hello,
I have made some changes[1] in accordance with PEP8[2] and PEP2[3]
coding guidelines. We will be following them for future work. I
haven't followed 79 character limit, but if we keep this in mind while
writing that will be good.
[1] http://rakesh.fedorapeople.org/misc/coding_guidelines.patch
[2] http://www.python.org/dev/peps/pep-0008/
[3] http://www.python.org/dev/peps/pep-0002/
--
rakesh
diff --git a/BuildRootCheck.py b/BuildRootCheck.py
index 6d606b2..71be1cd 100644
--- a/BuildRootCheck.py
+++ b/BuildRootCheck.py
@@ -21,7 +21,7 @@
import SpecCheck
import ReviewSpec
-from Filter import *
+from Filter import *
import re
# Allowed expressions for the buildroot tag by Fedora:
@@ -94,7 +94,6 @@ It needs to be one of these three:\n
'''Buildroot must be set to one of these three expressions:
%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
- %{_tmppath}/%{name}-%{version}-%{release}-root'''
-)
+ %{_tmppath}/%{name}-%{version}-%{release}-root''')
# SpecCheck ends here
diff --git a/Filter.py b/Filter.py
index 180e4b5..501b628 100644
--- a/Filter.py
+++ b/Filter.py
@@ -20,11 +20,13 @@ import sys
_details={}
+
def addDetails(*details):
""" """
for idx in range(len(details)/2):
_details[details[idx*2]]=details[idx*2+1]
+
def printDescriptions(reason):
""" """
try:
@@ -35,26 +37,31 @@ def printDescriptions(reason):
except KeyError:
pass
+
def printInfo(spec, reason, *details):
""" """
# I => Info
_print("I", spec, reason, details)
+
def printMust(spec, reason, *details):
""" """
# M => Must
_print("M", spec, reason, details)
+
def printShould(spec, reason, *details):
""" """
# S => Should
_print("S", spec, reason, details)
+
def printError(spec, reason, *details):
""" """
# E => Error
_print("E", spec, reason, details)
+
def printWarning(spec, reason, *details):
""" """
# W => Warning
@@ -72,7 +79,7 @@ def _print(type, spec, reason, details):
for d in details:
output_string = output_string + " %s" %d
- output_string += "\n";
+ output_string += "\n"
sys.stdout.write(output_string)
# filter ends here
diff --git a/FindDownload.py b/FindDownload.py
index 4a048e2..55dbc1a 100644
--- a/FindDownload.py
+++ b/FindDownload.py
@@ -24,10 +24,11 @@ import urllib2
download_dir = "./downloads/"
+
class FindDownload:
"""This will find and download spec and srpm"""
- def __init__(self,bugid):
+ def __init__(self, bugid):
"""Init method"""
page = "https://bugzilla.redhat.com/show_bug.cgi?id=" + str(bugid)
f = urllib2.urlopen(page)
@@ -44,7 +45,7 @@ class FindDownload:
print "Downloading SPEC"
specdata = f.read()
specname = os.path.basename(spec)
- f = open(os.path.join(download_dir,str(bugid),specname),"w")
+ f = open(os.path.join(download_dir, str(bugid), specname), "w")
f.write(specdata)
f.close()
@@ -58,8 +59,9 @@ class FindDownload:
print "Downloading SRPM"
srpmdata = f.read()
srpmname = os.path.basename(srpm)
- f = open(os.path.join(download_dir,str(bugid),srpmname),"wb")
+ f = open(os.path.join(download_dir, str(bugid), srpmname), "wb")
f.write(srpmdata)
f.close()
- self.path = os.path.join(download_dir,str(bugid))
- self.data = (os.path.join(download_dir,str(bugid),srpmname),
os.path.join(download_dir,str(bugid),specname))
+ self.path = os.path.join(download_dir, str(bugid))
+ self.data = (os.path.join(download_dir, str(bugid), srpmname), \
+ os.path.join(download_dir, str(bugid), specname))
diff --git a/ReviewSpec.py b/ReviewSpec.py
index e194d43..ecd0619 100644
--- a/ReviewSpec.py
+++ b/ReviewSpec.py
@@ -29,12 +29,14 @@ import SpecCheck
version='0.01'
+
def usage(name):
"""Print Usage Information"""
print 'usage:', name, '[<option>] <specfile>'
print ' options in:'
print '\t[-i|--info]\n\t[-g|--guideline
<guideline>]\n\t[-G|--guidelinedir
<guidelinedir>]\n\t[-v|--verbose]\n\t[-V|--version]\n\t[-h|--help]'
+
def printVersion():
"""Print Version Information"""
print 'reviewspec version', version, 'Copyright (C) 2008 Rakesh
Pandit, Fedora'
@@ -48,8 +50,7 @@ try:
'verbose',
'version',
'help'
- 'info'
- ])
+ 'info'])
except getopt.error, e:
usage(sys.argv[0])
@@ -58,7 +59,7 @@ except getopt.error, e:
if not args and not options:
usage(sys.argv[0])
sys.exit(1)
-
+
# Default options
verbose = 0
_directories = [".", "/usr/share/reviewspec"]
@@ -67,8 +68,7 @@ info=0
DEFAULT_GUIDELINES=( # Add all default checks here
"SampleCheck",
- "BuildRootCheck"
- )
+ "BuildRootCheck")
# Command line options
for opt in options:
@@ -87,7 +87,7 @@ for opt in options:
dir = opt[1]
dirpath = os.path.expanduser(dir)
- if not dirpath in _directories:
+ if not dirpath in _directories:
_directories.insert(0, dirpath)
if opt[0] == '-g' or opt[0] == '--guideline':
@@ -99,7 +99,7 @@ for opt in options:
if opt[0] == '-v' or opt[0] == '--verbose':
verbose = 1
-
+
def review():
"""Main review function"""
@@ -111,7 +111,7 @@ def review():
if _checks == []:
_checks += (DEFAULT_GUIDELINES)
for name in _checks:
- try:
+ try:
(file, path, description) = imp.find_module(name, _directories)
except ImportError:
print "The guideline is not present in any of locations:
", _directories
@@ -155,7 +155,7 @@ def review():
# Once Spec class is designed uncomment
runReviewChecks(spec)
review_done += 1
-
+
# Directories
for d in dirs:
try:
@@ -202,9 +202,10 @@ def review():
finally:
print "%d specs reviewed." % review_done
+
def runReviewChecks(spec):
if verbose:
- print "checking ", spec.getName() , "..."
+ print "checking ", spec.getName(), "..."
# Run all guidelines
for guide in SpecCheck.SpecCheck.checks:
diff --git a/RomBuilder.py b/RomBuilder.py
index 480d8ea..21b7282 100644
--- a/RomBuilder.py
+++ b/RomBuilder.py
@@ -16,6 +16,7 @@
# along with translate; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
class RomBuilder:
"""
Abstract builder interface to be implemented by derived classes.
diff --git a/RomKojiBuilder.py b/RomKojiBuilder.py
index 2fa400c..34e745f 100644
--- a/RomKojiBuilder.py
+++ b/RomKojiBuilder.py
@@ -23,6 +23,7 @@ import string
import time
import RomBuilder
+
def _unique_path(prefix):
"""
Taken from the Koji client: /usr/bin/koji
@@ -65,7 +66,7 @@ class RomKojiBuilder(RomBuilder.RomBuilder):
server_dir = _unique_path("rom-build")
session.uploadWrapper(source, server_dir)
server_source = server_dir + "/" + os.path.basename(source)
- build_opts = {"scratch" : True, "skip_tag" : None}
+ build_opts = {"scratch": True, "skip_tag": None}
self.taskId = session.build(server_source, target, build_opts)
session.logout()
diff --git a/SampleCheck.py b/SampleCheck.py
index 4fd7fc5..78307a5 100644
--- a/SampleCheck.py
+++ b/SampleCheck.py
@@ -18,7 +18,8 @@
import SpecCheck
import ReviewSpec
-from Filter import *
+from Filter import *
+
class SampleCheck(SpecCheck.SpecCheck):
"""Sample test"""
@@ -37,7 +38,6 @@ check=SampleCheck()
if ReviewSpec.info:
addDetails(
'sample-testing',
-'''The is a sample check'''
-)
+'''The is a sample check''')
# SpecCheck ends here
diff --git a/Spec.py b/Spec.py
index 30c47f1..3ef98f0 100644
--- a/Spec.py
+++ b/Spec.py
@@ -19,9 +19,10 @@
import re
import string
+
class Spec(object):
"""Spec file class """
-
+
def __init__(self, filename):
""" """
self.filename=filename
@@ -84,6 +85,7 @@ class Spec(object):
fobj.close()
# Get functions
+
def getSpecname(self):
""" Returns spec file name."""
return self.filename
@@ -158,7 +160,7 @@ class Spec(object):
def getFiles(self):
""" Returns %files section."""
- return self.files;
+ return self.files
def getChangelog(self):
""" Returns %changelog section."""
@@ -173,6 +175,7 @@ class Spec(object):
return self.check
# Set functions
+
def __setSpecname(self, filename):
""" Set spec file name."""
self.filename = filename
@@ -243,7 +246,7 @@ class Spec(object):
def __setFiles(self, files):
""" Set files section."""
- self.files = files;
+ self.files = files
def __setChangelog(self, changelog):
""" Set changelog section."""
@@ -284,13 +287,13 @@ class Spec(object):
# Logic to differentiate between sections.
for line in self.__spec_lines:
self.current_linenum += 1
-
+
section_marker = 0
for i in section.keys():
if section[i]["re"].search(line):
current_section = i
section_marker = 1
-
+
section[current_section]["content"].append(line)
# Set the attributes with content.
@@ -310,4 +313,3 @@ class Spec(object):
return
# Spec ends here
-
diff --git a/SpecCheck.py b/SpecCheck.py
index ba4c470..4354205 100644
--- a/SpecCheck.py
+++ b/SpecCheck.py
@@ -20,6 +20,7 @@
# Every Check file needs to inherit this class
#
+
class SpecCheck:
check_names_seen = []
checks = []
diff --git a/Srpm.py b/Srpm.py
index 85e6908..3e1a862 100644
--- a/Srpm.py
+++ b/Srpm.py
@@ -19,6 +19,7 @@
import os
import rpm
+
class Srpm:
"""Represents a source RPM"""
diff --git a/SrpmCheck.py b/SrpmCheck.py
index e328ca5..6925a00 100644
--- a/SrpmCheck.py
+++ b/SrpmCheck.py
@@ -14,6 +14,7 @@
# along with translate; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
class SrpmCheck:
""" Abstract base class for all source RPM checks"""
diff --git a/rom.py b/rom.py
index ea83c49..c6c1f4f 100755
--- a/rom.py
+++ b/rom.py
@@ -32,13 +32,13 @@ from ConfigParser import ConfigParser
cf = ConfigParser()
cf.readfp(open('/etc/rom.config'))
-username = cf.get("Details",'username')
-password = cf.get("Details",'password')
-
-
+username = cf.get("Details", 'username')
+password = cf.get("Details", 'password')
koji_getfile = "http://koji.fedoraproject.org/koji/getfile"
KOJI_URL = 'http://koji.fedoraproject.org/kojihub'
+
+
def _mock_error_code_to_log_file(err_code):
log_file = ''
if err_code == 1:
@@ -49,8 +49,9 @@ def _mock_error_code_to_log_file(err_code):
print "Unhandled error code :", err_code
return log_file
+
def get_files(**kw):
- results = {'logs':{'count':0}, 'downloads':{'count':0}}
+ results = {'logs': {'count': 0}, 'downloads': {'count': 0}}
task_id = int(kw.get('task_id', '0'))
state = int(kw.get('state', '0'))
@@ -92,7 +93,7 @@ def get_files(**kw):
def get_error_log(**kw):
- results = {'log_url':'', 'log_name':'', 'task_id':''}
+ results = {'log_url': '', 'log_name': '', 'task_id': ''}
task_id = int(kw.get('task_id', '0'))
cs = koji.ClientSession(KOJI_URL)
@@ -106,7 +107,7 @@ def get_error_log(**kw):
error_code = 0
try:
- # this should throw an error
+ # this should throw an error
child_result = cs.getTaskResult(child_task_id)
except koji.BuildrootError, e:
error = str(e)
@@ -134,14 +135,16 @@ def get_error_log(**kw):
return results
-def download(link,filepath):
+
+def download(link, filepath):
f = urllib2.urlopen(link)
print "Downloading:", link
data = f.read()
- f = open(filepath,'wb')
+ f = open(filepath, 'wb')
f.write(data)
f.close()
+
def main():
"""The main function"""
bugid = int(raw_input("Enter the bug number: "))
@@ -151,7 +154,7 @@ def main():
koji_id = None
kojilink = ""
bz = bugzilla.Bugzilla(url='https://bugzilla.redhat.com/xmlrpc.cgi')
- bz.login(username,password)
+ bz.login(username, password)
bug = bz.getbug(bugid)
for line in txts:
if line.startswith("Task info:"):
@@ -169,8 +172,8 @@ def main():
if key != "count":
links = z[key]
for link in links:
- download(link['url'],os.path.join(fd.path,link['name']))
- message = os.popen('rpmlint ' + os.path.join(fd.path,'*.rpm')
+ ' '+os.path.join(fd.path,'*.spec')).read()
+ download(link['url'], os.path.join(fd.path, link['name']))
+ message = os.popen('rpmlint ' + os.path.join(fd.path,
'*.rpm') + ' '+ os.path.join(fd.path, '*.spec')).read()
message = "Automated result from review-o-matic\n\n" + kojilink
+"\n\n" + message
print message
bug.addcomment(message)
@@ -179,5 +182,3 @@ def main():
if __name__ == '__main__':
main()
-
-
15 years, 4 months
[review-o-matic] [PATCH] RomFeeder and RomGenericFeeder
by Debarshi Ray
Here [1] is a patch to implement the RomFeeder adn RomGenericFeeder
classes. Pretty basic stuff and zero error handling at the moment, but
I guess that is fine for the time being.
>From 56ca501ccd6e3b3fc13c65d1e21e684c0d5b6521 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <rishi(a)fedoraproject.org>
Date: Fri, 19 Dec 2008 14:48:32 +0530
Subject: [PATCH] * RomFeeder.py, RomGenericFeeder.py: New files.
---
RomFeeder.py | 32 +++++++++++++++++++++++++++++++
RomGenericFeeder.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 84 insertions(+), 0 deletions(-)
diff --git a/RomFeeder.py b/RomFeeder.py
new file mode 100644
index 0000000..beb7b5e
--- /dev/null
+++ b/RomFeeder.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Debarshi Ray <rishi(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
+
+class RomFeeder:
+ """
+ Abstract feeder interface to be implemented by derived classes.
+ """
+
+ def __init__(self):
+ pass
+
+ def feed(self, item, dest):
+ """
+ item: Review request bug number or Spec/SRPM URI.
+ dest: Path to a destination directory.
+ """
+ raise NotImplementedError()
diff --git a/RomGenericFeeder.py b/RomGenericFeeder.py
new file mode 100644
index 0000000..cc45678
--- /dev/null
+++ b/RomGenericFeeder.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Debarshi Ray <rishi(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 urllib2
+import RomFeeder
+
+class RomGenericFeeder(RomFeeder.RomFeeder):
+ """
+ Implements a generic URI (eg., file://, ftp://, http://, etc.) feeder.
+ """
+
+ def __init__(self, bs=4096):
+ """
+ bs: Read bs bytes at a time. Default is 4096.
+ """
+ RomFeeder.RomFeeder.__init__(self)
+ self.bs = bs
+
+ def feed(self, item, dest):
+ """
+ item: Spec/SRPM URI.
+ dest: Path to a destination directory.
+ """
+ uri = urllib2.urlopen(item)
+ file_path = dest + "/" + os.path.basename(item)
+ file = open(file_path, "wb")
+
+ buf = ""
+ buf = uri.read(self.bs)
+ while buf:
+ file.write(buf)
+ buf = uri.read(self.bs)
+
+ file.close()
+ uri.close()
+ return file_path
--
1.4.0
Comments?
Happy hacking,
Debarshi
----
[1] http://rishi.fedorapeople.org/0001-RomFeeder.py-RomGenericFeeder.py-New-f...
15 years, 4 months
[review-o-matic] [PATCH] RomBuilder and RomKojiBuilder
by Debarshi Ray
Here is a patch [1] to implement the RomBuilder and RomKojiBuilder
classes. I have deliberately not implemented the retrieve method since
I would need to think a bit about how we would like it to behave. This
will obsolete some of the code in rom.py which does not use the Koji
API to start builds but instead invokes /usr/bin/koji.
>From 75c613746b78aff6dd0bdc5f08841b1b191ce085 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <rishi(a)fedoraproject.org>
Date: Tue, 16 Dec 2008 03:40:51 +0530
Subject: [PATCH] * RomBuilder.py, RomKojiBuilder.py: New files.
---
RomBuilder.py | 29 +++++++++++++++++++++++
RomKojiBuilder.py | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 96 insertions(+), 0 deletions(-)
create mode 100644 RomBuilder.py
create mode 100644 RomKojiBuilder.py
diff --git a/RomBuilder.py b/RomBuilder.py
new file mode 100644
index 0000000..b5e09c9
--- /dev/null
+++ b/RomBuilder.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Debarshi Ray <rishi(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
+
+class RomBuilder:
+ """Abstract builder interface to be implemented by derived classes."""
+
+ def __init__(self):
+ pass
+
+ def build(self):
+ raise NotImplementedError()
+
+ def retrieve(self):
+ raise NotImplementedError()
diff --git a/RomKojiBuilder.py b/RomKojiBuilder.py
new file mode 100644
index 0000000..2651427
--- /dev/null
+++ b/RomKojiBuilder.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Debarshi Ray <rishi(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 koji
+import os
+import random
+import string
+import time
+import RomBuilder
+
+def _unique_path(prefix):
+ """Taken from the Koji client: /usr/bin/koji"""
+ return '%s/%r.%s' % (prefix, time.time(),
+ ''.join([random.choice(string.ascii_letters)
for i in range(8)]))
+
+
+class RomKojiBuilder(RomBuilder.RomBuilder):
+ """Implements a Koji builder."""
+
+ def __init__(self,
koji_server="http://koji.fedoraproject.org/kojihub",
ssl_cert="~/.fedora.cert", ssl_ca="~/.fedora-upload-ca.cert",
ssl_serverca="~/.fedora-server-ca.cert"):
+ RomBuilder.RomBuilder.__init__(self)
+ self.kojiServer = koji_server
+ self.sslCert = os.path.expanduser(ssl_cert)
+ self.sslCa = os.path.expanduser(ssl_ca)
+ self.sslServerCa = os.path.expanduser(ssl_serverca)
+
+ def build(self, source, target):
+ 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)
+ 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, dir="/tmp"):
+ raise NotImplementedError()
--
1.5.6.5
Comments?
Happy hacking,
Debarshi
[1] http://rishi.fedorapeople.org/0001--RomBuilder.py-RomKojiBuilder.py-New-f...
15 years, 4 months
[review-o-matic] [Fwd: Work needed, how you can help!]
by sankarshan
Can't review-o-matic handle this via some kind of extension/plug-in ?
~sankarshan
-------- Original Message --------
Subject: Work needed, how you can help!
Date: Sun, 07 Dec 2008 13:22:46 -0800
From: Jesse Keating <jkeating(a)redhat.com>
Reply-To: Development discussions related to Fedora
<fedora-devel-list(a)redhat.com>
Organization: Red Hat
To: fedora-devel-list(a)redhat.com
rpm recently began auto-discovering requirements based on contents of
pkg-config files (.pc). This is awesome stuff, and will help developers
out a lot. However because of this, non-devel packages are suddenly
requiring pkg-config deps, and pkgconfig itself.
This is due to packages having their .pc file in the base package rather
than a -devel subpackage. There is a review guideline for this ( tail
end of http://fedoraproject.org/wiki/Packaging/ReviewGuidelines ) but I
couldn't find the matching Guideline entry so it's not surprising that
this could have been missed.
The work needed is for somebody to examine all the packages in rawhide
that provide .pc files and ensure proper placement of them based on the
review guideline. This will likely require interaction with the
packages maintainer(s) so the first step should probably be to produce a
list of packages that ship .pc in a non -devel package and send the list
(sorted by maintainer) to here so that we can discuss and pick off
items.
Thanks!
--
Jesse Keating
Fedora -- Freedom² is a feature!
identi.ca: http://identi.ca/jkeating
--
http://www.gutenberg.net - Fine literature digitally re-published
http://www.plos.org - Public Library of Science
http://www.creativecommons.org - Flexible copyright for creative work
--
fedora-devel-list mailing list
fedora-devel-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/fedora-devel-list
15 years, 4 months
[review-o-matic] TODO list
by Orcan Ogetbil
Hi folks,
>From the template I use for my reviews I prepared this TODO list for the implementation of all the checks that need to be implemented on r-o-m:
http://oget.fedorapeople.org/r-o-m/review-o-matic
The list is pretty much complete. I think it covers almost all of the guidelines, still there might be a few things that we can add.
The boxes on the left hand side of any check indicate which of the following files is needed to do that check: SPEC, SRPM, RPMs, buildlog. I tried to be accurate by putting those x's but there might be minor flaws. Feel free to correct me.
I think this would be a good starting point. Note that the implementation of certain guidelines is very hard. Examples:
- The SPEC file must be written in American English
- If there is a -devel package, check for the header files inside the package to figure out "Requires:" for the -devel package.
- If applicable, package must obey the specific Guidelines (python, java etc)
I think what we should do is to create minimal check files for all the items in this list. Whenever the script runs, the minimal check file should tell the reviewer what needs to be checked manually. In time, whenever we implement some of these checks, we will replace those directives with the proper ones.
Does everybody agree? If yes, I will write the minimal check files rightaway.
-Orcan
15 years, 4 months
[review-o-matic] regarding check table & timeline
by Rakesh Pandit
https://fedorahosted.org/review-o-matic/wiki/Check_Table
Table is complete with oget's list for now. We can add to it more
guidelines. But, I suggest lets get this list analysed and finished
first. Moreover as soon as kushal updates his document we can start
discussion on other front i.e about whole structure design and
workflow. If we speed up a bit I can also come up with time line
suggestions and milestones.
Deleting or marking already implemented guidelines is okay.
--
rakesh
15 years, 4 months