[review-o-matic] Few testing lines for Reporter block
by Rakesh Pandit
Hello,
The patches for "Reporter" block are very basic. The criteria
initially is to get work for "Application" block started. I am on my
way to writing "Reviewer" now.
I did some testing and sessions are:
For testing RomBugzillaReporter:
>>> from RomBugzillaReporter import RomBugzillaReporter
>>> a = RomBugzillaReporter(475032)
>>> a.printInfo("Testing")
>>> a.reportBugzilla()
Checked Bug 475032
For testing RomReporter interface for report generation:
>>> from RomReporter import RomReporter
>>> rp = RomReporter()
>>> from Spec import Spec
>>> spec_obj = Spec("dnrd.spec")
>>> rp.getReport()
''
>>> rp.printInfo("Testing1", spec=spec_obj)
>>> rp.getReport()
'dnrd.spec:77: I: Testing1 spec\n'
>>> print rp.getReport()
dnrd.spec:77: I: Testing1 spec
>>> rp.printMust("Testing2", spec=spec_obj)
>>> print rp.getReport()
dnrd.spec:77: I: Testing1 spec
dnrd.spec:77: M: Testing2 spec
>>> rp.printShould("Testing3", spec=spec_obj)
>>> print rp.getReport()
dnrd.spec:77: I: Testing1 spec
dnrd.spec:77: M: Testing2 spec
dnrd.spec:77: S: Testing3 spec
>>> rp.printError("Testing3", spec=spec_obj)
>>> print rp.getReport()
dnrd.spec:77: I: Testing1 spec
dnrd.spec:77: M: Testing2 spec
dnrd.spec:77: S: Testing3 spec
dnrd.spec:77: E: Testing3 spec
>>> rp.printWarning("Testing3", spec=spec_obj)
>>> print rp.getReport()
dnrd.spec:77: I: Testing1 spec
dnrd.spec:77: M: Testing2 spec
dnrd.spec:77: S: Testing3 spec
dnrd.spec:77: E: Testing3 spec
dnrd.spec:77: W: Testing3 spec
Line number 77 because calls are being made after all parsing has been
done. But while running checks, current line number will be shown
depending upon where message got generated. There are some loose ends
still, but will tie them later. Some I know and some will become clear
as and when we move ahead.
For testing RomFileReporter:
>>> from RomFileReporter import RomFileReporter
>>> rp=RomFileReporter("report.txt")
>>> from Spec import Spec
>>> spec_obj = Spec("dnrd.spec")
>>> rp.printInfo("Hello testing1", spec=spec_obj)
>>> rp.getReport()
'dnrd.spec:77: I: Hello testing1 spec\n'
>>> print rp.getReport()
dnrd.spec:77: I: Hello testing1 spec
>>> rp.printMust("Hello testing1", spec=spec_obj)
>>> print rp.getReport()
dnrd.spec:77: I: Hello testing1 spec
dnrd.spec:77: M: Hello testing1 spec
>>> rp.reportFile()
>>>
[rpandit@rocky review-o-matic]$ cat report.txt
dnrd.spec:77: I: Hello testing1 spec
dnrd.spec:77: M: Hello testing1 spec
[rpandit@rocky review-o-matic]$
Hope it helps for review.
--
Cheers,
rakesh
15 years, 3 months
[review-o-matic] [PATCH] Some more clean up - prework for Reviewer
by Rakesh Pandit
Hello
Need +1
http://rakesh.fedorapeople.org/misc/0001--Spec.py-Spec.getFileName-Spec._...
--
rakesh
>From 3005a02ec5c2ed9d75be8fbe54865749e77efbaf Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 18:33:51 +0530
Subject: [PATCH] * Spec.py (Spec.getFileName, Spec.__setFileName,
Spec.getSpecname,
Spec.__setSpecname, RomReporter.__print): Renamed Spec.getSpecname
to Spec.getFileName and Spec.__setSpecname to Spec.__setFileName.
And corresponding changes at different places.
* Spec.py, SpecCheck.py: Clean up, writing missing docs.
* RomReporter.py (RomReporter.printRpmLintMessages): Add new
method.
* Spec.py (Spec.path, Spec.file, Spec.__readSpecLines,
Spec.__getFilePath): New attributes and corresponding changes in
__readSpecLines method. Added __getFilePath to Spec class.
* Spec.py (SpecCheck.spec_check_names_seen, SpecCheck.spec_checks):
Renamed checks tp spec_checks and check_names_seen to
spec_check_names_seen.
---
RomReporter.py | 9 +++++++-
Spec.py | 57 +++++++++++++++++++++++++++++++------------------------
SpecCheck.py | 33 +++++++++++++++++++------------
3 files changed, 60 insertions(+), 39 deletions(-)
diff --git a/RomReporter.py b/RomReporter.py
index 28ebd82..37dc665 100644
--- a/RomReporter.py
+++ b/RomReporter.py
@@ -57,7 +57,7 @@ class RomReporter(object):
if 'spec' in details.keys():
spec = details['spec']
- self.report += "%s:%s %s: %s" % (spec.getSpecname(),
line_num, type, reason)
+ self.report += "%s:%s %s: %s" % (spec.getFileName(),
line_num, type, reason)
else:
self.report += "%s: %s" % (type, reason)
@@ -107,4 +107,11 @@ class RomReporter(object):
self.__print("W", reason, details)
+ def printRpmLintMessages(self, messages):
+ """
+ Adds rpmlint output to report.
+ """
+ self.report += "\n" + "Rpmlint Messages:" + "\n" + messages + "\n"
+
+
# Abstract reporter interface ends here
diff --git a/Spec.py b/Spec.py
index 3943999..47e5a8f 100644
--- a/Spec.py
+++ b/Spec.py
@@ -17,36 +17,39 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import re
+import os
import string
class Spec(object):
"""Spec file class """
- def __init__(self, filename):
+ def __init__(self, file):
""" """
- self.filename=filename
- self.current_linenum=None
- self.description=[]
- self.prep=[]
- self.build=[]
- self.install=[]
- self.clean=[]
- self.files=[]
- self.changelog=[]
- self.package=[]
- self.check=[]
- self.name=[]
- self.version=[]
- self.release=[]
- self.summary=[]
- self.group=[]
- self.license=[]
- self.url=[]
- self.source=[]
- self.buildroot=[]
- self.requires=[]
- self.buildrequires=[]
+ self.file = file
+ self.filename = os.path.basename(file)
+ self.path = os.path.dirname(file)
+ self.current_linenum = None
+ self.description = []
+ self.prep = []
+ self.build = []
+ self.install = []
+ self.clean = []
+ self.files = []
+ self.changelog = []
+ self.package = []
+ self.check = []
+ self.name = []
+ self.version = []
+ self.release = []
+ self.summary = []
+ self.group = []
+ self.license = []
+ self.url = []
+ self.source = []
+ self.buildroot = []
+ self.requires = []
+ self.buildrequires = []
self.__sections = ["description", "prep", "build", "install", "clean",
"files", "changelog", "package", "check"]
@@ -78,7 +81,7 @@ class Spec(object):
def __readSpecLines(self):
""" Reads spec lines."""
- fobj = open(self.filename, "r")
+ fobj = open(self.file, "r")
try:
self.__spec_lines = fobj.readlines()
finally:
@@ -86,10 +89,14 @@ class Spec(object):
# Get functions
- def getSpecname(self):
+ def getFileName(self):
""" Returns spec file name."""
return self.filename
+ def getSpecPath(self):
+ """ Returns spec file path."""
+ return self.path
+
def getLineNum(self):
""" Returns spec file line number where parser is right now."""
return self.current_linenum
diff --git a/SpecCheck.py b/SpecCheck.py
index 458c978..57fba2e 100644
--- a/SpecCheck.py
+++ b/SpecCheck.py
@@ -1,3 +1,4 @@
+#!/usr/bin/env python
#
# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
#
@@ -17,26 +18,32 @@
#
-# Every Check file needs to inherit this class
+# Every spec check file needs to inherit this class.
#
+import Check
-class SpecCheck:
- check_names_seen = []
- checks = []
+
+class SpecCheck(Check.Check):
+ """
+ Base class for all spec checks.
+ """
+ spec_check_names_seen = []
+ spec_checks = []
def __init__(self, name):
"""
"""
- if name not in SpecCheck.check_names_seen:
- SpecCheck.checks.append(self)
- SpecCheck.check_names_seen.append(name)
+ if name not in SpecCheck.spec_check_names_seen:
+ SpecCheck.spec_checks.append(self)
+ SpecCheck.spec_check_names_seen.append(name)
self.name = name
- def check(self, pkg):
- """
- Implemented by derived classes.
- """
- raise NotImplementedError('check must be implemented in subclass')
+ def check(self, spec):
+ """
+ Implemented by derived classes.
+ """
+ raise NotImplementedError('check must be implemented in subclass')
+
-# SpecCheck ends here
+# SpecCheck ends here.
--
1.6.0.6
15 years, 3 months
[review-o-matic] [PATCH] Reviewer
by Rakesh Pandit
Hello,
Following is reviewer part, it is not in a usable format because
Rpm.py and Srpm.py modules with Rpm and Srpm classes respectively are
not implemented yet and I will be writing them next. Moreover, the
only check we have needs some work to adjust to latest changes.
I have introduced three more Check classes, one is Check and other two
are SrcRPMCheck and RPMCheck. The fundamental behind this is they
conceptually categorize the spec checks, rpm checks, srpm checks and
hybrid checks. Hybrid checks are those checks where one needs two or
all three types of objects (spec, srpm or rpm). And thus saves lots of
hard code logic for "implement this categorization " and "implement
the number of objects (spec, srpm or rpms)" on needs to keep count on
while doing the running all the guidelines.
runRpmlint is right now a separate method in RomReviewer module. It
calls printRpmLintMessages from Reporter.
I would like to get this up so as Application Block work gets started.
In the meantime I will finish Srpm.py and Rpm.py and fix the
BuildRootCheck (only) test we have and get this Reviewer code working.
The patch files are:
[1] http://rakesh.fedorapeople.org/misc/0001--Check.py-New-file.patch
[2] http://rakesh.fedorapeople.org/misc/0002--SrcRPMCheck.py-New-file.patch
[3] http://rakesh.fedorapeople.org/misc/0003--RPMCheck.py-New-file.patch
[4] http://rakesh.fedorapeople.org/misc/0004--RomReviewer.py-New-file.patch
[5] http://rakesh.fedorapeople.org/misc/0005--RomSrcRPMReviewer.py-New-file.p...
[6] http://rakesh.fedorapeople.org/misc/0006--RomSpecReviewer.py-New-file.patch
[7] http://rakesh.fedorapeople.org/misc/0007--RomRPMReviewer.py-New-file.patch
--
rakesh
>From 1a3671b96227e7041aa9716b4e406a3c3fb77472 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:25:50 +0530
Subject: [PATCH] * Check.py: New file.
---
Check.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
create mode 100644 Check.py
diff --git a/Check.py b/Check.py
new file mode 100644
index 0000000..b97006e
--- /dev/null
+++ b/Check.py
@@ -0,0 +1,53 @@
+#!/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
+
+
+#
+# Every hybrid check file needs to inherit from this class
+#
+
+
+class Check(object):
+ """
+ Base class for all checks.
+ """
+ check_names_seen = []
+ checks = []
+
+ def __init__(self, name):
+ """
+ """
+ if name not in SpecCheck.check_names_seen:
+ SpecCheck.checks.append(self)
+ SpecCheck.check_names_seen.append(name)
+ self.name = name
+
+ def check(self, **details):
+ """
+ This one is for hybrid checks. Where we may need combination of
+ spec, srpm, rpm.
+
+ details: dictionary where one or more of spec, srpm, rpm can object
+ can be passed.
+
+ Will be implemented by derived classes.
+ """
+ raise NotImplementedError()
+
+
+# Check ends here.
--
1.6.0.6
>From 8ed449d966e374d6f6136c44f8fca99876ca5488 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:26:51 +0530
Subject: [PATCH] * SrcRPMCheck.py: New file.
---
SrcRPMCheck.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
create mode 100644 SrcRPMCheck.py
diff --git a/SrcRPMCheck.py b/SrcRPMCheck.py
new file mode 100644
index 0000000..691df8d
--- /dev/null
+++ b/SrcRPMCheck.py
@@ -0,0 +1,49 @@
+#!/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
+
+
+#
+# Every srpm check file needs to inherit this class.
+#
+
+import Check
+
+
+class SrcRPMCheck(Check.Check):
+ """
+ Base class for all srpm checks.
+ """
+ srpm_check_names_seen = []
+ srpm_checks = []
+
+ def __init__(self, name):
+ """
+ """
+ if name not in SrcRPMCheck.srpm_check_names_seen:
+ SrcRPMCheck.srpm_checks.append(self)
+ SrcRPMCheck.srpm_check_names_seen.append(name)
+ self.name = name
+
+ def check(self, srpm):
+ """
+ Implemented by derived classes.
+ """
+ raise NotImplementedError('check must be implemented in subclass')
+
+
+# SrcRPMCheck ends here.
--
1.6.0.6
>From f936f07c3241d0f56f089c18e32d72c55773c5ee Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:27:13 +0530
Subject: [PATCH] * RPMCheck.py: New file.
---
RPMCheck.py | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
create mode 100644 RPMCheck.py
diff --git a/RPMCheck.py b/RPMCheck.py
new file mode 100644
index 0000000..eb6ca6a
--- /dev/null
+++ b/RPMCheck.py
@@ -0,0 +1,49 @@
+#!/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
+
+
+#
+# Every rpm check file needs to inherit this class.
+#
+
+import Check
+
+
+class RPMCheck(Check.Check):
+ """
+ Base class for all rpm checks.
+ """
+ rpm_check_names_seen = []
+ rpm_checks = []
+
+ def __init__(self, name):
+ """
+ """
+ if name not in RPMCheck.rpm_check_names_seen:
+ RPMCheck.rpm_checks.append(self)
+ RPMCheck.rpm_check_names_seen.append(name)
+ self.name = name
+
+ def check(self, rpm):
+ """
+ Implemented by derived classes.
+ """
+ raise NotImplementedError('check must be implemented in subclass')
+
+
+# RPMCheck ends here.
--
1.6.0.6
>From 1e8a8b0f4cbb790fe82809cb7b45c1a0419a6b0e Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:27:55 +0530
Subject: [PATCH] * RomReviewer.py: New file.
---
RomReviewer.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 85 insertions(+), 0 deletions(-)
create mode 100644 RomReviewer.py
diff --git a/RomReviewer.py b/RomReviewer.py
new file mode 100644
index 0000000..f379e7e
--- /dev/null
+++ b/RomReviewer.py
@@ -0,0 +1,85 @@
+#!/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 sys
+import imp
+
+import Check
+
+
+def runRpmlint(self, reporter, *details):
+ """
+ Returns rpmlint messages on spec, srpm, rpm.
+ """
+ # Add -i once we implement config feature and have command
+ # line arguments, so that we can check verbose parameter.
+ rpmlint_args = ""
+ for items in details:
+ rpmlint_args += os.path.join(items.getFilePath(), \
+ items.getFileName()) + " "
+
+ rpmlint_message = os.popen("rpmlint " + rpmlint_args).read()
+
+ # Assuming same object is used for other reporting also.
+ reporter.printRpmLintMessages(rpmlint_message)
+ return
+
+
+class RomReviewer(object):
+ """
+ Reviewer interface. Part of functionality to be implemented by
+ derived class.
+ """
+
+ def __init__(self):
+ """
+ """
+ # Need to update it for each guideline.
+ self.default_guidelines = ("SampleCheck")
+
+ # Load all checks.
+ self.__loadChecks()
+
+ def __loadChecks(self):
+ """
+ Implements the loading module.
+ """
+ for name in self.default_guidelines:
+ try:
+ # Later on we need to generalize the second parameter
+ # depending on where guideline files go after installation.
+ (file, path, description) = imp.find_module(name, ".")
+ except ImportError:
+ print "Guideline import error: ", name
+ sys.exit(1)
+ imp.load_module(name, file, path, description)
+
+ def review(self, **details):
+ """
+ Implements the general checks which may use spec, rpm, srpm.
+
+ details: Dictionary has any number of Spec or Srpm or Rpm
+ obects.
+ """
+ for guide in Check.Check.checks:
+ guide.check(details)
+ return
+
+
+# RomReviewer ends here
--
1.6.0.6
>From 954d2371e153f0794a9b6ed8e1bf44f562155ada Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:28:13 +0530
Subject: [PATCH] * RomSrcRPMReviewer.py: New file.
---
RomSrcRPMReviewer.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100644 RomSrcRPMReviewer.py
diff --git a/RomSrcRPMReviewer.py b/RomSrcRPMReviewer.py
new file mode 100644
index 0000000..1c00cba
--- /dev/null
+++ b/RomSrcRPMReviewer.py
@@ -0,0 +1,42 @@
+#!/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 RomReviewer
+import SrcRPMCheck
+
+
+class RomSrcRPMReviewer(RomReviewer.RomReviewer):
+ """
+ Implements Srource RPM reviewer.
+ """
+
+ def __init__(self):
+ """
+ """
+ pass
+
+ def review(self, srpm):
+ """
+ Implements reviewer for srpm.
+ """
+ for guide in SrcRPMCheck.SrcRPMCheck.checks:
+ guide.check(srpm)
+ return
+
+
+# RomSrcRPMReviewer ends here
--
1.6.0.6
>From cbdb0a7c602b02a6240b4852ee07fab459e49832 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:28:41 +0530
Subject: [PATCH] * RomSpecReviewer.py: New file.
---
RomSpecReviewer.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100644 RomSpecReviewer.py
diff --git a/RomSpecReviewer.py b/RomSpecReviewer.py
new file mode 100644
index 0000000..861de79
--- /dev/null
+++ b/RomSpecReviewer.py
@@ -0,0 +1,42 @@
+#!/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 RomReviewer
+import SpecCheck
+
+
+class RomSpecReviewer(RomReviewer.RomReviewer):
+ """
+ Implements spec reviewer.
+ """
+
+ def __init__(self):
+ """
+ """
+ pass
+
+ def review(self, spec):
+ """
+ Implements spec review.
+ """
+ for guide in SpecCheck.SpecCheck.checks:
+ guide.check(spec)
+ return
+
+
+# RomSpecReviewer ends here
--
1.6.0.6
>From 1df9e39b11b95d65143b926e0d8bd8eee34649a9 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 23:28:56 +0530
Subject: [PATCH] * RomRPMReviewer.py: New file.
---
RomRPMReviewer.py | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
create mode 100644 RomRPMReviewer.py
diff --git a/RomRPMReviewer.py b/RomRPMReviewer.py
new file mode 100644
index 0000000..bc096e4
--- /dev/null
+++ b/RomRPMReviewer.py
@@ -0,0 +1,42 @@
+#!/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 Reviewer
+import RPMCheck
+
+
+class RomRPMReviewer(RomReviewer.RomReviewer):
+ """
+ Implements RPM reviewer.
+ """
+
+ def __init__(self):
+ """
+ """
+ pass
+
+ def review(self, rpm):
+ """
+ Implements reviewer for rpm.
+ """
+ for guide in SrcRPMCheck.SrcRPMCheck.checks:
+ guide.check(rpm)
+ return
+
+
+# RomRPMReviewer ends here
--
1.6.0.6
15 years, 3 months
[review-o-matic] [PATCH] SOme more clean up - Committed
by Rakesh Pandit
>From c620853227a4a3925de6db4edb7a6abae7076f02 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Thu, 25 Dec 2008 14:51:52 +0530
Subject: [PATCH] * BuildRootCheck.py (__init__): Cleaned incorrect docs.
* SpecCheck.py (__init__, check): Wrote docs.
---
BuildRootCheck.py | 4 ++--
SpecCheck.py | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/BuildRootCheck.py b/BuildRootCheck.py
index 71be1cd..e63a95e 100644
--- a/BuildRootCheck.py
+++ b/BuildRootCheck.py
@@ -39,7 +39,7 @@ class BuildRootCheck(SpecCheck.SpecCheck):
"""Check the buildroot tag of the spec file to see if it matches
the guidelines."""
def __init__(self):
- """Sample constructor"""
+ """ """
SpecCheck.SpecCheck.__init__(self, "BuildRootCheck")
def check(self, spec):
@@ -96,4 +96,4 @@ It needs to be one of these three:\n
%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%{_tmppath}/%{name}-%{version}-%{release}-root''')
-# SpecCheck ends here
+# BuildRootCheck ends here
diff --git a/SpecCheck.py b/SpecCheck.py
index 4354205..458c978 100644
--- a/SpecCheck.py
+++ b/SpecCheck.py
@@ -26,12 +26,17 @@ class SpecCheck:
checks = []
def __init__(self, name):
+ """
+ """
if name not in SpecCheck.check_names_seen:
SpecCheck.checks.append(self)
SpecCheck.check_names_seen.append(name)
self.name = name
def check(self, pkg):
+ """
+ Implemented by derived classes.
+ """
raise NotImplementedError('check must be implemented in subclass')
# SpecCheck ends here
--
1.6.0.6
--
rakesh
15 years, 3 months
[review-o-matic] [PATCH] RomFileReporter
by Rakesh Pandit
Link: http://rakesh.fedorapeople.org/misc/0003--RomFileReporter.py-New-file.patch
--
rakesh
>From 8c1596fabd358370bb56fd78f15067efc383364c Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Tue, 23 Dec 2008 21:41:26 +0530
Subject: [PATCH] * RomFileReporter.py: New file
---
RomFileReporter.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
create mode 100644 RomFileReporter.py
diff --git a/RomFileReporter.py b/RomFileReporter.py
new file mode 100644
index 0000000..207fe2a
--- /dev/null
+++ b/RomFileReporter.py
@@ -0,0 +1,69 @@
+#!/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 RomReporter
+
+
+class FileBaseException(Exception):
+ """
+ RomFileReporter base class exception.
+ """
+ pass
+
+
+class FileOpenException(FileBaseException):
+ """
+ File exception for open failure.
+ """
+ pass
+
+
+class RomFileReporter(RomReporter.RomReporter):
+ """
+ Implements a Bugzilla Reporter.
+ """
+
+ def __init__(self, file):
+ """
+ file: were report will go
+ """
+ RomReporter.RomReporter.__init__(self)
+
+ self.fp = None
+ try:
+ self.fp = open(file, "w")
+ except IOError, e:
+ raise FileOpenException(e)
+
+ def __del__(self):
+ """
+ Close the open file object.
+ """
+ self.fp.close()
+
+ def reportFile(self):
+ """
+ Report to file.
+ """
+ self.fp.write(self.report)
+ return
+
+
+# RomFileReporter ends here
--
1.6.0.6
Comments ?
15 years, 4 months
[review-o-matic] [PATCH] RomBugzillaReporter
by Rakesh Pandit
Link: http://rakesh.fedorapeople.org/misc/0002--RomBugzillaReporter.py-New-file...
--
rakesh
>From 68eb4bf100f023a0b845bb63c1a950a0f3f81e16 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Tue, 23 Dec 2008 21:41:00 +0530
Subject: [PATCH] * RomBugzillaReporter.py: New file.
---
RomBugzillaReporter.py | 108 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 108 insertions(+), 0 deletions(-)
create mode 100644 RomBugzillaReporter.py
diff --git a/RomBugzillaReporter.py b/RomBugzillaReporter.py
new file mode 100644
index 0000000..087f26c
--- /dev/null
+++ b/RomBugzillaReporter.py
@@ -0,0 +1,108 @@
+#!/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
+
+from bugzilla import Bugzilla
+from ConfigParser import ConfigParser
+
+import RomReporter
+
+
+class BugzillaBaseException(Exception):
+ """
+ RomBugzillaReporter base class exception.
+ """
+ pass
+
+
+class BugzillaLoginException(BugzillaBaseException):
+ """
+ Bugzilla exception for login failure.
+ """
+
+ def __str__(self):
+ """
+ """
+ return "Login failure. Check authentication credentials in
rom.config."
+
+
+class BugzillaConfigfileException(BugzillaBaseException):
+ """
+ Bugzilla exception for config file absense.
+ """
+
+ def __str__(self):
+ """
+ """
+ return "Config file rom.config not found."
+
+
+class RomBugzillaReporter(RomReporter.RomReporter):
+ """
+ Implements a Bugzilla Reporter.
+ """
+
+ def __init__(self, bug_num):
+ """
+ bugNum: Bugzilla Id
+ """
+ RomReporter.RomReporter.__init__(self)
+ self.bugzilla_url = 'https://bugzilla.redhat.com/xmlrpc.cgi'
+
+ self.bugNum = bug_num
+ self.bugzilla = Bugzilla(url=self.bugzilla_url)
+ self._login()
+ return
+
+ def _login(self):
+ """
+ Login to Bugzilla using credentials on rom.config file.
+ """
+ file_object = None
+ file_name = "rom.config"
+ config_parser = ConfigParser()
+
+ try:
+ if os.path.exists(file_name):
+ file_object = open(file_name)
+ elif os.path.exists("/etc/" + file_name):
+ file_object = open("/etc/" + file_name)
+ else:
+ raise BugzillaConfigfileException
+ except IOError:
+ raise BugzillaConfigfileException
+
+ config_parser.readfp(file_object)
+ username = config_parser.get("Details", "username")
+ password = config_parser.get("Details", "password")
+
+ islogin = self.bugzilla.login(username, password)
+ if not islogin:
+ raise BugzillaLoginException
+ return
+
+ def reportBugzilla(self):
+ """
+ Report to Bugzilla.
+ """
+ bug = self.bugzilla.getbug(self.bugNum)
+ bug.addcomment(self.report)
+ return
+
+# RomBugzillaReporter ends here
--
1.6.0.6
Comments ?
15 years, 4 months
[review-o-matic] [PATCH] RomReporter base class
by Rakesh Pandit
Link: http://rakesh.fedorapeople.org/misc/0001--RomReporter.py-New-file.patch
--
rakesh
>From 6c4836def543c13774fb29b0974262d474280332 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Tue, 23 Dec 2008 21:40:21 +0530
Subject: [PATCH] * RomReporter.py: New file.
---
RomReporter.py | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 112 insertions(+), 0 deletions(-)
create mode 100644 RomReporter.py
diff --git a/RomReporter.py b/RomReporter.py
new file mode 100644
index 0000000..f9dfb31
--- /dev/null
+++ b/RomReporter.py
@@ -0,0 +1,112 @@
+#!/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
+
+
+class RomReporter(object):
+ """
+ Reporter interface. Part of functionality to be implemented by
+ derived classes.
+ """
+
+ def __new__(cls, *args, **kwargs):
+ """
+ Make reporter singleton class.
+ """
+ if '_one_inst' not in vars(cls):
+ cls._one_inst = object.__new__(cls, *args, **kwargs)
+ return cls._one_inst
+
+ def __init__(self):
+ """
+ """
+ self.report = ""
+
+ def getReport(self):
+ """
+ Return report.
+ """
+ return self.report
+
+ def __print(self, type, reason, details):
+ """
+ type: Type of message e.g, M, S, E, W etc
+ spec: Spec object
+ reason: Main message
+ details: dictionary for other arguments if any
+ """
+ line_num = None
+
+ if 'spec' in details.keys():
+ spec = details['spec']
+ if spec.getLineNum() is not None:
+ line_num = "%s:" % spec.getLineNum()
+
+ if 'spec' in details.keys():
+ spec = details['spec']
+ self.report += "%s:%s %s: %s" % (spec.getSpecname(),
line_num, type, reason)
+ else:
+ self.report += "%s: %s" % (type, reason)
+
+ for d in details:
+ self.report += " %s" %d
+
+ self.report +="\n"
+
+ def printInfo(self, reason, **details):
+ """
+ spec: Spec object
+ reason: message
+ details: additional messages
+ """
+ # I => Info
+ self.__print("I", reason, details)
+
+
+ def printMust(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # M => Must
+ self.__print("M", reason, details)
+
+
+ def printShould(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # S => Should
+ self.__print("S", reason, details)
+
+
+ def printError(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # E => Error
+ self.__print("E", reason, details)
+
+
+ def printWarning(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # W => Warning
+ self.__print("W", reason, details)
+
+
+# Abstract reporter interface ends here
--
1.6.0.6
Comments ?
15 years, 4 months
[review-o-matic] [PATCH] minor fix in Spec.py
by Rakesh Pandit
Minor fix.
Committed.
--
rakesh
commit 0b0756b861ed7d806f3c9a4e2cd08a2d46824ca4
Author: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Tue Dec 23 16:21:22 2008 +0530
* Spec.py (__init__): Changed initial value for self.current_linenum,
corrected __populateSpecSections spelling.
diff --git a/Spec.py b/Spec.py
index 3ef98f0..3943999 100644
--- a/Spec.py
+++ b/Spec.py
@@ -26,7 +26,7 @@ class Spec(object):
def __init__(self, filename):
""" """
self.filename=filename
- self.current_linenum=0
+ self.current_linenum=None
self.description=[]
self.prep=[]
self.build=[]
@@ -54,7 +54,7 @@ class Spec(object):
"license", "url", "source",
"buildroot", "requires", "buildrequires"]
self.__spec_lines = []
self.__readSpecLines()
- self.__popluateSpecSections()
+ self.__populateSpecSections()
def __getitem__(self, key):
""" Operator overloading - read"""
@@ -262,6 +262,7 @@ class Spec(object):
def __populateSpecSections(self):
""" Populates all section varaibles."""
+ self.current_linenum = 0
files_has_defattr = 0
section = {}
15 years, 4 months