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

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import subprocess
import os
import re
@ -69,10 +71,10 @@ class Downloadboob(object):
for local_link_name in dirList:
link_name = self.links_directory + "/" + local_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)
else:
print u"Keep %s" % link_name
print(u"Keep %s" % link_name)
def check_link(self, link_name):
if os.path.islink(link_name):
@ -85,10 +87,10 @@ class Downloadboob(object):
return True
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
print " create link to %s" % self.links_directory
print(" create link to %s" % self.links_directory)
if not os.path.isdir(self.links_directory):
os.makedirs(self.links_directory)
@ -101,17 +103,17 @@ class Downloadboob(object):
if not self.is_downloaded(video):
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):
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)
else:
print "Already downloaded, check %s" % video.id
print("Already downloaded, check %s" % video.id)
self.backend.fill_video(video, ('url','title', 'url', 'duration'))
linkname = self.get_linkname(video)
if not os.path.exists(linkname):
self.remove_download(video)
# download videos
print "Downloading..."
print("Downloading...")
for video in videos:
self.do_download(video)
@ -164,7 +166,7 @@ class Downloadboob(object):
# already empty
return
print 'Remove video %s' % video.title
print('Remove video %s' % video.title)
# Empty it to keep information we have already downloaded it.
with open(path, 'w'):
@ -175,23 +177,23 @@ class Downloadboob(object):
idname = self.get_filename(video, relative=True)
absolute_idname = self.get_filename(video, relative=False)
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)
def do_download(self, video):
if not video:
print >>sys.stderr, 'Video not found: %s' % video
print('Video not found: %s' % video, file=sys.stderr)
return 3
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
def check_exec(executable):
with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0:
print >>sys.stderr, 'Please install "%s"' % executable
print('Please install "%s"' % executable, file=sys.stderr)
return False
return True
@ -220,14 +222,14 @@ config.read(['/etc/downloadboob.conf', os.path.expanduser('~/downloadboob.conf')
try:
links_directory=os.path.expanduser(config.get('main','directory', '.'))
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)
links_directory=links_directory.decode('utf-8')
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():
if section != "main":

View file

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

View file

@ -1,5 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
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
print sys.argv
print(sys.argv)
if len(sys.argv) < 2:
actions[constants.DISPLAY_MENU]()._do()
else:

View file

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

View file

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

View file

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

View file

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
import urllib
@ -33,11 +34,11 @@ def get_settings(key):
def display_error(error):
print "%s: %s" % ("ERROR", error)
print("%s: %s" % ("ERROR", error))
def display_info(msg):
print "%s: %s" % ("INFO", msg)
print("%s: %s" % ("INFO", msg))
def parse_params(paramStr):
@ -93,18 +94,18 @@ def create_param_url(paramsDic, quote_plus=False):
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={}):
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('c_items')
def end_of_directory(update=False):
print '******************************************************'
print('******************************************************')
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
# -*- coding: utf-8 -*-
from __future__ import print_function
from .base.weboobmc2 import Weboobmc
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):
yield video
except Exception as e:
print e
print(e)
def get_video(self, video, _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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os
@ -79,8 +80,8 @@ class VideoobWeb(Application):
def main(self, argv):
self.load_config()
self.weboob.load_backends(CapVideo)
print 'Web server created. Listening on http://%s:%s' % (
self.config.get('host'), int(self.config.get('port')))
print('Web server created. Listening on http://%s:%s' % (
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.serve_forever()

View file

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

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from random import randint
@ -93,7 +94,7 @@ class ProfilesWalker(Optimization):
self.profiles_queue.add(id)
return
except Exception as e:
print e
print(e)
finally:
if self.view_cron is not None:
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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.tools.browser import BrowserUnavailable
from weboob.capabilities.dating import Optimization
@ -45,5 +46,5 @@ class Visibility(Optimization):
with self.browser:
self.browser.login()
except BrowserUnavailable as e:
print str(e)
print(str(e))
pass

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.tools.browser import Page, BrowserIncorrectPassword
import urllib2
@ -121,4 +122,4 @@ class AuthenticationPage(Page):
def print_cookies(self):
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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import re
from decimal import Decimal
@ -217,8 +219,8 @@ class CardsPage(Page):
try:
t.id = t.unique_id(seen)
except UnicodeEncodeError:
print t
print t.label
print(t)
print(t.label)
raise
yield t

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.tools.mech import ClientForm
ControlNotFoundError = ClientForm.ControlNotFoundError
@ -73,7 +75,7 @@ class VideoPage(Page):
obj = self.parser.select(self.document.getroot(), 'meta[name=available]', 1)
if obj is not None:
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)
if not m:
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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import urllib
from weboob.tools.browser import Browser, BrowserIncorrectPassword, BrowserUnavailable,\
@ -149,7 +151,7 @@ class GDCVaultBrowser(Browser):
return self.page.iter_videos()
def latest_videos(self):
print "browser:latest_videos()"
print("browser:latest_videos()")
#self.home()
self.location('/free')
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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import urllib
import mechanize
@ -85,7 +86,7 @@ class HelloBank(Browser):
accounts = self.page.get_accounts()
if len(accounts) == 0:
print 'no accounts'
print('no accounts')
# oops, no accounts? check if we have not exhausted the allowed use
# of this password
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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from decimal import Decimal
@ -66,7 +67,7 @@ class AccountsList(Page):
l.append(account)
if len(l) == 0:
print 'no accounts'
print('no accounts')
# oops, no accounts? check if we have not exhausted the allowed use
# of this password
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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from random import randint
@ -100,7 +101,7 @@ class ProfilesWalker(Optimization):
self.profiles_queue.add(id)
return
except Exception as e:
print e
print(e)
finally:
if self.view_cron is not None:
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
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import hashlib
@ -133,7 +134,7 @@ class Tile(object):
raise TileError('Tile not found ' + sum, self)
def display(self):
print self.checksum()
print(self.checksum())
#im = Image.new('RGB', (24, 23))
#im.putdata(self.map)
#im.save('/tmp/%s.png' % self.checksum())

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import re
from weboob.browser2.page import JsonPage, HTMLPage, method
@ -142,7 +144,7 @@ class DeparturesPage2(HTMLPage):
form['moiHoraire'] = '%s|%s' % (date.month, date.year)
form['heureHoraire'] = date.hour
form['minuteHoraire'] = date.minute
print form
print(form)
form.submit()

View file

@ -18,6 +18,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import argparse
import subprocess
import datetime
@ -50,11 +52,11 @@ def write(target, contents):
if not os.path.isdir(os.path.dirname(target)):
os.makedirs(os.path.dirname(target))
if os.path.exists(target):
print >>sys.stderr, "%s already exists." % target
print("%s already exists." % target, file=sys.stderr)
sys.exit(4)
with codecs.open(target, mode='w', encoding='utf-8') as f:
f.write(contents)
print 'Created %s' % target
print('Created %s' % target)
class Recipe(object):
@ -156,7 +158,7 @@ class CapRecipe(Recipe):
self.error('Capability %r not found' % self.capname)
def error(self, message):
print >>sys.stderr, message
print(message, file=sys.stderr)
sys.exit(1)
def methods_code(self, klass):

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python
from __future__ import print_function
import sys
from weboob.tools.browser import StandardBrowser
print StandardBrowser()._certhash(sys.argv[1])
print(StandardBrowser()._certhash(sys.argv[1]))

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import subprocess
@ -15,7 +16,7 @@ for root, dirs, files in os.walk(sys.argv[1]):
try:
exec(s)
except ImportError as e:
print >>sys.stderr, str(e)
print(str(e), file=sys.stderr)
else:
m = eval(f[:-3])
for attrname in dir(m):
@ -36,7 +37,7 @@ for f in selection:
for line in p.stdout.readlines():
dependencies.add(line.strip().split(':')[0])
else:
print 'not found: %s' % f
print('not found: %s' % f)
for d in dependencies:
print d
print(d)

View file

@ -1,5 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import subprocess
import sys
import os
@ -10,26 +12,26 @@ if '--deps' in sys.argv:
else:
deps = ['--nodeps']
print "Weboob local installer"
print
print("Weboob local installer")
print()
if len(sys.argv) < 2:
print "This tool will install Weboob to be usuable without requiring"
print "messing with your system, which should only be touched by a package manager."
print
print "Usage: %s DESTINATION [OPTIONS]" % sys.argv[0]
print
print "By default, no dependencies are installed, as you should try"
print "to install them from your package manager as much as possible."
print "To install all the missing dependencies, add the option --deps"
print "at the end of the command line."
print
print >>sys.stderr, "Error: Please provide a destination, " \
"for example %s/bin" % os.getenv('HOME')
print("This tool will install Weboob to be usuable without requiring")
print("messing with your system, which should only be touched by a package manager.")
print()
print("Usage: %s DESTINATION [OPTIONS]" % sys.argv[0])
print()
print("By default, no dependencies are installed, as you should try")
print("to install them from your package manager as much as possible.")
print("To install all the missing dependencies, add the option --deps")
print("at the end of the command line.")
print()
print("Error: Please provide a destination, " \
"for example %s/bin" % os.getenv('HOME'), file=sys.stderr)
sys.exit(1)
else:
dest = os.path.expanduser(sys.argv[1])
print "Installing weboob applications into %s." % dest
print("Installing weboob applications into %s." % dest)
subprocess.check_call(
[sys.executable, 'setup.py',
@ -38,11 +40,11 @@ subprocess.check_call(
subprocess.check_call([sys.executable, os.path.join(dest, 'weboob-config'), 'update'])
print
print "Installation done. Applications are available in %s." % dest
print "You can remove the source files."
print
print "To have easy access to the Weboob applications,"
print "you should add the following line to your ~/.bashrc or ~/.zshrc file:"
print "export PATH=\"$PATH:%s\"" % dest
print "And then restart your shells."
print()
print("Installation done. Applications are available in %s." % dest)
print("You can remove the source files.")
print()
print("To have easy access to the Weboob applications,")
print("you should add the following line to your ~/.bashrc or ~/.zshrc file:")
print("export PATH=\"$PATH:%s\"" % dest)
print("And then restart your shells.")

View file

@ -1,11 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import subprocess
import sys
import os
if len(sys.argv) < 2:
print "Usage: %s SCRIPTNAME [args]" % sys.argv[0]
print("Usage: %s SCRIPTNAME [args]" % sys.argv[0])
sys.exit(1)
else:
script = sys.argv[1]
@ -37,7 +39,7 @@ p = subprocess.Popen(
stdout=subprocess.PIPE)
s = p.communicate()
if p.returncode != 0:
print s[0]
print(s[0])
sys.exit(p.returncode)
if os.path.exists(script):

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
# Copyright(C) 2010-2011 Laurent Bachelier
#
@ -120,10 +121,10 @@ def main():
try:
script = imp.load_module("scripts.%s" % fname, f, tmpfile, desc)
except ImportError as e:
print >>sys.stderr, "Unable to load the %s script (%s)" \
% (fname, e)
print("Unable to load the %s script (%s)" \
% (fname, e), file=sys.stderr)
else:
print "Loaded %s" % fname
print("Loaded %s" % fname)
# Find the applications we can handle
for klass in script.__dict__.itervalues():
if inspect.isclass(klass) and issubclass(klass, Application):
@ -227,7 +228,7 @@ For full COPYRIGHT see COPYING file with weboob package.
with open(os.path.join(BASE_PATH, DEST_DIR, "%s.1" % script_name), 'w+') as manfile:
for line in mantext.split('\n'):
manfile.write('%s\n' % line.lstrip().encode('utf-8'))
print "wrote %s/%s.1" % (DEST_DIR, script_name)
print("wrote %s/%s.1" % (DEST_DIR, script_name))
if __name__ == '__main__':
sys.exit(main())

View file

@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
@ -17,4 +19,4 @@ for dirpath, dirnames, filenames in os.walk(root):
if not os.path.exists(os.path.join(dirpath, filename[:-1])):
os.unlink(os.path.join(dirpath, filename))
if verbose:
print os.path.join(dirpath, filename)
print(os.path.join(dirpath, filename))

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
# Hint: use this script with file:///path/to/local/modules/ in sources.list
# if you want to correctly check all modules.
@ -22,6 +23,6 @@ for name, backend in weboob.modules_loader.loaded.iteritems():
backends_without_icons.append(name)
if backends_without_tests:
print 'Modules without tests: %s' % backends_without_tests
print('Modules without tests: %s' % backends_without_tests)
if backends_without_icons:
print 'Modules without icons: %s' % backends_without_icons
print('Modules without icons: %s' % backends_without_icons)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from datetime import datetime, timedelta
import re
@ -119,7 +120,7 @@ class Event(object):
elif line.startswith('h3=. '):
m = re.match('h3=. Event finished. Winner is "(.*)":/users/(\d+)\!', line)
if not m:
print >>self.stderr, 'Unable to parse h3=: %s' % line
print('Unable to parse h3=: %s' % line, file=self.stderr)
continue
self.winner = Member(int(m.group(2)), m.group(1))
elif line.startswith('h2. '):
@ -127,7 +128,7 @@ class Event(object):
elif line.startswith('h3. '):
m = re.match('h3. "(.*)":/users/(\d+)', line)
if not m:
print >>self.stderr, 'Unable to parse user "%s"' % line
print('Unable to parse user "%s"' % line, file=self.stderr)
continue
member = Member(int(m.group(2)), m.group(1))
if member.id == self.my_id:
@ -166,7 +167,7 @@ class Event(object):
elif line.startswith('[['):
m = re.match('\[\[(\w+)\]\]\|\[\[(\w+)\]\]\|(.*)\|', line)
if not m:
print >>self.stderr, 'Unable to parse task: "%s"' % line
print('Unable to parse task: "%s"' % line, file=self.stderr)
continue
task = Task(m.group(1), m.group(2))
member.tasks.append(task)
@ -292,7 +293,7 @@ class Boobathon(ReplApplication):
def main(self, argv):
if len(argv) < 2:
print >>self.stderr, 'Please give the name of the boobathon'
print('Please give the name of the boobathon', file=self.stderr)
return 1
self.event = Event(argv[1], choice(self.weboob.backend_instances.values()))
@ -372,9 +373,9 @@ class Boobathon(ReplApplication):
else:
s += ' '
s += '|%s' % self.NC
print s
print(s)
print ''
print('')
now = datetime.now()
if self.event.begin > now:
d = self.event.begin - now
@ -394,13 +395,13 @@ class Boobathon(ReplApplication):
progress += '>'
else:
progress += ' '
print 'Event started: %s |%s| %s' % (self.event.begin.strftime('%H:%M'),
print('Event started: %s |%s| %s' % (self.event.begin.strftime('%H:%M'),
progress,
self.event.end.strftime('%H:%M'))
self.event.end.strftime('%H:%M')))
d = self.event.end - now
msg = 'The event will be finished in %d days, %02d:%02d:%02d'
print msg % (d.days, d.seconds/3600, d.seconds%3600/60, d.seconds%60)
print(msg % (d.days, d.seconds/3600, d.seconds%3600/60, d.seconds%60))
def do_tasks(self, line):
"""
@ -468,10 +469,10 @@ class Boobathon(ReplApplication):
if member.name == name:
self.event.winner = member
if self.save_event('Close event'):
print 'Event is now closed. Winner is %s!' % self.event.winner.name
print('Event is now closed. Winner is %s!' % self.event.winner.name)
return
print >>self.stderr, '"%s" not found' % name
print('"%s" not found' % name, file=self.stderr)
return 3
def complete_edit(self, text, line, *ignored):
@ -486,7 +487,7 @@ class Boobathon(ReplApplication):
Edit information about you or about event.
"""
if not line:
print >>self.stderr, 'Syntax: edit [event | me]'
print('Syntax: edit [event | me]', file=self.stderr)
return 2
self.event.load()
@ -496,12 +497,12 @@ class Boobathon(ReplApplication):
elif line == 'me':
mem = self.event.get_me()
if not mem:
print >>self.stderr, 'You haven\'t joined the event.'
print('You haven\'t joined the event.', file=self.stderr)
return 1
self.edit_member(mem)
self.save_event('Member edited')
else:
print >>self.stderr, 'Unable to edit "%s"' % line
print('Unable to edit "%s"' % line, file=self.stderr)
return 1
def do_info(self, line):
@ -511,19 +512,19 @@ class Boobathon(ReplApplication):
Display information about this event.
"""
self.event.load()
print self.event.title
print '-' * len(self.event.title)
print self.event.description
print ''
print 'Date:', self.event.date.strftime('%Y-%m-%d') if self.event.date else 'Unknown'
print 'Begin:', self.event.begin.strftime('%H:%M') if self.event.begin else 'Unknown'
print 'End:', self.event.end.strftime('%H:%M') if self.event.end else 'Unknown'
print 'Duration:', self.event.format_duration() or 'Unknown'
print 'Location:', self.event.location or 'Unknown'
print ''
print 'There are %d members, use the "members" command to list them' % len(self.event.members)
print(self.event.title)
print('-' * len(self.event.title))
print(self.event.description)
print('')
print('Date:', self.event.date.strftime('%Y-%m-%d') if self.event.date else 'Unknown')
print('Begin:', self.event.begin.strftime('%H:%M') if self.event.begin else 'Unknown')
print('End:', self.event.end.strftime('%H:%M') if self.event.end else 'Unknown')
print('Duration:', self.event.format_duration() or 'Unknown')
print('Location:', self.event.location or 'Unknown')
print('')
print('There are %d members, use the "members" command to list them' % len(self.event.members))
if self.event.get_me() is None:
print 'To join this event, use the command "join".'
print('To join this event, use the command "join".')
def do_members(self, line):
"""
@ -533,22 +534,22 @@ class Boobathon(ReplApplication):
"""
self.event.load()
for member in self.event.members.itervalues():
print member.name
print '-' * len(member.name)
print 'Repository:', member.repository
print(member.name)
print('-' * len(member.name))
print('Repository:', member.repository)
if self.event.date is None:
print 'Availabilities:', member.availabilities
print 'Hardware:', member.hardware
print('Availabilities:', member.availabilities)
print('Hardware:', member.hardware)
accompl = 0
for task in member.tasks:
if task.status == task.STATUS_DONE:
accompl += 1
print '%d tasks (%d accomplished)' % (len(member.tasks), accompl)
print('%d tasks (%d accomplished)' % (len(member.tasks), accompl))
if member is self.event.winner:
print '=== %s is the winner!' % member.name
print ''
print('=== %s is the winner!' % member.name)
print('')
print 'Use the "tasks" command to display all tasks'
print('Use the "tasks" command to display all tasks')
def do_join(self, line):
"""
@ -558,11 +559,11 @@ class Boobathon(ReplApplication):
"""
self.event.load()
if self.event.backend.browser.get_userid() in self.event.members:
print >>self.stderr, 'You have already joined this event.'
print('You have already joined this event.', file=self.stderr)
return 1
if self.event.is_closed():
print >>self.stderr, "Boobathon is closed."
print("Boobathon is closed.", file=self.stderr)
return 1
m = Member(self.event.backend.browser.get_userid(), None)
@ -579,17 +580,17 @@ class Boobathon(ReplApplication):
self.event.load()
if self.event.currently_in_event():
print >>self.stderr, 'Unable to leave during the event, loser!'
print('Unable to leave during the event, loser!', file=self.stderr)
return 1
if self.event.is_closed():
print >>self.stderr, "Boobathon is closed."
print("Boobathon is closed.", file=self.stderr)
return 1
try:
self.event.members.pop(self.event.backend.browser.get_userid())
except KeyError:
print >>self.stderr, "You have not joined this event."
print("You have not joined this event.", file=self.stderr)
return 1
else:
self.save_event('Left the event')
@ -603,26 +604,26 @@ class Boobathon(ReplApplication):
self.event.load()
mem = self.event.get_me()
if not mem:
print >>self.stderr, "You have not joined this event."
print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
print >>self.stderr, "Boobathon is closed."
print("Boobathon is closed.", file=self.stderr)
return 1
try:
task_id = int(line)
except ValueError:
print >>self.stderr, 'The task ID should be a number'
print('The task ID should be a number', file=self.stderr)
return 2
try:
task = mem.tasks.pop(task_id)
except IndexError:
print >>self.stderr, 'Unable to find task #%d' % task_id
print('Unable to find task #%d' % task_id, file=self.stderr)
return 1
else:
print 'Removing task #%d (%s,%s).' % (task_id, task.backend, task.capability)
print('Removing task #%d (%s,%s).' % (task_id, task.backend, task.capability))
self.save_event('Remove task')
def do_addtask(self, line):
@ -634,24 +635,24 @@ class Boobathon(ReplApplication):
self.event.load()
mem = self.event.get_me()
if not mem:
print >>self.stderr, "You have not joined this event."
print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
print >>self.stderr, "Boobathon is closed."
print("Boobathon is closed.", file=self.stderr)
return 1
backend, capability = self.parse_command_args(line, 2, 2)
if not backend[0].isupper():
print >>self.stderr, 'The backend name "%s" needs to start with a capital.' % backend
print('The backend name "%s" needs to start with a capital.' % backend, file=self.stderr)
return 2
if not capability.startswith('Cap') or not capability[3].isupper():
print >>self.stderr, '"%s" is not a proper capability name (must start with Cap).' % capability
print('"%s" is not a proper capability name (must start with Cap).' % capability, file=self.stderr)
return 2
for task in mem.tasks:
if (task.backend,task.capability) == (backend,capability):
print >>self.stderr, "A task already exists for that."
print("A task already exists for that.", file=self.stderr)
return 1
task = Task(backend, capability)
@ -668,15 +669,15 @@ class Boobathon(ReplApplication):
self.event.load()
mem = self.event.get_me()
if not mem:
print >>self.stderr, "You have not joined this event."
print("You have not joined this event.", file=self.stderr)
return 1
if len(mem.tasks) == 0:
print >>self.stderr, "You don't have any task to do."
print("You don't have any task to do.", file=self.stderr)
return 1
if not self.event.currently_in_event():
print >>self.stderr, "You can't start a task, we are not in event."
print("You can't start a task, we are not in event.", file=self.stderr)
return 1
if line.isdigit():
@ -690,16 +691,16 @@ class Boobathon(ReplApplication):
last_done = i
elif task.status == task.STATUS_PROGRESS:
task.status = task.STATUS_NONE
print 'Task #%s (%s,%s) canceled.' % (i, task.backend, task.capability)
print('Task #%s (%s,%s) canceled.' % (i, task.backend, task.capability))
if (i == task_id or task_id < 0) and task.status == task.STATUS_NONE:
break
else:
print >>self.stderr, 'Task not found.'
print('Task not found.', file=self.stderr)
return 3
if task.status == task.STATUS_DONE:
print >>self.stderr, 'Task is already done.'
print('Task is already done.', file=self.stderr)
return 1
task.status = task.STATUS_PROGRESS
@ -716,16 +717,16 @@ class Boobathon(ReplApplication):
self.event.load()
mem = self.event.get_me()
if not mem:
print >>self.stderr, "You have not joined this event."
print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
print >>self.stderr, "Boobathon is closed."
print("Boobathon is closed.", file=self.stderr)
return 1
for i, task in enumerate(mem.tasks):
if task.status == task.STATUS_PROGRESS:
print 'Task (%s,%s) done! (%d%%)' % (task.backend, task.capability, (i+1)*100/len(mem.tasks))
print('Task (%s,%s) done! (%d%%)' % (task.backend, task.capability, (i+1)*100/len(mem.tasks)))
if self.event.currently_in_event():
task.status = task.STATUS_DONE
task.date = datetime.now()
@ -733,12 +734,12 @@ class Boobathon(ReplApplication):
self.save_event('Task accomplished')
else:
task.status = task.STATUS_NONE
print >>self.stderr, 'Oops, you are out of event. Canceling the task...'
print('Oops, you are out of event. Canceling the task...', file=self.stderr)
self.save_event('Cancel task')
return 1
return
print >>self.stderr, "There isn't any task in progress."
print("There isn't any task in progress.", file=self.stderr)
return 1
def do_cancel(self, line):
@ -750,21 +751,21 @@ class Boobathon(ReplApplication):
self.event.load()
mem = self.event.get_me()
if not mem:
print >>self.stderr, "You have not joined this event."
print("You have not joined this event.", file=self.stderr)
return 1
if self.event.is_closed():
print >>self.stderr, "Boobathon is closed."
print("Boobathon is closed.", file=self.stderr)
return 1
for task in mem.tasks:
if task.status == task.STATUS_PROGRESS:
print 'Task (%s,%s) canceled.' % (task.backend, task.capability)
print('Task (%s,%s) canceled.' % (task.backend, task.capability))
task.status = task.STATUS_NONE
self.save_event('Cancel task')
return
print >>self.stderr, "There isn't any task in progress."
print("There isn't any task in progress.", file=self.stderr)
return 1
def load_default_backends(self):
@ -780,7 +781,7 @@ class Boobathon(ReplApplication):
return
if not self.check_loaded_backends({'url': 'https://symlink.me'}):
print "Ok, so leave now, fag."
print("Ok, so leave now, fag.")
sys.exit(0)
def is_module_loadable(self, module):

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright(C) 2013 Bezleputh

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from datetime import time, datetime
from weboob.tools.date import parse_date
@ -178,10 +180,10 @@ class Boobcoming(ReplApplication):
r = 'notempty'
while r != '':
for category in CATEGORIES.values:
print ' %s%2d)%s [%s] %s' % (self.BOLD,
print(' %s%2d)%s [%s] %s' % (self.BOLD,
CATEGORIES.index[category] + 1,
self.NC,
'x' if category in query.categories else ' ', category)
'x' if category in query.categories else ' ', category))
r = self.ask(' Select category (or empty to stop)', regexp='(\d+|)', default='')
if not r.isdigit():
continue
@ -230,7 +232,7 @@ class Boobcoming(ReplApplication):
if line:
_date = parse_date(line)
if not _date:
print >>self.stderr, 'Invalid argument: %s' % self.get_command_help('list')
print('Invalid argument: %s' % self.get_command_help('list'), file=self.stderr)
return 2
date_from = datetime.combine(_date, time.min)
@ -255,13 +257,13 @@ class Boobcoming(ReplApplication):
"""
if not _id:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
event = self.get_object(_id, 'get_event')
if not event:
print >>self.stderr, 'Upcoming event not found: %s' % _id
print('Upcoming event not found: %s' % _id, file=self.stderr)
return 3
self.start_format()
@ -278,7 +280,7 @@ class Boobcoming(ReplApplication):
Export event in ICALENDAR format
"""
if not line:
print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('export')
print('This command takes at leat one argument: %s' % self.get_command_help('export'), file=self.stderr)
return 2
_file, args = self.parse_command_args(line, 2, req_n=1)
@ -306,7 +308,7 @@ class Boobcoming(ReplApplication):
event = self.get_object(_id, 'get_event')
if not event:
print >>self.stderr, 'Upcoming event not found: %s' % _id
print('Upcoming event not found: %s' % _id, file=self.stderr)
return 3
l.append(event)
@ -328,7 +330,7 @@ class Boobcoming(ReplApplication):
ID is the identifier of the event.
"""
if not line:
print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('attends')
print('This command takes at leat one argument: %s' % self.get_command_help('attends'), file=self.stderr)
return 2
args = self.parse_command_args(line, 1, req_n=1)
@ -346,7 +348,7 @@ class Boobcoming(ReplApplication):
"""
if not line:
print >>self.stderr, 'This command takes at leat one argument: %s' % self.get_command_help('unattends')
print('This command takes at leat one argument: %s' % self.get_command_help('unattends'), file=self.stderr)
return 2
args = self.parse_command_args(line, 1, req_n=1)

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2011 Laurent Bachelier
#

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from decimal import Decimal
@ -86,9 +87,9 @@ class Boobill(ReplApplication):
self.bcall_error_handler(backend, error, backtrace)
if len(more_results) > 0:
print >>self.stderr, 'Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results))
print('Hint: There are more results available for %s (use option -n or count command)' % (', '.join(more_results)), file=self.stderr)
for backend in not_implemented:
print >>self.stderr, u'Error(%s): This feature is not supported yet by this backend.' % backend.name
print(u'Error(%s): This feature is not supported yet by this backend.' % backend.name, file=self.stderr)
def do_subscriptions(self, line):
"""
@ -183,7 +184,7 @@ class Boobill(ReplApplication):
id, dest = self.parse_command_args(line, 2, 1)
id, backend_name = self.parse_id(id)
if not id:
print >>self.stderr, 'Error: please give a bill ID (hint: use bills command)'
print('Error: please give a bill ID (hint: use bills command)', file=self.stderr)
return 2
names = (backend_name,) if backend_name is not None else None
@ -204,13 +205,13 @@ class Boobill(ReplApplication):
for backend, buf in self.do('download_bill', id, backends=names):
if buf:
if dest == "-":
print buf
print(buf)
else:
try:
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
print >>self.stderr, 'Unable to write bill in "%s": %s' % (dest, e)
print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
@ -221,13 +222,13 @@ class Boobill(ReplApplication):
for backend2, buf in self.do('download_bill', bill.id, backends=names):
if buf:
if dest == "-":
print buf
print(buf)
else:
try:
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
print >>self.stderr, 'Unable to write bill in "%s": %s' % (dest, e)
print('Unable to write bill in "%s": %s' % (dest, e), file=self.stderr)
return 1
return

View file

@ -17,8 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.lyrics import CapLyrics
from weboob.capabilities.base import empty
@ -84,7 +83,7 @@ class Booblyrics(ReplApplication):
songlyrics = self.get_object(id, 'get_lyrics')
if not songlyrics:
print >>self.stderr, 'Song lyrics not found: %s' % id
print('Song lyrics not found: %s' % id, file=self.stderr)
return 3
self.start_format()

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os
import datetime
@ -288,14 +289,14 @@ class Boobmsg(ReplApplication):
results[backend.name] = [field]
for name, fields in results.iteritems():
print ':: %s ::' % name
print(':: %s ::' % name)
for f in fields:
if f.flags & f.FIELD_HTML:
value = html2text(f.value)
else:
value = f.value
print '%s: %s' % (f.label, value)
print ''
print('%s: %s' % (f.label, value))
print('')
def do_post(self, line):
"""
@ -347,7 +348,7 @@ class Boobmsg(ReplApplication):
self.bcall_errors_handler(errors)
else:
if self.interactive:
print 'Message sent sucessfully to %s' % receiver
print('Message sent sucessfully to %s' % receiver)
threads = []
messages = []
@ -430,7 +431,7 @@ class Boobmsg(ReplApplication):
"""
message = None
if len(arg) == 0:
print >>self.stderr, 'Please give a message ID.'
print('Please give a message ID.', file=self.stderr)
return 2
try:
@ -447,7 +448,7 @@ class Boobmsg(ReplApplication):
self.weboob.do('set_message_read', message, backends=message.backend)
return
else:
print >>self.stderr, 'Message not found'
print('Message not found', file=self.stderr)
return 3
def do_profile(self, id):
@ -475,7 +476,7 @@ class Boobmsg(ReplApplication):
"""
photo_cmd = self.config.get('photo_viewer')
if photo_cmd is None:
print >>self.stderr, "Configuration error: photo_viewer is undefined"
print("Configuration error: photo_viewer is undefined", file=self.stderr)
return
_id, backend_name = self.parse_id(id, unique_backend=True)

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.library import CapBook, Book
from weboob.tools.application.repl import ReplApplication
from weboob.tools.application.formatters.iformatter import PrettyFormatter
@ -62,7 +64,7 @@ class Boobooks(ReplApplication):
id, backend_name = self.parse_id(id)
if not id:
print >>self.stderr, 'Error: please give a book ID (hint: use ls command)'
print('Error: please give a book ID (hint: use ls command)', file=self.stderr)
return 2
names = (backend_name,) if backend_name is not None else None

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.base import empty
from weboob.capabilities.gauge import CapGauge, SensorNotFound
@ -110,7 +111,7 @@ class Boobsize(ReplApplication):
def bcall_error_handler(self, backend, error, backtrace):
if isinstance(error, SensorNotFound):
msg = unicode(error) or 'Sensor not found (hint: try details command)'
print >>self.stderr, 'Error(%s): %s' % (backend.name, msg)
print('Error(%s): %s' % (backend.name, msg), file=self.stderr)
else:
return ReplApplication.bcall_error_handler(self, backend, error, backtrace)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from datetime import timedelta
from email import message_from_string, message_from_file
@ -156,7 +157,7 @@ class BoobTracker(ReplApplication):
elif len(path) > 0:
query.project = path[0]
else:
print >>self.stderr, 'Please enter a project name'
print('Please enter a project name', file=self.stderr)
return 1
query.author = self.options.author
@ -183,12 +184,12 @@ class BoobTracker(ReplApplication):
Get an issue and display it.
"""
if not line:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('get', short=True)
print('This command takes an argument: %s' % self.get_command_help('get', short=True), file=self.stderr)
return 2
issue = self.get_object(line, 'get_issue')
if not issue:
print >>self.stderr, 'Issue not found: %s' % line
print('Issue not found: %s' % line, file=self.stderr)
return 3
self.format(issue)
@ -226,7 +227,7 @@ class BoobTracker(ReplApplication):
try:
hours = float(hours)
except ValueError:
print >>self.stderr, 'Error: HOURS parameter may be a float'
print('Error: HOURS parameter may be a float', file=self.stderr)
return 1
id, backend_name = self.parse_id(id, unique_backend=True)
@ -398,8 +399,8 @@ class BoobTracker(ReplApplication):
try:
issue = backend.post_issue(issue)
print 'Issue %s %s' % (self.formatter.colored(issue.fullid, 'red', 'bold'),
'updated' if edit else 'created')
print('Issue %s %s' % (self.formatter.colored(issue.fullid, 'red', 'bold'),
'updated' if edit else 'created'))
if edit:
self.format(issue)
elif email_to:
@ -447,7 +448,7 @@ Weboob Team
--status STATUS
"""
if not line.strip():
print 'Please give the project name'
print('Please give the project name')
return 1
project, backend_name = self.parse_id(line, unique_backend=True)
@ -481,7 +482,7 @@ Weboob Team
_id, key, value = self.parse_command_args(line, 3, 1)
issue = self.get_object(_id, 'get_issue')
if not issue:
print >>self.stderr, 'Issue not found: %s' % _id
print('Issue not found: %s' % _id, file=self.stderr)
return 3
return self.edit_issue(issue, edit=True)
@ -499,4 +500,4 @@ Weboob Team
Attach a file to an issue (Not implemented yet).
"""
print >>self.stderr, 'Not implemented yet.'
print('Not implemented yet.', file=self.stderr)

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from datetime import datetime
@ -230,11 +230,11 @@ class Cineoob(ReplApplication):
person1 = self.get_object(id1, 'get_person', caps=CapCinema)
if not person1:
print >>self.stderr, 'Person not found: %s' % id1
print('Person not found: %s' % id1, file=self.stderr)
return 3
person2 = self.get_object(id2, 'get_person', caps=CapCinema)
if not person2:
print >>self.stderr, 'Person not found: %s' % id2
print('Person not found: %s' % id2, file=self.stderr)
return 3
initial_count = self.options.count
@ -263,11 +263,11 @@ class Cineoob(ReplApplication):
movie1 = self.get_object(id1, 'get_movie', caps=CapCinema)
if not movie1:
print >>self.stderr, 'Movie not found: %s' % id1
print('Movie not found: %s' % id1, file=self.stderr)
return 3
movie2 = self.get_object(id2, 'get_movie', caps=CapCinema)
if not movie2:
print >>self.stderr, 'Movie not found: %s' % id2
print('Movie not found: %s' % id2, file=self.stderr)
return 3
initial_count = self.options.count
@ -294,7 +294,7 @@ class Cineoob(ReplApplication):
movie = self.get_object(id, 'get_movie', caps=CapCinema)
if not movie:
print >>self.stderr, 'Movie not found: %s' % id
print('Movie not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -309,7 +309,7 @@ class Cineoob(ReplApplication):
person = self.get_object(id, 'get_person', caps=CapCinema)
if not person:
print >>self.stderr, 'Person not found: %s' % id
print('Person not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -356,7 +356,7 @@ class Cineoob(ReplApplication):
movie = self.get_object(movie_id, 'get_movie', caps=CapCinema)
if not movie:
print >>self.stderr, 'Movie not found: %s' % id
print('Movie not found: %s' % id, file=self.stderr)
return 3
for backend, person in self.do('iter_movie_persons', movie.id, role, backends=movie.backend, caps=CapCinema):
@ -373,7 +373,7 @@ class Cineoob(ReplApplication):
person = self.get_object(person_id, 'get_person', caps=CapCinema)
if not person:
print >>self.stderr, 'Person not found: %s' % id
print('Person not found: %s' % id, file=self.stderr)
return 3
for backend, movie in self.do('iter_person_movies', person.id, role, backends=person.backend, caps=CapCinema):
@ -387,7 +387,7 @@ class Cineoob(ReplApplication):
"""
person = self.get_object(person_id, 'get_person', ('name', 'biography'), caps=CapCinema)
if not person:
print >>self.stderr, 'Person not found: %s' % person_id
print('Person not found: %s' % person_id, file=self.stderr)
return 3
self.start_format()
@ -411,7 +411,7 @@ class Cineoob(ReplApplication):
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
if not movie:
print >>self.stderr, 'Movie not found: %s' % id
print('Movie not found: %s' % id, file=self.stderr)
return 3
# i would like to clarify with fillobj but how could i fill the movie AND choose the country ?
@ -419,7 +419,7 @@ class Cineoob(ReplApplication):
if not empty(release):
movie.all_release_dates = u'%s' % (release)
else:
print >>self.stderr, 'Movie releases not found for %s' % movie.original_title
print('Movie releases not found for %s' % movie.original_title, file=self.stderr)
return 3
self.start_format()
self.format(movie)
@ -440,7 +440,7 @@ class Cineoob(ReplApplication):
torrent = self.get_object(id, 'get_torrent', caps=CapTorrent)
if not torrent:
print >>self.stderr, 'Torrent not found: %s' % id
print('Torrent not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -472,26 +472,26 @@ class Cineoob(ReplApplication):
for backend, buf in self.do('get_torrent_file', _id, backends=backend_name, caps=CapTorrent):
if buf:
if dest == '-':
print buf
print(buf)
else:
try:
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
print >>self.stderr, 'Unable to write .torrent in "%s": %s' % (dest, e)
print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
except CallErrors as errors:
for backend, error, backtrace in errors:
if isinstance(error, MagnetOnly):
print >>self.stderr, u'Error(%s): No direct URL available, ' \
print(u'Error(%s): No direct URL available, ' \
u'please provide this magnet URL ' \
u'to your client:\n%s' % (backend, error.magnet)
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
return 4
else:
self.bcall_error_handler(backend, error, backtrace)
print >>self.stderr, 'Torrent "%s" not found' % id
print('Torrent "%s" not found' % id, file=self.stderr)
return 3
@defaultcount(10)
@ -518,7 +518,7 @@ class Cineoob(ReplApplication):
"""
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
if not movie:
print >>self.stderr, 'Movie not found: %s' % id
print('Movie not found: %s' % id, file=self.stderr)
return 3
pattern = movie.original_title
@ -547,7 +547,7 @@ class Cineoob(ReplApplication):
subtitle = self.get_object(id, 'get_subtitle', caps=CapCinema)
if not subtitle:
print >>self.stderr, 'Subtitle not found: %s' % id
print('Subtitle not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -578,17 +578,17 @@ class Cineoob(ReplApplication):
for backend, buf in self.do('get_subtitle_file', _id, backends=backend_name, caps=CapSubtitle):
if buf:
if dest == '-':
print buf
print(buf)
else:
try:
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
print >>self.stderr, 'Unable to write file in "%s": %s' % (dest, e)
print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
print >>self.stderr, 'Subtitle "%s" not found' % id
print('Subtitle "%s" not found' % id, file=self.stderr)
return 3
@defaultcount(10)
@ -657,7 +657,7 @@ class Cineoob(ReplApplication):
language, id = self.parse_command_args(line, 2, 2)
movie = self.get_object(id, 'get_movie', ('original_title'), caps=CapCinema)
if not movie:
print >>self.stderr, 'Movie not found: %s' % id
print('Movie not found: %s' % id, file=self.stderr)
return 3
pattern = movie.original_title

View file

@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
from .comparoob import Comparoob

View file

@ -17,9 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.pricecomparison import CapPriceComparison
from weboob.tools.html import html2text
@ -108,18 +106,18 @@ class Comparoob(ReplApplication):
product = None
if len(products) == 0:
print >>self.stderr, 'Error: no product found with this pattern'
print('Error: no product found with this pattern', file=self.stderr)
return 1
elif len(products) == 1:
product = products[0]
else:
print 'What product do you want to compare?'
print('What product do you want to compare?')
for i, p in enumerate(products):
print ' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, p.name)
print(' %s%2d)%s %s' % (self.BOLD, i+1, self.NC, p.name))
r = int(self.ask(' Select a product', regexp='\d+'))
while product is None:
if r <= 0 or r > len(products):
print 'Error: Please enter a valid ID'
print('Error: Please enter a valid ID')
continue
product = products[r-1]
@ -146,12 +144,12 @@ class Comparoob(ReplApplication):
Get information about a product.
"""
if not _id:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
price = self.get_object(_id, 'get_price')
if not price:
print >>self.stderr, 'Price not found: %s' % _id
print('Price not found: %s' % _id, file=self.stderr)
return 3
self.start_format()

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import codecs
@ -99,7 +99,7 @@ class Cookboob(ReplApplication):
"""
recipe = self.get_object(id, 'get_recipe')
if not recipe:
print >>self.stderr, 'Recipe not found: %s' % id
print('Recipe not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -132,7 +132,7 @@ class Cookboob(ReplApplication):
if recipe:
xmlstring = recipe.toKrecipesXml(backend_name or None)
if dest == '-':
print xmlstring
print(xmlstring)
else:
if not dest.endswith('.kreml'):
dest += '.kreml'
@ -140,10 +140,10 @@ class Cookboob(ReplApplication):
with codecs.open(dest, 'w', 'utf-8') as f:
f.write(xmlstring)
except IOError as e:
print >>self.stderr, 'Unable to write .kreml in "%s": %s' % (dest, e)
print('Unable to write .kreml in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
print >>self.stderr, 'Recipe "%s" not found' % id
print('Recipe "%s" not found' % id, file=self.stderr)
return 3
@defaultcount(10)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.housing import CapHousing, Query
from weboob.tools.application.repl import ReplApplication, defaultcount
@ -104,7 +105,7 @@ class Flatboob(ReplApplication):
query.cities = []
while pattern:
if len(query.cities) > 0:
print '\n%sSelected cities:%s %s' % (self.BOLD, self.NC, ', '.join([c.name for c in query.cities]))
print('\n%sSelected cities:%s %s' % (self.BOLD, self.NC, ', '.join([c.name for c in query.cities])))
pattern = self.ask('Enter a city pattern (or empty to stop)', default='')
if not pattern:
break
@ -114,7 +115,7 @@ class Flatboob(ReplApplication):
cities.append(city)
if len(cities) == 0:
print ' Not found!'
print(' Not found!')
continue
if len(cities) == 1:
if city in query.cities:
@ -126,7 +127,7 @@ class Flatboob(ReplApplication):
r = 'notempty'
while r != '':
for i, city in enumerate(cities):
print ' %s%2d)%s [%s] %s' % (self.BOLD, i+1, self.NC, 'x' if city in query.cities else ' ', city.name)
print(' %s%2d)%s [%s] %s' % (self.BOLD, i+1, self.NC, 'x' if city in query.cities else ' ', city.name))
r = self.ask(' Select cities (or empty to stop)', regexp='(\d+|)', default='')
if not r.isdigit():
continue
@ -142,10 +143,10 @@ class Flatboob(ReplApplication):
r = 'notempty'
while r != '':
for good in Query.HOUSE_TYPES.values:
print ' %s%2d)%s [%s] %s' % (self.BOLD,
print(' %s%2d)%s [%s] %s' % (self.BOLD,
Query.HOUSE_TYPES.index[good] + 1,
self.NC,
'x' if good in query.house_types else ' ', good)
'x' if good in query.house_types else ' ', good))
r = self.ask(' Select type of house (or empty to stop)', regexp='(\d+|)', default='')
if not r.isdigit():
continue
@ -160,14 +161,14 @@ class Flatboob(ReplApplication):
_type = None
while _type not in [query.TYPE_RENT, query.TYPE_SALE]:
print ' %s%2d)%s %s' % (self.BOLD,
print(' %s%2d)%s %s' % (self.BOLD,
query.TYPE_RENT,
self.NC,
"Rent")
print ' %s%2d)%s %s' % (self.BOLD,
"Rent"))
print(' %s%2d)%s %s' % (self.BOLD,
query.TYPE_SALE,
self.NC,
"Sale")
"Sale"))
_type = self.ask_int('Type of query')
query.type = _type
@ -207,20 +208,20 @@ class Flatboob(ReplApplication):
"""
queries = self.config.get('queries')
if not queries:
print >>self.stderr, 'There is no saved queries'
print('There is no saved queries', file=self.stderr)
return 2
if not query_name:
for name in queries.keys():
print ' %s* %s %s' % (self.BOLD,
print(' %s* %s %s' % (self.BOLD,
self.NC,
name)
name))
query_name = self.ask('Which one')
if query_name in queries:
self.complete_search(queries.get(query_name))
else:
print >>self.stderr, 'Unknown query'
print('Unknown query', file=self.stderr)
return 2
def complete_info(self, text, line, *ignored):
@ -235,12 +236,12 @@ class Flatboob(ReplApplication):
Get information about a housing.
"""
if not _id:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
housing = self.get_object(_id, 'get_housing')
if not housing:
print >>self.stderr, 'Housing not found: %s' % _id
print('Housing not found: %s' % _id, file=self.stderr)
return 3
self.start_format()

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os
from re import search, sub
@ -67,7 +67,7 @@ class Galleroob(ReplApplication):
List galleries matching a PATTERN.
"""
if not pattern:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('search', short=True)
print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr)
return 2
self.start_format(pattern=pattern)
@ -97,14 +97,14 @@ class Galleroob(ReplApplication):
gallery = result
if not gallery:
print >>self.stderr, 'Gallery not found: %s' % _id
print('Gallery not found: %s' % _id, file=self.stderr)
return 3
backend.fillobj(gallery, ('title',))
if dest is None:
dest = sub('/', ' ', gallery.title)
print "Downloading to %s" % dest
print("Downloading to %s" % dest)
try:
os.mkdir(dest)
@ -122,7 +122,7 @@ class Galleroob(ReplApplication):
if img.data is None:
backend.fillobj(img, ('url', 'data'))
if img.data is None:
print >>self.stderr, "Couldn't get page %d, exiting" % i
print("Couldn't get page %d, exiting" % i, file=self.stderr)
break
ext = search(r"\.([^\.]{1,5})$", img.url)
@ -132,7 +132,7 @@ class Galleroob(ReplApplication):
ext = "jpg"
name = '%03d.%s' % (i, ext)
print 'Writing file %s' % name
print('Writing file %s' % name)
with open(name, 'w') as f:
f.write(img.data)
@ -149,7 +149,7 @@ class Galleroob(ReplApplication):
gallery = self.get_object(_id, 'get_gallery')
if not gallery:
print >>self.stderr, 'Gallery not found: %s' % _id
print('Gallery not found: %s' % _id, file=self.stderr)
return 3
self.start_format()

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.geolocip import CapGeolocIp
from weboob.tools.application.repl import ReplApplication
@ -36,7 +36,7 @@ class Geolooc(ReplApplication):
def main(self, argv):
if len(argv) < 2:
print >>self.stderr, 'Syntax: %s ipaddr' % argv[0]
print('Syntax: %s ipaddr' % argv[0], file=self.stderr)
return 2
for backend, location in self.do('get_location', argv[1]):

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.job import CapJob
from weboob.tools.application.repl import ReplApplication, defaultcount
@ -122,13 +123,13 @@ class Handjoob(ReplApplication):
Get information about an advert.
"""
if not _id:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
job_advert = self.get_object(_id, 'get_job_advert')
if not job_advert:
print >>self.stderr, 'Job advert not found: %s' % _id
print('Job advert not found: %s' % _id, file=self.stderr)
return 3
self.start_format()

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from copy import copy
@ -87,11 +88,11 @@ class HaveDate(Boobmsg):
_id, backend_name = self.parse_id(id, unique_backend=True)
for backend, query in self.do('send_query', _id, backends=backend_name):
print '%s' % query.message
print('%s' % query.message)
def edit_optims(self, backend_names, optims_names, stop=False):
if optims_names is None:
print >>self.stderr, 'Error: missing parameters.'
print('Error: missing parameters.', file=self.stderr)
return 2
for optim_name in optims_names.split():
@ -101,29 +102,29 @@ class HaveDate(Boobmsg):
backends_optims[backend.name] = optim
for backend_name, optim in backends_optims.iteritems():
if len(optim.CONFIG) == 0:
print '%s.%s does not require configuration.' % (backend_name, optim_name)
print('%s.%s does not require configuration.' % (backend_name, optim_name))
continue
was_running = optim.is_running()
if stop and was_running:
print 'Stopping %s: %s' % (optim_name, backend_name)
print('Stopping %s: %s' % (optim_name, backend_name))
optim.stop()
params = optim.get_config()
if params is None:
params = {}
print 'Configuration of %s.%s' % (backend_name, optim_name)
print '-----------------%s-%s' % ('-' * len(backend_name), '-' * len(optim_name))
print('Configuration of %s.%s' % (backend_name, optim_name))
print('-----------------%s-%s' % ('-' * len(backend_name), '-' * len(optim_name)))
for key, value in optim.CONFIG.iteritems():
params[key] = self.ask(value, default=params[key] if (key in params) else value.default)
optim.set_config(params)
if stop and was_running:
print 'Starting %s: %s' % (optim_name, backend_name)
print('Starting %s: %s' % (optim_name, backend_name))
optim.start()
def optims(self, function, backend_names, optims, store=True):
if optims is None:
print >>self.stderr, 'Error: missing parameters.'
print('Error: missing parameters.', file=self.stderr)
return 2
for optim_name in optims.split():
@ -205,7 +206,7 @@ class HaveDate(Boobmsg):
if backend_name == '*':
backend_name = None
elif backend_name is not None and not backend_name in [b.name for b in self.enabled_backends]:
print >>self.stderr, 'Error: No such backend "%s"' % backend_name
print('Error: No such backend "%s"' % backend_name, file=self.stderr)
return 1
if cmd == 'start':
@ -245,7 +246,7 @@ class HaveDate(Boobmsg):
line.append((b, status))
self.format(tuple(line))
return
print >>self.stderr, "No such command '%s'" % cmd
print("No such command '%s'" % cmd, file=self.stderr)
return 1
def do_events(self, line):

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from email.mime.text import MIMEText
from smtplib import SMTP
@ -118,7 +119,7 @@ class Monboob(ReplApplication):
if self.config.get('interval') < 1:
raise ValueError()
except ValueError:
print >>self.stderr, 'Configuration error: interval must be an integer >0.'
print('Configuration error: interval must be an integer >0.', file=self.stderr)
return 1
try:
@ -126,7 +127,7 @@ class Monboob(ReplApplication):
if self.config.get('html') not in (0, 1):
raise ValueError()
except ValueError:
print >>self.stderr, 'Configuration error: html must be 0 or 1.'
print('Configuration error: html must be 0 or 1.', file=self.stderr)
return 2
return ReplApplication.main(self, argv)
@ -189,7 +190,7 @@ class Monboob(ReplApplication):
break
if len(content) == 0:
print >>self.stderr, 'Unable to send an empty message'
print('Unable to send an empty message', file=self.stderr)
return 1
# remove signature
@ -209,7 +210,7 @@ class Monboob(ReplApplication):
bname, id = reply_to.split('.', 1)
thread_id, parent_id = id.rsplit('.', 1)
except ValueError:
print >>self.stderr, 'In-Reply-To header might be in form <backend.thread_id.message_id>'
print('In-Reply-To header might be in form <backend.thread_id.message_id>', file=self.stderr)
return 1
# Default use the To header field to know the backend to use.
@ -219,11 +220,11 @@ class Monboob(ReplApplication):
try:
backend = self.weboob.backend_instances[bname]
except KeyError:
print >>self.stderr, 'Backend %s not found' % bname
print('Backend %s not found' % bname, file=self.stderr)
return 1
if not backend.has_caps(CapMessagesPost):
print >>self.stderr, 'The backend %s does not implement CapMessagesPost' % bname
print('The backend %s does not implement CapMessagesPost' % bname, file=self.stderr)
return 1
thread = Thread(thread_id)

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.base import empty
from weboob.capabilities.parcel import CapParcel, Parcel, ParcelNotFound
@ -105,7 +105,7 @@ class Parceloob(ReplApplication):
"""
parcel = self.get_object(line, 'get_parcel_tracking')
if not parcel:
print >>self.stderr, 'Error: the parcel "%s" is not found' % line
print('Error: the parcel "%s" is not found' % line, file=self.stderr)
return 2
parcels = set(self.storage.get('tracking', default=[]))
@ -113,7 +113,7 @@ class Parceloob(ReplApplication):
self.storage.set('tracking', list(parcels))
self.storage.save()
print 'Parcel "%s" has been tracked.' % parcel.fullid
print('Parcel "%s" has been tracked.' % parcel.fullid)
def do_untrack(self, line):
"""
@ -137,22 +137,22 @@ class Parceloob(ReplApplication):
parcel = False
if not parcel:
print >>self.stderr, 'Error: the parcel "%s" is not found. Did you provide the full id@backend parameter?' % line
print('Error: the parcel "%s" is not found. Did you provide the full id@backend parameter?' % line, file=self.stderr)
return 2
try:
parcels.remove(parcel.fullid)
except KeyError:
print >>self.stderr, "Error: parcel \"%s\" wasn't tracked" % parcel.fullid
print("Error: parcel \"%s\" wasn't tracked" % parcel.fullid, file=self.stderr)
return 2
self.storage.set('tracking', list(parcels))
self.storage.save()
if removed:
print "Parcel \"%s\" isn't tracked anymore." % line
print("Parcel \"%s\" isn't tracked anymore." % line)
else:
print "Parcel \"%s\" isn't tracked anymore." % parcel.fullid
print("Parcel \"%s\" isn't tracked anymore." % parcel.fullid)
def do_status(self, line):
"""
@ -184,7 +184,7 @@ class Parceloob(ReplApplication):
"""
parcel = self.get_object(id, 'get_parcel_tracking', [])
if not parcel:
print >>self.stderr, 'Error: parcel not found'
print('Error: parcel not found', file=self.stderr)
return 2
self.start_format()

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2011 Laurent Bachelier
#

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os
import codecs
@ -49,14 +50,14 @@ class Pastoob(ReplApplication):
Get information about pastes.
"""
if not line:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
self.start_format()
for _id in line.split(' '):
paste = self.get_object(_id, 'get_paste', ['id', 'title', 'language', 'public', 'contents'])
if not paste:
print >>self.stderr, 'Paste not found: %s' % _id
print('Paste not found: %s' % _id, file=self.stderr)
self.format(paste)
@ -80,22 +81,22 @@ class Pastoob(ReplApplication):
def _get_op(self, _id, binary, command='get'):
if not _id:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help(command, short=True)
print('This command takes an argument: %s' % self.get_command_help(command, short=True), file=self.stderr)
return 2
try:
paste = self.get_object(_id, 'get_paste', ['contents'])
except PasteNotFound:
print >>self.stderr, 'Paste not found: %s' % _id
print('Paste not found: %s' % _id, file=self.stderr)
return 3
if not paste:
print >>self.stderr, 'Unable to handle paste: %s' % _id
print('Unable to handle paste: %s' % _id, file=self.stderr)
return 1
if binary:
if self.interactive:
if not self.ask('The console may become messed up. Are you sure you want to show a binary file on your terminal?', default=False):
print >>self.stderr, 'Aborting.'
print('Aborting.', file=self.stderr)
return 1
output = self.stdout
output.write(paste.contents.decode('base64'))
@ -135,7 +136,7 @@ class Pastoob(ReplApplication):
else:
contents = self.acquire_input()
if not len(contents):
print >>self.stderr, 'Empty paste, aborting.'
print('Empty paste, aborting.', file=self.stderr)
return 1
else:
@ -147,7 +148,7 @@ class Pastoob(ReplApplication):
with m as fp:
contents = fp.read()
except IOError as e:
print >>self.stderr, 'Unable to open file "%s": %s' % (filename, e.strerror)
print('Unable to open file "%s": %s' % (filename, e.strerror), file=self.stderr)
return 1
if binary:
@ -164,7 +165,7 @@ class Pastoob(ReplApplication):
if len(backends):
backend = choice(backends[max(backends.keys())])
else:
print >>self.stderr, 'No suitable backend found.'
print('No suitable backend found.', file=self.stderr)
return 1
p = backend.new_paste(_id=None)
@ -175,7 +176,7 @@ class Pastoob(ReplApplication):
p.title = os.path.basename(filename)
p.contents = contents
backend.post_paste(p, max_age=params['max_age'])
print 'Successfuly posted paste: %s' % p.page_url
print('Successfuly posted paste: %s' % p.page_url)
def get_params(self):
return {'public': self.options.public,

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import time
import logging
@ -208,7 +210,7 @@ class MessagesManager(QWidget):
self.ui.profileButton.hide()
def _profilePressed(self):
print self.thread.id
print(self.thread.id)
self.emit(SIGNAL('display_contact'), self.thread.id)
def displayReply(self):

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QFileDialog
@ -82,6 +83,6 @@ class Subtitle(QFrame):
with open(dest, 'w') as f:
f.write(data)
except IOError as e:
print >>self.stderr, 'Unable to write subtitle file in "%s": %s' % (dest, e)
print('Unable to write subtitle file in "%s": %s' % (dest, e), file=self.stderr)
return 1
return

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from PyQt4.QtCore import Qt, SIGNAL
from PyQt4.QtGui import QFrame, QFileDialog
@ -86,6 +87,6 @@ class Torrent(QFrame):
with open(unicode(dest), 'w') as f:
f.write(data)
except IOError as e:
print >>self.stderr, 'Unable to write .torrent in "%s": %s' % (dest, e)
print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr)
return 1
return

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import urllib
import codecs
@ -107,6 +109,6 @@ class Recipe(QFrame):
with codecs.open(dest, 'w', 'utf-8') as f:
f.write(data)
except IOError as e:
print >>self.stderr, 'Unable to write Krecipe file in "%s": %s' % (dest, e)
print('Unable to write Krecipe file in "%s": %s' % (dest, e), file=self.stderr)
return 1
return

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from PyQt4.QtGui import QWidget, QTreeWidgetItem, QImage, QIcon, QPixmap
from PyQt4.QtCore import SIGNAL, Qt
@ -101,7 +103,7 @@ class EventsWidget(QWidget):
if s == event.type:
found = True
if not found:
print event.type
print(event.type)
self.ui.typeBox.addItem(event.type.capitalize(), event.type)
if event.type == self.event_filter:
self.ui.typeBox.setCurrentIndex(self.ui.typeBox.count()-1)

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#

View file

@ -17,6 +17,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import subprocess
import os
import re
@ -166,18 +168,18 @@ class Radioob(ReplApplication):
_id, dest = self.parse_command_args(line, 2, 1)
audio = self.get_object(_id, 'get_audio', ['url'])
if not audio:
print >>self.stderr, 'Audio file not found: %s' % _id
print('Audio file not found: %s' % _id, file=self.stderr)
return 3
if not audio.url:
print >>self.stderr, 'Error: the direct URL is not available.'
print('Error: the direct URL is not available.', file=self.stderr)
return 4
def check_exec(executable):
with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0:
print >>self.stderr, 'Please install "%s"' % executable
print('Please install "%s"' % executable, file=self.stderr)
return False
return True
@ -224,7 +226,7 @@ class Radioob(ReplApplication):
"""
_id, stream_id = self.parse_command_args(line, 2, 1)
if not _id:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True)
print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr)
return 2
try:
@ -235,14 +237,14 @@ class Radioob(ReplApplication):
obj = self.retrieve_obj(_id)
if obj is None:
print >>self.stderr, 'No object matches with this id:', _id
print('No object matches with this id:', _id, file=self.stderr)
return 3
if isinstance(obj, Radio):
try:
streams = [obj.streams[stream_id]]
except IndexError:
print >>self.stderr, 'Stream %d not found' % stream_id
print('Stream %d not found' % stream_id, file=self.stderr)
return 1
elif isinstance(obj, BaseAudio):
streams = [obj]
@ -251,7 +253,7 @@ class Radioob(ReplApplication):
streams = obj.tracks_list
if len(streams) == 0:
print >>self.stderr, 'Radio or Audio file not found:', _id
print('Radio or Audio file not found:', _id, file=self.stderr)
return 3
try:
@ -289,7 +291,7 @@ class Radioob(ReplApplication):
self.player.play(stream, player_name=player_name, player_args=media_player_args)
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
print '%s\nRadio URL: %s' % (e, stream.url)
print('%s\nRadio URL: %s' % (e, stream.url))
def retrieve_obj(self, _id):
obj = None
@ -316,7 +318,7 @@ class Radioob(ReplApplication):
"""
if not line:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
return 2
cmd, args = self.parse_command_args(line, 2, req_n=1)
@ -326,11 +328,11 @@ class Radioob(ReplApplication):
audio = self.get_object(_id, 'get_audio')
if not audio:
print >>self.stderr, 'Audio file not found: %s' % _id
print('Audio file not found: %s' % _id, file=self.stderr)
return 3
if not audio.url:
print >>self.stderr, 'Error: the direct URL is not available.'
print('Error: the direct URL is not available.', file=self.stderr)
return 4
self.PLAYLIST.append(audio)
@ -342,11 +344,11 @@ class Radioob(ReplApplication):
audio_to_remove = self.get_object(_id, 'get_audio')
if not audio_to_remove:
print >>self.stderr, 'Audio file not found: %s' % _id
print('Audio file not found: %s' % _id, file=self.stderr)
return 3
if not audio_to_remove.url:
print >>self.stderr, 'Error: the direct URL is not available.'
print('Error: the direct URL is not available.', file=self.stderr)
return 4
for audio in self.PLAYLIST:
@ -369,7 +371,7 @@ class Radioob(ReplApplication):
self.cached_format(audio)
else:
print >>self.stderr, 'Playlist command only support "add", "remove", "display" and "export" arguments.'
print('Playlist command only support "add", "remove", "display" and "export" arguments.', file=self.stderr)
return 2
def complete_info(self, text, line, *ignored):
@ -384,7 +386,7 @@ class Radioob(ReplApplication):
Get information about a radio or an audio file.
"""
if not _id:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
obj = self.retrieve_obj(_id)
@ -395,7 +397,7 @@ class Radioob(ReplApplication):
self.set_formatter('playlist_tracks_list_info')
if obj is None:
print >>self.stderr, 'No object matches with this id:', _id
print('No object matches with this id:', _id, file=self.stderr)
return 3
self.format(obj)
@ -411,7 +413,7 @@ class Radioob(ReplApplication):
"""
if not pattern:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
return 2
cmd, args = self.parse_command_args(pattern, 2, req_n=1)
@ -446,7 +448,7 @@ class Radioob(ReplApplication):
self.format(playlist)
else:
print >>self.stderr, 'Search command only supports "radio", "song", "album" and "playlist" arguments.'
print('Search command only supports "radio", "song", "album" and "playlist" arguments.', file=self.stderr)
return 2
def do_ls(self, line):

View file

@ -17,8 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.subtitle import CapSubtitle
from weboob.capabilities.base import empty
@ -113,7 +112,7 @@ class Suboob(ReplApplication):
subtitle = self.get_object(id, 'get_subtitle')
if not subtitle:
print >>self.stderr, 'Subtitle not found: %s' % id
print('Subtitle not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -138,7 +137,7 @@ class Suboob(ReplApplication):
subtitle = self.get_object(id, 'get_subtitle')
if not subtitle:
print >>self.stderr, 'Subtitle not found: %s' % id
print('Subtitle not found: %s' % id, file=self.stderr)
return 3
if dest is None:
@ -156,10 +155,10 @@ class Suboob(ReplApplication):
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
print >>self.stderr, 'Unable to write file in "%s": %s' % (dest, e)
print('Unable to write file in "%s": %s' % (dest, e), file=self.stderr)
return 1
else:
print 'Saved to %s' % dest
print('Saved to %s' % dest)
return
@defaultcount(10)

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.translate import CapTranslate, TranslationFail, LanguageNotSupported
from weboob.tools.application.repl import ReplApplication
@ -114,5 +115,5 @@ class Translaboob(ReplApplication):
for backend, translation in self.do('translate', self.LANGUAGE[lan_from], self.LANGUAGE[lan_to], text):
self.format(translation)
except (TranslationFail, LanguageNotSupported) as error:
print >>self.stderr, error
print(error, file=self.stderr)
pass

View file

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2010-2011 Romain Bignon
#

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import datetime
@ -104,7 +105,7 @@ class Traveloob(ReplApplication):
if arrival:
arrival_id, backend_name2 = self.parse_id(arrival)
if backend_name and backend_name2 and backend_name != backend_name2:
print >>self.stderr, 'Departure and arrival aren\'t on the same backend'
print('Departure and arrival aren\'t on the same backend', file=self.stderr)
return 1
else:
arrival_id = backend_name2 = None
@ -120,8 +121,8 @@ class Traveloob(ReplApplication):
try:
date = self.parse_datetime(date)
except ValueError as e:
print >>self.stderr, 'Invalid datetime value: %s' % e
print >>self.stderr, 'Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".'
print('Invalid datetime value: %s' % e, file=self.stderr)
print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr)
return 1
for backend, departure in self.do('iter_station_departures', station_id, arrival_id, date, backends=backends):
@ -149,8 +150,8 @@ class Traveloob(ReplApplication):
filters.departure_time = self.parse_datetime(self.options.departure_time)
filters.arrival_time = self.parse_datetime(self.options.arrival_time)
except ValueError as e:
print >>self.stderr, 'Invalid datetime value: %s' % e
print >>self.stderr, 'Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".'
print('Invalid datetime value: %s' % e, file=self.stderr)
print('Please enter a datetime in form "yyyy-mm-dd HH:MM" or "HH:MM".', file=self.stderr)
return 1
for backend, route in self.do('iter_roadmap', departure, arrival, filters):

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import requests
import subprocess
@ -76,14 +77,14 @@ class Videoob(ReplApplication):
def download(self, video, dest, default=None):
if not video.url:
print >>self.stderr, 'Error: the direct URL is not available.'
print('Error: the direct URL is not available.', file=self.stderr)
return 4
def check_exec(executable):
with open('/dev/null', 'w') as devnull:
process = subprocess.Popen(['which', executable], stdout=devnull)
if process.wait() != 0:
print >>self.stderr, 'Please install "%s"' % executable
print('Please install "%s"' % executable, file=self.stderr)
return False
return True
@ -146,7 +147,7 @@ class Videoob(ReplApplication):
_id, dest = self.parse_command_args(line, 2, 1)
video = self.get_object(_id, 'get_video', ['url'])
if not video:
print >>self.stderr, 'Video not found: %s' % _id
print('Video not found: %s' % _id, file=self.stderr)
return 3
return self.download(video, dest)
@ -163,7 +164,7 @@ class Videoob(ReplApplication):
Play a video with a found player.
"""
if not line:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('play', short=True)
print('This command takes an argument: %s' % self.get_command_help('play', short=True), file=self.stderr)
return 2
ret = 0
@ -177,10 +178,10 @@ class Videoob(ReplApplication):
def play(self, video, _id):
if not video:
print >>self.stderr, 'Video not found: %s' % _id
print('Video not found: %s' % _id, file=self.stderr)
return 3
if not video.url:
print >>self.stderr, 'Error: the direct URL is not available.'
print('Error: the direct URL is not available.', file=self.stderr)
return 4
try:
player_name = self.config.get('media_player')
@ -190,7 +191,7 @@ class Videoob(ReplApplication):
'configuration file.')
self.player.play(video, player_name=player_name, player_args=media_player_args)
except (InvalidMediaPlayer, MediaPlayerNotFound) as e:
print '%s\nVideo URL: %s' % (e, video.url)
print('%s\nVideo URL: %s' % (e, video.url))
def complete_info(self, text, line, *ignored):
args = line.split(' ')
@ -204,14 +205,14 @@ class Videoob(ReplApplication):
Get information about a video.
"""
if not line:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('info', short=True)
print('This command takes an argument: %s' % self.get_command_help('info', short=True), file=self.stderr)
return 2
self.start_format()
for _id in line.split(' '):
video = self.get_object(_id, 'get_video')
if not video:
print >>self.stderr, 'Video not found: %s' % _id
print('Video not found: %s' % _id, file=self.stderr)
return 3
self.format(video)
@ -239,11 +240,11 @@ class Videoob(ReplApplication):
"""
if not self.interactive:
print >>self.stderr, 'This command can be used only in interactive mode.'
print('This command can be used only in interactive mode.', file=self.stderr)
return 1
if not line:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('playlist')
print('This command takes an argument: %s' % self.get_command_help('playlist'), file=self.stderr)
return 2
cmd, args = self.parse_command_args(line, 2, req_n=1)
@ -253,11 +254,11 @@ class Videoob(ReplApplication):
video = self.get_object(_id, 'get_video')
if not video:
print >>self.stderr, 'Video not found: %s' % _id
print('Video not found: %s' % _id, file=self.stderr)
return 3
if not video.url:
print >>self.stderr, 'Error: the direct URL is not available.'
print('Error: the direct URL is not available.', file=self.stderr)
return 4
self.PLAYLIST.append(video)
@ -267,11 +268,11 @@ class Videoob(ReplApplication):
video_to_remove = self.get_object(_id, 'get_video')
if not video_to_remove:
print >>self.stderr, 'Video not found: %s' % _id
print('Video not found: %s' % _id, file=self.stderr)
return 3
if not video_to_remove.url:
print >>self.stderr, 'Error: the direct URL is not available.'
print('Error: the direct URL is not available.', file=self.stderr)
return 4
for video in self.PLAYLIST:
@ -297,7 +298,7 @@ class Videoob(ReplApplication):
for video in self.PLAYLIST:
self.play(video, video.id)
else:
print >>self.stderr, 'Playlist command only support "add", "remove", "display", "download" and "export" arguments.'
print('Playlist command only support "add", "remove", "display", "download" and "export" arguments.', file=self.stderr)
return 2
def complete_nsfw(self, text, line, begidx, endidx):
@ -318,10 +319,10 @@ class Videoob(ReplApplication):
elif line == 'off':
self.nsfw = False
else:
print 'Invalid argument "%s".' % line
print('Invalid argument "%s".' % line)
return 2
else:
print "on" if self.nsfw else "off"
print("on" if self.nsfw else "off")
@defaultcount()
def do_search(self, pattern):
@ -331,7 +332,7 @@ class Videoob(ReplApplication):
Search for videos matching a PATTERN.
"""
if not pattern:
print >>self.stderr, 'This command takes an argument: %s' % self.get_command_help('search', short=True)
print('This command takes an argument: %s' % self.get_command_help('search', short=True), file=self.stderr)
return 2
self.change_path([u'search'])

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os
import tempfile
@ -53,7 +54,7 @@ class WebContentEdit(ReplApplication):
contents += [content for backend, content in self.do('get_content', _id, backends=backend_names) if content]
if len(contents) == 0:
print >>self.stderr, 'No contents found'
print('No contents found', file=self.stderr)
return 3
if self.stdin.isatty():
@ -92,10 +93,10 @@ class WebContentEdit(ReplApplication):
contents.remove(content)
if len(contents) == 0:
print >>self.stderr, 'No changes. Abort.'
print('No changes. Abort.', file=self.stderr)
return 1
print 'Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents))
print('Contents changed:\n%s' % ('\n'.join(' * %s' % content.id for content in contents)))
message = self.ask('Enter a commit message', default='')
minor = self.ask('Is this a minor edit?', default=False)
@ -119,7 +120,7 @@ class WebContentEdit(ReplApplication):
# stdin is not a tty
if len(contents) != 1:
print >>self.stderr, "Multiple ids not supported with pipe"
print("Multiple ids not supported with pipe", file=self.stderr)
return 2
message, minor = '', False
@ -149,7 +150,7 @@ class WebContentEdit(ReplApplication):
Display log of a page
"""
if not line:
print >>self.stderr, 'Error: please give a page ID'
print('Error: please give a page ID', file=self.stderr)
return 2
_id, backend_name = self.parse_id(line)
@ -168,7 +169,7 @@ class WebContentEdit(ReplApplication):
Get page contents
"""
if not line:
print >>self.stderr, 'Error: please give a page ID'
print('Error: please give a page ID', file=self.stderr)
return 2
_part_line = line.strip().split(' ')
@ -181,7 +182,7 @@ class WebContentEdit(ReplApplication):
_part_line.remove('-r')
if not _part_line:
print >>self.stderr, 'Error: please give a page ID'
print('Error: please give a page ID', file=self.stderr)
return 2
_id, backend_name = self.parse_id(" ".join(_part_line))

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os
import re
@ -52,7 +53,7 @@ class WeboobCfg(ReplApplication):
Add a backend.
"""
if not line:
print >>self.stderr, 'You must specify a module name. Hint: use the "modules" command.'
print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr)
return 2
name, options = self.parse_command_args(line, 2, 1)
if options:
@ -66,7 +67,7 @@ class WeboobCfg(ReplApplication):
try:
key, value = option.split('=', 1)
except ValueError:
print >>self.stderr, 'Parameters have to be formatted "key=value"'
print('Parameters have to be formatted "key=value"', file=self.stderr)
return 2
params[key] = value
@ -96,16 +97,16 @@ class WeboobCfg(ReplApplication):
try:
backend = self.weboob.get_backend(backend_name)
except KeyError:
print >>self.stderr, 'Error: backend "%s" not found.' % backend_name
print('Error: backend "%s" not found.' % backend_name, file=self.stderr)
return 1
if not backend.has_caps(CapAccount):
print >>self.stderr, 'Error: backend "%s" does not support accounts management' % backend_name
print('Error: backend "%s" does not support accounts management' % backend_name, file=self.stderr)
return 1
mail = self.acquire_input()
if not backend.confirm_account(mail):
print >>self.stderr, 'Error: Unable to confirm account creation'
print('Error: Unable to confirm account creation', file=self.stderr)
return 1
return 0
@ -141,14 +142,14 @@ class WeboobCfg(ReplApplication):
Remove a backend.
"""
if not self.weboob.backends_config.remove_backend(instance_name):
print >>self.stderr, 'Backend instance "%s" does not exist' % instance_name
print('Backend instance "%s" does not exist' % instance_name, file=self.stderr)
return 1
def _do_toggle(self, name, state):
try:
bname, items = self.weboob.backends_config.get_backend(name)
except KeyError:
print >>self.stderr, 'Backend instance "%s" does not exist' % name
print('Backend instance "%s" does not exist' % name, file=self.stderr)
return 1
self.weboob.backends_config.edit_backend(name, bname, {'_enabled': state})
@ -177,7 +178,7 @@ class WeboobCfg(ReplApplication):
try:
self.edit_backend(line)
except KeyError:
print >>self.stderr, 'Error: backend "%s" not found' % line
print('Error: backend "%s" not found' % line, file=self.stderr)
return 1
def do_modules(self, line):
@ -201,12 +202,12 @@ class WeboobCfg(ReplApplication):
Display information about a module.
"""
if not line:
print >>self.stderr, 'You must specify a module name. Hint: use the "modules" command.'
print('You must specify a module name. Hint: use the "modules" command.', file=self.stderr)
return 2
minfo = self.weboob.repositories.get_module_info(line)
if not minfo:
print >>self.stderr, 'Module "%s" does not exist.' % line
print('Module "%s" does not exist.' % line, file=self.stderr)
return 1
try:
@ -214,16 +215,16 @@ class WeboobCfg(ReplApplication):
except ModuleLoadError:
module = None
print '.------------------------------------------------------------------------------.'
print '| Module %-69s |' % minfo.name
print "+-----------------.------------------------------------------------------------'"
print '| Version | %s' % minfo.version
print '| Maintainer | %s' % minfo.maintainer
print '| License | %s' % minfo.license
print '| Description | %s' % minfo.description
print '| Capabilities | %s' % ', '.join(minfo.capabilities)
print '| Installed | %s%s' % (('yes' if module else 'no'), ' (new version available)' if self.weboob.repositories.versions.get(minfo.name) > minfo.version else '')
print '| Location | %s' % (minfo.url or os.path.join(minfo.path, minfo.name))
print('.------------------------------------------------------------------------------.')
print('| Module %-69s |' % minfo.name)
print("+-----------------.------------------------------------------------------------'")
print('| Version | %s' % minfo.version)
print('| Maintainer | %s' % minfo.maintainer)
print('| License | %s' % minfo.license)
print('| Description | %s' % minfo.description)
print('| Capabilities | %s' % ', '.join(minfo.capabilities))
print('| Installed | %s%s' % (('yes' if module else 'no'), ' (new version available)' if self.weboob.repositories.versions.get(minfo.name) > minfo.version else ''))
print('| Location | %s' % (minfo.url or os.path.join(minfo.path, minfo.name)))
if module:
first = True
for key, field in module.config.iteritems():
@ -231,12 +232,12 @@ class WeboobCfg(ReplApplication):
if not field.default is None:
value += ' (default: %s)' % field.default
if first:
print '| | '
print '| Configuration | %s: %s' % (key, value)
print('| | ')
print('| Configuration | %s: %s' % (key, value))
first = False
else:
print '| | %s: %s' % (key, value)
print "'-----------------'"
print('| | %s: %s' % (key, value))
print("'-----------------'")
def do_applications(self, line):
"""
@ -252,7 +253,7 @@ class WeboobCfg(ReplApplication):
m = regexp.match(root)
if m and '__init__.py' in files:
applications.add(m.group(1))
print ' '.join(sorted(applications)).encode('utf-8')
print(' '.join(sorted(applications)).encode('utf-8'))
def do_update(self, line):
"""

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.tools.application.repl import ReplApplication
@ -41,7 +41,7 @@ class WeboobCli(ReplApplication):
def main(self, argv):
if len(argv) < 3:
print >>self.stderr, "Syntax: %s capability method [args ..]" % argv[0]
print("Syntax: %s capability method [args ..]" % argv[0], file=self.stderr)
return 2
cap_s = argv[1]

View file

@ -17,6 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from optparse import OptionGroup
@ -48,12 +49,12 @@ class WeboobDebug(Application):
try:
backend_name = argv[1]
except IndexError:
print >>self.stderr, 'Usage: %s BACKEND' % argv[0]
print('Usage: %s BACKEND' % argv[0], file=self.stderr)
return 1
try:
backend = self.weboob.load_backends(names=[backend_name])[backend_name]
except KeyError:
print >>self.stderr, u'Unable to load backend "%s"' % backend_name
print(u'Unable to load backend "%s"' % backend_name, file=self.stderr)
return 1
locs = dict(backend=backend, browser=backend.browser, application=self, weboob=self.weboob)

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from datetime import datetime
from time import mktime, strptime
@ -69,14 +69,14 @@ class WeboobRepos(ReplApplication):
if not os.path.exists(path):
os.mkdir(path)
elif not os.path.isdir(path):
print u'"%s" is not a directory' % path
print(u'"%s" is not a directory' % path)
return 1
r = Repository('http://')
r.name = name
r.maintainer = self.ask('Enter maintainer of the repository')
r.save(os.path.join(path, r.INDEX))
print u'Repository "%s" created.' % path
print(u'Repository "%s" created.' % path)
def do_build(self, line):
"""
@ -95,8 +95,8 @@ class WeboobRepos(ReplApplication):
with open(index_file, 'r') as fp:
r.parse_index(fp)
except IOError as e:
print >>self.stderr, 'Unable to open repository: %s' % e
print >>self.stderr, 'Use the "create" command before.'
print('Unable to open repository: %s' % e, file=self.stderr)
print('Use the "create" command before.', file=self.stderr)
return 1
r.build_index(source_path, index_file)
@ -110,13 +110,13 @@ class WeboobRepos(ReplApplication):
if os.path.exists(krname):
kr_mtime = int(datetime.fromtimestamp(os.path.getmtime(krname)).strftime('%Y%m%d%H%M'))
if not os.path.exists(krname) or kr_mtime < r.key_update:
print 'Generate keyring'
print('Generate keyring')
# Remove all existing keys
if os.path.exists(krname):
os.remove(krname)
# Add all valid keys
for keyfile in os.listdir(os.path.join(source_path, r.KEYDIR)):
print 'Adding key %s' % keyfile
print('Adding key %s' % keyfile)
keypath = os.path.join(source_path, r.KEYDIR, keyfile)
subprocess.check_call([
gpg,
@ -134,7 +134,7 @@ class WeboobRepos(ReplApplication):
os.chmod(krname, 0o644)
os.utime(krname, (kr_mtime, kr_mtime))
else:
print 'Keyring is up to date'
print('Keyring is up to date')
for name, module in r.modules.iteritems():
tarname = os.path.join(repo_path, '%s.tar.gz' % name)
@ -146,7 +146,7 @@ class WeboobRepos(ReplApplication):
if tar_mtime >= module.version:
continue
print 'Create archive for %s' % name
print('Create archive for %s' % name)
with closing(tarfile.open(tarname, 'w:gz')) as tar:
tar.add(module_path, arcname=name, exclude=self._archive_excludes)
tar_mtime = mktime(strptime(str(module.version), '%Y%m%d%H%M'))
@ -195,7 +195,7 @@ class WeboobRepos(ReplApplication):
if os.path.exists(sigpath):
sig_mtime = int(os.path.getmtime(sigpath))
if not os.path.exists(sigpath) or sig_mtime < file_mtime:
print 'Signing %s' % filename
print('Signing %s' % filename)
if os.path.exists(sigpath):
os.remove(sigpath)
subprocess.check_call([
@ -207,7 +207,7 @@ class WeboobRepos(ReplApplication):
'--output', sigpath,
'--sign', filepath])
os.utime(sigpath, (file_mtime, file_mtime))
print 'Signatures are up to date'
print('Signatures are up to date')
@staticmethod
def _find_gpg():

View file

@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
from weboob.capabilities.torrent import CapTorrent, MagnetOnly
from weboob.tools.application.repl import ReplApplication, defaultcount
@ -116,7 +116,7 @@ class Weboorrents(ReplApplication):
"""
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
if not torrent:
print >>self.stderr, 'Torrent not found: %s' % id
print('Torrent not found: %s' % id, file=self.stderr)
return 3
self.start_format()
@ -141,7 +141,7 @@ class Weboorrents(ReplApplication):
torrent = self.get_object(id, 'get_torrent', ('description', 'files'))
if not torrent:
print >>self.stderr, 'Torrent not found: %s' % id
print('Torrent not found: %s' % id, file=self.stderr)
return 3
dest = self.obj_to_filename(torrent, dest, '{id}-{name}.torrent')
@ -150,26 +150,26 @@ class Weboorrents(ReplApplication):
for backend, buf in self.do('get_torrent_file', torrent.id, backends=torrent.backend):
if buf:
if dest == '-':
print buf
print(buf)
else:
try:
with open(dest, 'w') as f:
f.write(buf)
except IOError as e:
print >>self.stderr, 'Unable to write .torrent in "%s": %s' % (dest, e)
print('Unable to write .torrent in "%s": %s' % (dest, e), file=self.stderr)
return 1
return
except CallErrors as errors:
for backend, error, backtrace in errors:
if isinstance(error, MagnetOnly):
print >>self.stderr, u'Error(%s): No direct URL available, ' \
print(u'Error(%s): No direct URL available, ' \
u'please provide this magnet URL ' \
u'to your client:\n%s' % (backend, error.magnet)
u'to your client:\n%s' % (backend, error.magnet), file=self.stderr)
return 4
else:
self.bcall_error_handler(backend, error, backtrace)
print >>self.stderr, 'Torrent "%s" not found' % id
print('Torrent "%s" not found' % id, file=self.stderr)
return 3
@defaultcount(10)