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

@ -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)