diff options
Diffstat (limited to 'libbe/command/base.py')
-rw-r--r-- | libbe/command/base.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/libbe/command/base.py b/libbe/command/base.py index f019450..efba1b2 100644 --- a/libbe/command/base.py +++ b/libbe/command/base.py @@ -21,9 +21,9 @@ import codecs import optparse import os.path -import StringIO +import io import sys -import urlparse +import urllib.parse import libbe import libbe.storage @@ -84,8 +84,8 @@ def get_command(command_name): try: cmd = libbe.util.plugin.import_by_name( 'libbe.command.%s' % command_name.replace("-", "_")) - except ImportError, e: - raise UnknownCommand(command_name, message=unicode(e)) + except ImportError as e: + raise UnknownCommand(command_name, message=str(e)) return cmd def get_command_class(module=None, command_name=None): @@ -104,7 +104,7 @@ def get_command_class(module=None, command_name=None): try: cname = command_name.capitalize().replace('-', '_') cmd = getattr(module, cname) - except ImportError, e: + except ImportError as e: raise UnknownCommand(command_name) return cmd @@ -320,9 +320,9 @@ class Command (object): if 'user-id' in options: self._user_id = options.pop('user-id') if len(options) > 0: - raise UserError, 'Invalid option passed to command %s:\n %s' \ + raise UserError('Invalid option passed to command %s:\n %s' \ % (self.name, '\n '.join(['%s: %s' % (k,v) - for k,v in options.items()])) + for k,v in list(options.items())]))) in_optional_args = False for i,arg in enumerate(self.args): if arg.repeatable == True: @@ -352,7 +352,7 @@ class Command (object): 'command': self.name, 'parameters': kwargs, }, context=0) - url = urlparse.urljoin(self.server, 'run') + url = urllib.parse.urljoin(self.server, 'run') page,final_url,info = libbe.util.http.get_post_url( url=url, get=False, data=data, agent=self.user_agent) self.stdout.write(page) @@ -491,14 +491,14 @@ class StringInputOutput (InputOutput): u'goodbye\\n' """ def __init__(self): - stdin = StringIO.StringIO() + stdin = io.StringIO() stdin.encoding = 'utf-8' - stdout = StringIO.StringIO() + stdout = io.StringIO() stdout.encoding = 'utf-8' InputOutput.__init__(self, stdin, stdout) def set_stdin(self, stdin_string): - self.stdin = StringIO.StringIO(stdin_string) + self.stdin = io.StringIO(stdin_string) def get_stdout(self): ret = self.stdout.getvalue() |