[csw-devel] SF.net SVN: gar:[12522] csw/mgar/gar/v2-uwatch2/bin/uwatch
Maciej (Matchek) Blizinski
maciej at opencsw.org
Fri Jan 14 09:44:01 CET 2011
No dia 13 de Janeiro de 2011 00:27, <wbonnet at users.sourceforge.net> escreveu:
> Revision: 12522
> http://gar.svn.sourceforge.net/gar/?rev=12522&view=rev
> Author: wbonnet
> Date: 2011-01-13 00:27:01 +0000 (Thu, 13 Jan 2011)
>
> Log Message:
> -----------
> Mysql code started. Not yet functionnal
>
> Modified Paths:
> --------------
> csw/mgar/gar/v2-uwatch2/bin/uwatch
>
> Modified: csw/mgar/gar/v2-uwatch2/bin/uwatch
> ===================================================================
> --- csw/mgar/gar/v2-uwatch2/bin/uwatch 2011-01-12 23:10:12 UTC (rev 12521)
> +++ csw/mgar/gar/v2-uwatch2/bin/uwatch 2011-01-13 00:27:01 UTC (rev 12522)
> @@ -39,6 +39,7 @@
> import shutil
> import subprocess
> import pysvn
> +import MySQLdb
>
> from urllib2 import Request, urlopen, URLError
> from optparse import OptionParser
> @@ -83,6 +84,18 @@
> # ---------------------------------------------------------------------------------------------------------------------
> #
> #
> +class DatabaseConnectionException(Exception):
> + """Exception raised when an error occur while connecting to the database
> + """
> +
> + # -----------------------------------------------------------------------------------------------------------------
> +
> + def __init__(self, message):
> + self.message = message
> +
> +# ---------------------------------------------------------------------------------------------------------------------
> +#
> +#
> class UpstreamUrlRetrievalFailedException(Exception):
> """Exception raised when an unsuported protocol is specified in the upstream url
> """
> @@ -1029,9 +1042,173 @@
>
> def __init__(self, name):
> super(ReportPackageVersionCommand, self).__init__(name)
> + self.conn = None
>
> # -----------------------------------------------------------------------------------------------------------------
>
> + def openDatabaseConnection(self):
> + """This method open a connection to the mysql database using value from the configuration parser. The result of
> + connect method is stored into a connection object
> + """
> +
> + # Open the database connection
> + try:
> + self.conn = MySQLdb.connect(host = self.configParser.getDatabaseHost(),
Are you aware of the Python standard ConfigParser and optparse modules?
More information about the devel
mailing list