Use the print function everywhere

python modernize.py --no-six -f libmodernize.fixes.fix_print -w

With manual fixes as the import was put always on top.
This commit is contained in:
Laurent Bachelier 2014-10-06 14:23:20 +02:00
commit 74a4ef6723
73 changed files with 499 additions and 442 deletions

View file

@ -18,6 +18,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from datetime import datetime, timedelta from datetime import datetime, timedelta
import logging import logging
@ -138,7 +139,7 @@ class BoobotBrowser(StandardBrowser):
# meta charset=... # meta charset=...
encoding = meta.attrib.get('charset', encoding).lower() encoding = meta.attrib.get('charset', encoding).lower()
except Exception as e: except Exception as e:
print e print(e)
finally: finally:
r.seek(0) r.seek(0)
if encoding == 'iso-8859-1' or not encoding: if encoding == 'iso-8859-1' or not encoding:
@ -159,7 +160,7 @@ class BoobotBrowser(StandardBrowser):
title = ' '.join(title.splitlines()) title = ' '.join(title.splitlines())
except AssertionError as e: except AssertionError as e:
# invalid HTML # invalid HTML
print e print(e)
return content_type, hsize, title return content_type, hsize, title
@ -377,7 +378,7 @@ class Boobot(SingleServerIRCBot):
for msg in getattr(self, func)(backend, _id): for msg in getattr(self, func)(backend, _id):
yield msg yield msg
except Exception as e: except Exception as e:
print get_backtrace() print(get_backtrace())
yield u'Oops: [%s] %s' % (type(e).__name__, e) yield u'Oops: [%s] %s' % (type(e).__name__, e)
break break
@ -394,7 +395,7 @@ class Boobot(SingleServerIRCBot):
except BrowserUnavailable as e: except BrowserUnavailable as e:
yield u'URL (error): %s' % e yield u'URL (error): %s' % e
except Exception as e: except Exception as e:
print get_backtrace() print(get_backtrace())
yield u'Oops: [%s] %s' % (type(e).__name__, e) yield u'Oops: [%s] %s' % (type(e).__name__, e)
def obj_info_video(self, backend, id): def obj_info_video(self, backend, id):
@ -418,7 +419,7 @@ def main():
try: try:
bot.start() bot.start()
except KeyboardInterrupt: except KeyboardInterrupt:
print "Stopped." print("Stopped.")
thread.stop() thread.stop()

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import subprocess import subprocess
import os import os
import re import re
@ -69,10 +71,10 @@ class Downloadboob(object):
for local_link_name in dirList: for local_link_name in dirList:
link_name = self.links_directory + "/" + local_link_name link_name = self.links_directory + "/" + local_link_name
if not self.check_link(link_name): if not self.check_link(link_name):
print u"Remove %s" % link_name print(u"Remove %s" % link_name)
os.remove(link_name) os.remove(link_name)
else: else:
print u"Keep %s" % link_name print(u"Keep %s" % link_name)
def check_link(self, link_name): def check_link(self, link_name):
if os.path.islink(link_name): if os.path.islink(link_name):
@ -85,10 +87,10 @@ class Downloadboob(object):
return True return True
def download(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None, title_exclude=[], id_regexp=None): def download(self, pattern=None, sortby=CapVideo.SEARCH_RELEVANCE, nsfw=False, max_results=None, title_exclude=[], id_regexp=None):
print "For backend %s, search for '%s'" % (backend_name, pattern) print("For backend %s, search for '%s'" % (backend_name, pattern))
# create directory for links # create directory for links
print " create link to %s" % self.links_directory print(" create link to %s" % self.links_directory)
if not os.path.isdir(self.links_directory): if not os.path.isdir(self.links_directory):
os.makedirs(self.links_directory) os.makedirs(self.links_directory)
@ -101,17 +103,17 @@ class Downloadboob(object):
if not self.is_downloaded(video): if not self.is_downloaded(video):
self.backend.fill_video(video, ('url','title', 'url', 'duration')) self.backend.fill_video(video, ('url','title', 'url', 'duration'))
if not(self.is_excluded(video.title, title_exclude)) and self.id_regexp_matched(video.id, id_regexp): if not(self.is_excluded(video.title, title_exclude)) and self.id_regexp_matched(video.id, id_regexp):
print " %s\n Id:%s\n Duration:%s" % (video.title, video.id, video.duration) print(" %s\n Id:%s\n Duration:%s" % (video.title, video.id, video.duration))
videos.append(video) videos.append(video)
else: else:
print "Already downloaded, check %s" % video.id print("Already downloaded, check %s" % video.id)
self.backend.fill_video(video, ('url','title', 'url', 'duration')) self.backend.fill_video(video, ('url','title', 'url', 'duration'))
linkname = self.get_linkname(video) linkname = self.get_linkname(video)
if not os.path.exists(linkname): if not os.path.exists(linkname):
self.remove_download(video) self.remove_download(video)
# download videos # download videos
print "Downloading..." print("Downloading...")
for video in videos: for video in videos:
self.do_download(video) self.do_download(video)
@ -164,7 +166,7 @@ class Downloadboob(object):
# already empty # already empty
return return
print 'Remove video %s' % video.title print('Remove video %s' % video.title)
# Empty it to keep information we have already downloaded it. # Empty it to keep information we have already downloaded it.
with open(path, 'w'): with open(path, 'w'):
@ -175,23 +177,23 @@ class Downloadboob(object):
idname = self.get_filename(video, relative=True) idname = self.get_filename(video, relative=True)
absolute_idname = self.get_filename(video, relative=False) absolute_idname = self.get_filename(video, relative=False)
if not os.path.islink(linkname) and os.path.isfile(absolute_idname): if not os.path.islink(linkname) and os.path.isfile(absolute_idname):
print "%s -> %s" % (linkname, idname) print("%s -> %s" % (linkname, idname))
os.symlink(idname, linkname) os.symlink(idname, linkname)
def do_download(self, video): def do_download(self, video):
if not video: if not video:
print >>sys.stderr, 'Video not found: %s' % video print('Video not found: %s' % video, file=sys.stderr)
return 3 return 3
if not video.url: if not video.url:
print >>sys.stderr, 'Error: the direct URL is not available.' print('Error: the direct URL is not available.', file=sys.stderr)
return 4 return 4
def check_exec(executable): def check_exec(executable):
with open('/dev/null', 'w') as devnull: with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull) process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0: if process.wait() != 0:
print >>sys.stderr, 'Please install "%s"' % executable print('Please install "%s"' % executable, file=sys.stderr)
return False return False
return True return True
@ -220,14 +222,14 @@ config.read(['/etc/downloadboob.conf', os.path.expanduser('~/downloadboob.conf')
try: try:
links_directory=os.path.expanduser(config.get('main','directory', '.')) links_directory=os.path.expanduser(config.get('main','directory', '.'))
except ConfigParser.NoSectionError: except ConfigParser.NoSectionError:
print "Please create a documentation file (see the README file and the downloadboob.conf example file)" print("Please create a documentation file (see the README file and the downloadboob.conf example file)")
sys.exit(2) sys.exit(2)
links_directory=links_directory.decode('utf-8') links_directory=links_directory.decode('utf-8')
download_directory=os.path.join(links_directory, DOWNLOAD_DIRECTORY) download_directory=os.path.join(links_directory, DOWNLOAD_DIRECTORY)
print "Downloading to %s" % (links_directory) print("Downloading to %s" % (links_directory))
for section in config.sections(): for section in config.sections():
if section != "main": if section != "main":

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
try: try:
import sqlite3 as sqlite import sqlite3 as sqlite
except ImportError as e: except ImportError as e:
@ -36,13 +38,13 @@ def main(filename):
try: try:
hds = weboob.build_backend('hds') hds = weboob.build_backend('hds')
except ModuleLoadError as e: except ModuleLoadError as e:
print >>sys.stderr, 'Unable to load "hds" module: %s' % e print('Unable to load "hds" module: %s' % e, file=sys.stderr)
return 1 return 1
try: try:
db = sqlite.connect(database=filename, timeout=10.0) db = sqlite.connect(database=filename, timeout=10.0)
except sqlite.OperationalError as err: except sqlite.OperationalError as err:
print >>sys.stderr, 'Unable to open %s database: %s' % (filename, err) print('Unable to open %s database: %s' % (filename, err), file=sys.stderr)
return 1 return 1
sys.stdout.write('Reading database... ') sys.stdout.write('Reading database... ')
@ -50,7 +52,7 @@ def main(filename):
try: try:
results = db.execute('SELECT id, author FROM stories') results = db.execute('SELECT id, author FROM stories')
except sqlite.OperationalError as err: except sqlite.OperationalError as err:
print >>sys.stderr, 'fail!\nUnable to read database: %s' % err print('fail!\nUnable to read database: %s' % err, file=sys.stderr)
return 1 return 1
stored = set() stored = set()
@ -104,33 +106,33 @@ def main(filename):
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:
print >>sys.stderr, 'Syntax: %s [--help] SQLITE_FILENAME' % sys.argv[0] print('Syntax: %s [--help] SQLITE_FILENAME' % sys.argv[0], file=sys.stderr)
sys.exit(1) sys.exit(1)
if sys.argv[1] in ('-h', '--help'): if sys.argv[1] in ('-h', '--help'):
print 'Syntax: %s SQLITE_FILENAME' % sys.argv[0] print('Syntax: %s SQLITE_FILENAME' % sys.argv[0])
print '' print('')
print 'Before running this software, please create the database with' print('Before running this software, please create the database with')
print 'this command:' print('this command:')
print ' $ cat scheme.sql | sqlite3 hds.sql' print(' $ cat scheme.sql | sqlite3 hds.sql')
print '' print('')
print 'You can then run export.py with:' print('You can then run export.py with:')
print ' $ %s hds.sql ' % sys.argv[0] print(' $ %s hds.sql ' % sys.argv[0])
print '' print('')
print 'It fill the database with stories and authors information' print('It fill the database with stories and authors information')
print 'fetched from histoires-de-sexe.net' print('fetched from histoires-de-sexe.net')
print '' print('')
print 'You can next use SQL queries to find interesting stories, for' print('You can next use SQL queries to find interesting stories, for')
print 'example:' print('example:')
print '' print('')
print '- To get all stories written by women' print('- To get all stories written by women')
print ' sqlite> SELECT s.id, s.title, s.category, a.name' print(' sqlite> SELECT s.id, s.title, s.category, a.name')
print ' FROM stories AS s LEFT JOIN authors AS a' print(' FROM stories AS s LEFT JOIN authors AS a')
print ' WHERE a.name = s.author AND a.sex = 2;' print(' WHERE a.name = s.author AND a.sex = 2;')
print '- To get all stories where it talks about bukkake' print('- To get all stories where it talks about bukkake')
print ' sqlite> SELECT s.id, s.title, s.category, a.name' print(' sqlite> SELECT s.id, s.title, s.category, a.name')
print ' FROM stories AS s LEFT JOIN authors AS a' print(' FROM stories AS s LEFT JOIN authors AS a')
print ' WHERE a.name = s.author AND s.body LIKE \'%bukkake%\';' print(' WHERE a.name = s.author AND s.body LIKE \'%bukkake%\';')
sys.exit(0) sys.exit(0)
sys.exit(main(sys.argv[1])) sys.exit(main(sys.argv[1]))

View file

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
import sys import sys
import resources.lib.test.common_test as common_xbmc import resources.lib.test.common_test as common_xbmc
@ -7,7 +8,7 @@ import resources.lib.constants as constants
from resources.lib.actions import actions from resources.lib.actions import actions
print sys.argv print(sys.argv)
if len(sys.argv) < 2: if len(sys.argv) < 2:
actions[constants.DISPLAY_MENU]()._do() actions[constants.DISPLAY_MENU]()._do()
else: else:

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
import sys import sys
from . import constants from . import constants
@ -52,7 +53,7 @@ class DisplayCollectionMenuAction(VideoobBaseAction):
common_xbmc.end_of_directory(False) common_xbmc.end_of_directory(False)
def add_videos(self, _video, backend): def add_videos(self, _video, backend):
print _video print(_video)
video = self.videoobmc.get_video(_video, backend) video = self.videoobmc.get_video(_video, backend)
if video: if video:
MenuItemVideo(video).add_to_menu() MenuItemVideo(video).add_to_menu()

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
import xbmc import xbmc
import xbmcgui import xbmcgui
@ -41,7 +42,7 @@ def get_addon_dir():
def display_error(msg): def display_error(msg):
xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg)) xbmc.executebuiltin("XBMC.Notification(%s, %s)" % (get_translation('30200').decode('utf-8'), msg))
print msg print(msg)
print_exc(msg) print_exc(msg)

