Skip to content
Snippets Groups Projects
Commit 274d5270 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

blank line is really blank (no \t)

parent 159e782c
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,7 @@ def send_error(error_message):
class GajimRemote:
def __init__(self):
self.argv_len = len(sys.argv)
# define commands dict. Prototype :
......@@ -99,7 +99,7 @@ def __init__(self):
[
(_('account'), _('show only contacts of the given account'), False)
]
],
'list_accounts': [
_('Prints a list of registered accounts'),
......@@ -201,7 +201,7 @@ def __init__(self):
('jid', _('JID of the contact'), True),
(_('account'), _('if specified, contact is taken from the '
'contact list of this account'), False)
]
],
'add_contact': [
......@@ -211,14 +211,14 @@ def __init__(self):
(_('account'), _('Adds new contact to this account'), False)
]
],
'get_status': [
_('Returns current status (the global one unless account is specified)'),
[
(_('account'), _(''), False)
]
],
'get_status_message': [
_('Returns current status message(the global one unless account is specified)'),
[
......@@ -247,14 +247,14 @@ def __init__(self):
else:
print self.compose_help().encode(PREFERRED_ENCODING)
sys.exit(0)
self.init_connection()
self.check_arguments()
if self.command == 'contact_info':
if self.argv_len < 3:
send_error(_('Missing argument "contact_jid"'))
try:
res = self.call_remote_method()
except exceptions.ServiceNotAvailable:
......@@ -262,14 +262,14 @@ def __init__(self):
sys.exit(1)
else:
self.print_result(res)
def print_result(self, res):
''' Print retrieved result to the output '''
if res is not None:
if self.command in ('open_chat', 'send_message', 'send_single_message', 'start_chat'):
if self.command in ('send_message', 'send_single_message'):
self.argv_len -= 2
if res is False:
if self.argv_len < 4:
send_error(_('\'%s\' is not in your roster.\n'
......@@ -302,7 +302,7 @@ def print_result(self, res):
print self.print_info(0, res, True)
elif res:
print unicode(res).encode(PREFERRED_ENCODING)
def init_connection(self):
''' create the onnection to the session dbus,
or exit if it is not possible '''
......@@ -310,7 +310,7 @@ def init_connection(self):
self.sbus = dbus.SessionBus()
except:
raise exceptions.SessionBusNotPresent
if _version[1] >= 30:
obj = self.sbus.get_object(SERVICE, OBJ_PATH)
interface = dbus.Interface(obj, INTERFACE)
......@@ -319,10 +319,10 @@ def init_connection(self):
interface = self.service.get_object(OBJ_PATH, INTERFACE)
else:
send_error(_('Unknown D-Bus version: %s') % _version[1])
# get the function asked
self.method = interface.__getattr__(self.command)
def make_arguments_row(self, args):
''' return arguments list. Mandatory arguments are enclosed with:
'<', '>', optional arguments - with '[', ']' '''
......@@ -339,7 +339,7 @@ def make_arguments_row(self, args):
else:
str += ']'
return str
def help_on_command(self, command):
''' return help message for a given command '''
if command in self.commands:
......@@ -353,7 +353,7 @@ def help_on_command(self, command):
str += ' ' + argument[0] + ' - ' + argument[1] + '\n'
return str
send_error(_('%s not found') % command)
def compose_help(self):
''' print usage, and list available commands '''
str = _('Usage: %s command [arguments]\nCommand is one of:\n' ) % BASENAME
......@@ -374,7 +374,7 @@ def compose_help(self):
str += ']'
str += '\n'
return str
def print_info(self, level, prop_dict, encode_return = False):
''' return formated string from data structure '''
if prop_dict is None or not isinstance(prop_dict, (dict, list, tuple)):
......@@ -423,7 +423,7 @@ def print_info(self, level, prop_dict, encode_return = False):
except:
pass
return ret_str
def check_arguments(self):
''' Make check if all necessary arguments are given '''
argv_len = self.argv_len - 2
......@@ -433,7 +433,7 @@ def check_arguments(self):
send_error(_('Argument "%s" is not specified. \n'
'Type "%s help %s" for more info') %
(args[argv_len][0], BASENAME, self.command))
def call_remote_method(self):
''' calls self.method with arguments from sys.argv[2:] '''
args = sys.argv[2:]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment