From 8c0033074b91e5dbac09818c689a8a1a48534ac1 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 30 Jan 2013 20:41:51 +0100 Subject: [PATCH] Support both output logging and error logging in the Environment.log() method --- updater/shared/environment.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/updater/shared/environment.py b/updater/shared/environment.py index a275ae7..8203b69 100644 --- a/updater/shared/environment.py +++ b/updater/shared/environment.py @@ -1,12 +1,15 @@ -import oursql +import oursql, sys class Environment(object): def connect(self, host="localhost", username="root", password="", database="learn"): self.db = oursql.connect(host=host, user=username, passwd=password, db=database) self.connected = True - def log(self, text): - print text + def log(self, text, is_error=False): + if is_error == False: + sys.stdout.write(text + "\n") + else: + sys.stderr.write(text + "\n") def Scraper(self, scraper_class): s = scraper_class(self.db)