View file

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
from weboob.tools.application.base import Application from weboob.tools.application.base import Application
import os import os
@ -53,7 +54,7 @@ class Weboobmc(Application):
with open('/dev/null', 'w') as devnull: with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull) process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0: if process.wait() != 0:
print 'Please install "%s"' % executable print('Please install "%s"' % executable)
return False return False
return True return True

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
import urllib import urllib
@ -33,11 +34,11 @@ def get_settings(key):
def display_error(error): def display_error(error):
print "%s: %s" % ("ERROR", error) print("%s: %s" % ("ERROR", error))
def display_info(msg): def display_info(msg):
print "%s: %s" % ("INFO", msg) print("%s: %s" % ("INFO", msg))
def parse_params(paramStr): def parse_params(paramStr):
@ -93,18 +94,18 @@ def create_param_url(paramsDic, quote_plus=False):
def add_menu_item(params={}): def add_menu_item(params={}):
print '%s => "%s"' % (params.get('name'), create_param_url(params)) print('%s => "%s"' % (params.get('name'), create_param_url(params)))
def add_menu_link(params={}): def add_menu_link(params={}):
print '[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url')) print('[%s] %s (%s)' % (params.get('id'), params.get('name'), params.get('url')))
#print params.get('itemInfoLabels') #print params.get('itemInfoLabels')
#print params.get('c_items') #print params.get('c_items')
def end_of_directory(update=False): def end_of_directory(update=False):
print '******************************************************' print('******************************************************')
def download_video(url, name, dir='./'): def download_video(url, name, dir='./'):
print 'Downlaod a video %s from %s' % (name, url) print('Downlaod a video %s from %s' % (name, url))

