Show
Ignore:
Timestamp:
09/06/05 13:20:56 (3 years ago)
Author:
nk
Message:

move gajim-remote.py and overrite

Files:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.8.2/src/gajim-remote.py

    r3282 r3443  
    3333signal.signal(signal.SIGINT, signal.SIG_DFL) # ^C exits the application 
    3434 
    35 import i18n 
     35from common import i18n 
    3636 
    3737_ = i18n._ 
    3838i18n.init() 
    3939 
    40  
     40def send_error(error_message): 
     41        '''  Writes error message to stderr and exits ''' 
     42        sys.stderr.write(error_message + '\n') 
     43        sys.stderr.flush() 
     44        sys.exit(1) 
    4145try: 
    4246        import dbus 
     
    150154                if self.argv_len  < 2 or \ 
    151155                        sys.argv[1] not in self.commands.keys(): # no args or bad args 
    152                         self.send_error(self.compose_help()) 
     156                        send_error(self.compose_help()) 
    153157                self.command = sys.argv[1] 
    154158                 
     
    165169                if self.command == 'contact_info': 
    166170                        if self.argv_len < 3: 
    167                                 self.send_error(_('Missing argument "contact_jid"')) 
     171                                send_error(_('Missing argument "contact_jid"')) 
    168172                        try: 
    169173                                id = self.sbus.add_signal_receiver(self.show_vcard_info,  
    170174                                        'VcardInfo', INTERFACE, SERVICE, OBJ_PATH) 
    171175                        except: 
    172                                 self.send_error(_('Service not available')) 
     176                                send_error(_('Service not available')) 
    173177                 
    174178                res = self.call_remote_method() 
     
    188192                                if res == False: 
    189193                                        if self.argv_len < 4: 
    190                                                 self.send_error(_('\'%s\' is not in your roster.\n\ 
     194                                                send_error(_('\'%s\' is not in your roster.\n\ 
    191195Please specify account for sending the message.') % sys.argv[2]) 
    192196                                        else: 
    193                                                 self.send_error(_('You have no active account')) 
     197                                                send_error(_('You have no active account')) 
    194198                        elif self.command == 'list_accounts': 
    195199                                if isinstance(res, list): 
     
    210214                        self.sbus = dbus.SessionBus() 
    211215                except: 
    212                         self.send_error(_('Session bus is not available.')) 
    213                  
    214                 if _version[1] >= 30 and _version[1] <= 42: 
     216                        send_error(_('Session bus is not available.')) 
     217                 
     218                if _version[1] >= 30: 
    215219                        obj = self.sbus.get_object(SERVICE, OBJ_PATH) 
    216220                        interface = dbus.Interface(obj, INTERFACE) 
     
    252256                                str += ' ' +  argument[0] + ' - ' + argument[1] + '\n' 
    253257                        return str 
    254                 self.send_error(_('%s not found') % command) 
     258                send_error(_('%s not found') % command) 
    255259                         
    256260        def compose_help(self): 
     
    455459                if len(args) > argv_len: 
    456460                        if args[argv_len][2]: 
    457                                 self.send_error(_('Argument "%s" is not specified. \n\ 
     461                                send_error(_('Argument "%s" is not specified. \n\ 
    458462Type "%s help %s" for more info') % (args[argv_len][0], BASENAME, self.command)) 
    459463 
     
    482486                        return res 
    483487                except: 
    484                         self.send_error(_('Service not available')) 
     488                        send_error(_('Service not available')) 
    485489                return None 
    486  
    487         def send_error(self, error_message): 
    488                 '''  Writes error message to stderr and exits ''' 
    489                 sys.stderr.write(error_message + '\n') 
    490                 sys.stderr.flush() 
    491                 sys.exit(1) 
    492490 
    493491if __name__ == '__main__':