View file

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import print_function
from .base.weboobmc2 import Weboobmc from .base.weboobmc2 import Weboobmc
from weboob.capabilities.video import BaseVideo, CapVideo from weboob.capabilities.video import BaseVideo, CapVideo
@ -22,7 +23,7 @@ class Videoobmc(Weboobmc):
for _backend, video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs): for _backend, video in self.weboob.do(self._do_complete, self.count, fields, 'search_videos', **kwargs):
yield video yield video
except Exception as e: except Exception as e:
print e print(e)
def get_video(self, video, _backend): def get_video(self, video, _backend):
backend = self.weboob.get_backend(_backend) backend = self.weboob.get_backend(_backend)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os import os
@ -79,8 +80,8 @@ class VideoobWeb(Application):
def main(self, argv): def main(self, argv):
self.load_config() self.load_config()
self.weboob.load_backends(CapVideo) self.weboob.load_backends(CapVideo)
print 'Web server created. Listening on http://%s:%s' % ( print('Web server created. Listening on http://%s:%s' % (
self.config.get('host'), int(self.config.get('port'))) self.config.get('host'), int(self.config.get('port'))))
srv = make_server(self.config.get('host'), int(self.config.get('port')), self.make_app) srv = make_server(self.config.get('host'), int(self.config.get('port')), self.make_app)
srv.serve_forever() srv.serve_forever()

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import hashlib import hashlib
import sys import sys
@ -92,13 +93,13 @@ class Tile(object):
self.map.append(pxls) self.map.append(pxls)
def display(self): def display(self):
print '-' * (len(self.map) * 2 + 2) print('-' * (len(self.map) * 2 + 2))
for y in xrange(len(self.map[0])): for y in xrange(len(self.map[0])):
sys.stdout.write('|') sys.stdout.write('|')
for x in xrange(len(self.map)): for x in xrange(len(self.map)):
sys.stdout.write('%s' % ('XX' if self.map[x][y] else ' ')) sys.stdout.write('%s' % ('XX' if self.map[x][y] else ' '))
print '|' print('|')
print '-' * (len(self.map) * 2 + 2) print('-' * (len(self.map) * 2 + 2))
def checksum(self): def checksum(self):
s = '' s = ''
@ -113,9 +114,9 @@ class Tile(object):
try: try:
return self.hash[checksum] return self.hash[checksum]
except KeyError: except KeyError:
print 'Unable te resolve:' print('Unable te resolve:')
self.display() self.display()
print 'hash: %s' % checksum print('hash: %s' % checksum)
raise CaptchaError() raise CaptchaError()
@ -175,11 +176,11 @@ class Decoder(object):
checksum = tile.checksum() checksum = tile.checksum()
if checksum in self.hash: if checksum in self.hash:
print 'Skipping %s' % self.hash[checksum] print('Skipping %s' % self.hash[checksum])
continue continue
tile.display() tile.display()
print 'Checksum: %s' % checksum print('Checksum: %s' % checksum)
ntry = 2 ntry = 2
while ntry: while ntry:
sys.stdout.write('Enter the letter: ') sys.stdout.write('Enter the letter: ')
@ -187,9 +188,9 @@ class Decoder(object):
ntry -= 1 ntry -= 1
if len(l) != 1: if len(l) != 1:
print 'Error: please enter only one letter' print('Error: please enter only one letter')
elif l in self.hash.itervalues(): elif l in self.hash.itervalues():
print 'Warning! This letter has already been catched!' print('Warning! This letter has already been catched!')
else: else:
ntry = 0 ntry = 0
@ -200,13 +201,13 @@ class Decoder(object):
while True: while True:
self.process() self.process()
except KeyboardInterrupt: except KeyboardInterrupt:
print '' print('')
print 'hash = {' print('hash = {')
l = sorted(self.hash.iteritems(), key=lambda (k,v): (v,k)) l = sorted(self.hash.iteritems(), key=lambda (k,v): (v,k))
for hash, value in l: for hash, value in l:
print ' \'%s\': %s' % (hash, value) print(' \'%s\': %s' % (hash, value))
print '}' print('}')
if __name__ == '__main__': if __name__ == '__main__':
d = Decoder() d = Decoder()

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from random import randint from random import randint
@ -93,7 +94,7 @@ class ProfilesWalker(Optimization):
self.profiles_queue.add(id) self.profiles_queue.add(id)
return return
except Exception as e: except Exception as e:
print e print(e)
finally: finally:
if self.view_cron is not None: if self.view_cron is not None:
self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile) self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.tools.browser import BrowserUnavailable from weboob.tools.browser import BrowserUnavailable
from weboob.capabilities.dating import Optimization from weboob.capabilities.dating import Optimization
@ -45,5 +46,5 @@ class Visibility(Optimization):
with self.browser: with self.browser:
self.browser.login() self.browser.login()
except BrowserUnavailable as e: except BrowserUnavailable as e:
print str(e) print(str(e))
pass pass

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.tools.browser import Page, BrowserIncorrectPassword from weboob.tools.browser import Page, BrowserIncorrectPassword
import urllib2 import urllib2
@ -121,4 +122,4 @@ class AuthenticationPage(Page):
def print_cookies(self): def print_cookies(self):
for c in self.browser._ua_handlers["_cookies"].cookiejar: for c in self.browser._ua_handlers["_cookies"].cookiejar:
print "%s : %s" % (c.name, c.value) print("%s : %s" % (c.name, c.value))

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import re import re
from decimal import Decimal from decimal import Decimal
@ -217,8 +219,8 @@ class CardsPage(Page):
try: try:
t.id = t.unique_id(seen) t.id = t.unique_id(seen)
except UnicodeEncodeError: except UnicodeEncodeError:
print t print(t)
print t.label print(t.label)
raise raise
yield t yield t

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.tools.mech import ClientForm from weboob.tools.mech import ClientForm
ControlNotFoundError = ClientForm.ControlNotFoundError ControlNotFoundError = ClientForm.ControlNotFoundError
@ -73,7 +75,7 @@ class VideoPage(Page):
obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1) obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1)
if obj is not None: if obj is not None:
value = obj.attrib['content'] value = obj.attrib['content']
print value print(value)
m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value) m = re.match('(\d\d)-(\d\d)-(\d\d\d\d)\s*(\d\d):(\d\d)', value)
if not m: if not m:
raise BrokenPageError('Unable to parse datetime: %r' % value) raise BrokenPageError('Unable to parse datetime: %r' % value)

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import urllib import urllib
from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\ from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\
@ -149,7 +151,7 @@ class GDCVaultBrowser(Browser):
return self.page.iter_videos() return self.page.iter_videos()
def latest_videos(self): def latest_videos(self):
print "browser:latest_videos()" print("browser:latest_videos()")
#self.home() #self.home()
self.location('/free') self.location('/free')
assert self.is_on_page(IndexPage) assert self.is_on_page(IndexPage)

View file

@ -18,6 +18,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import urllib import urllib
import mechanize import mechanize
@ -85,7 +86,7 @@ class HelloBank(Browser):
accounts = self.page.get_accounts() accounts = self.page.get_accounts()
if len(accounts) == 0: if len(accounts) == 0:
print 'no accounts' print('no accounts')
# oops, no accounts? check if we have not exhausted the allowed use # oops, no accounts? check if we have not exhausted the allowed use
# of this password # of this password
for img in self.document.getroot().cssselect('img[align="middle"]'): for img in self.document.getroot().cssselect('img[align="middle"]'):

View file

@ -18,6 +18,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from decimal import Decimal from decimal import Decimal
@ -66,7 +67,7 @@ class AccountsList(Page):
l.append(account) l.append(account)
if len(l) == 0: if len(l) == 0:
print 'no accounts' print('no accounts')
# oops, no accounts? check if we have not exhausted the allowed use # oops, no accounts? check if we have not exhausted the allowed use
# of this password # of this password
for img in self.document.getroot().cssselect('img[align="middle"]'): for img in self.document.getroot().cssselect('img[align="middle"]'):

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>. # along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from random import randint from random import randint
@ -100,7 +101,7 @@ class ProfilesWalker(Optimization):
self.profiles_queue.add(id) self.profiles_queue.add(id)
return return
except Exception as e: except Exception as e:
print e print(e)
finally: finally:
if self.view_cron is not None: if self.view_cron is not None:
self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile) self.view_cron = self.sched.schedule(randint(5, 10), self.view_profile)

Some files were not shown because too many files have changed in this diff Show more