コード例 #1
0
 def callback(iq):
     if iq['type'] != 'result':
         if iq['error']['type'] == 'auth':
             self.core.information(
                 'You are not allowed to see the activity of this contact.',
                 'Error')
         else:
             self.core.information('Error retrieving the activity',
                                   'Error')
         return
     seconds = iq['last_activity']['seconds']
     status = iq['last_activity']['status']
     from_ = iq['from']
     msg = '\x19%s}The last activity of %s was %s ago%s'
     if not safeJID(from_).user:
         msg = '\x19%s}The uptime of %s is %s.' % (
             dump_tuple(get_theme().COLOR_INFORMATION_TEXT), from_,
             common.parse_secs_to_str(seconds))
     else:
         msg = '\x19%s}The last activity of %s was %s ago%s' % (
             dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
             from_,
             common.parse_secs_to_str(seconds),
             (' and his/her last status was %s' %
              status) if status else '',
         )
     self.add_message(msg)
     self.core.refresh_window()
コード例 #2
0
 def callback(iq):
     for query in iq.xml.getiterator('{jabber:iq:last}query'):
         self.api.information(
             'Server %s online since %s' %
             (iq['from'], parse_secs_to_str(int(
                 query.attrib['seconds']))), 'Info')
         return
     self.api.information('Could not retrieve uptime', 'Error')
コード例 #3
0
ファイル: reminder.py プロジェクト: Perdu/poezio
 def command_tasks(self, arg, nocommand=None):
     if nocommand:
         s = 'The following tasks were loaded:\n'
     else:
         s = 'The following tasks are active:\n'
     for key in self.tasks:
         s += 'Task %s: %s every %s.\n' % (key, repr(self.tasks[key][1]),
                 common.parse_secs_to_str(self.tasks[key][0]))
     if s:
         self.api.information(s, 'Info')
コード例 #4
0
ファイル: reminder.py プロジェクト: lasse-aagren/poezio
 def command_tasks(self, arg, nocommand=None):
     if nocommand:
         s = 'The following tasks were loaded:\n'
     else:
         s = 'The following tasks are active:\n'
     for key in self.tasks:
         s += 'Task %s: %s every %s.\n' % (key, repr(self.tasks[key][1]),
                                           common.parse_secs_to_str(
                                               self.tasks[key][0]))
     if s:
         self.api.information(s, 'Info')
コード例 #5
0
 def callback(iq):
     "Callback for the last activity"
     if iq['type'] != 'result':
         if iq['error']['type'] == 'auth':
             self.information(
                 'You are not allowed to see the '
                 'activity of this contact.', 'Error')
         else:
             self.information('Error retrieving the activity', 'Error')
         return
     seconds = iq['last_activity']['seconds']
     status = iq['last_activity']['status']
     from_ = iq['from']
     if not safeJID(from_).user:
         msg = 'The uptime of %s is %s.' % (
             from_, common.parse_secs_to_str(seconds))
     else:
         msg = 'The last activity of %s was %s ago%s' % (
             from_, common.parse_secs_to_str(seconds),
             (' and his/her last status was %s' % status) if status else '')
     self.information(msg, 'Info')
コード例 #6
0
ファイル: commands.py プロジェクト: krackou/poezio
 def callback(iq):
     "Callback for the last activity"
     if iq['type'] != 'result':
         if iq['error']['type'] == 'auth':
             self.information(_('You are not allowed to see the '
                                'activity of this contact.'),
                              _('Error'))
         else:
             self.information(_('Error retrieving the activity'), 'Error')
         return
     seconds = iq['last_activity']['seconds']
     status = iq['last_activity']['status']
     from_ = iq['from']
     if not safeJID(from_).user:
         msg = 'The uptime of %s is %s.' % (
                 from_,
                 common.parse_secs_to_str(seconds))
     else:
         msg = 'The last activity of %s was %s ago%s' % (
             from_,
             common.parse_secs_to_str(seconds),
             (' and his/her last status was %s' % status) if status else '')
     self.information(msg, 'Info')
コード例 #7
0
ファイル: reminder.py プロジェクト: Perdu/poezio
    def command_remind(self, arg):
        args = common.shell_split(arg)
        if len(args) < 2:
            return
        time = common.parse_str_to_secs(args[0])
        if not time:
            return

        self.tasks[self.count] = (time, args[1])
        timed_event = timed_events.DelayedEvent(time, self.remind, self.count)
        self.api.add_timed_event(timed_event)
        self.api.information('Task %s added: %s every %s.' % (self.count, args[1],
            common.parse_secs_to_str(time)), 'Info')
        self.count += 1
コード例 #8
0
ファイル: reminder.py プロジェクト: lasse-aagren/poezio
    def command_remind(self, arg):
        args = common.shell_split(arg)
        if len(args) < 2:
            return
        time = common.parse_str_to_secs(args[0])
        if not time:
            return

        self.tasks[self.count] = (time, args[1])
        timed_event = timed_events.DelayedEvent(time, self.remind, self.count)
        self.api.add_timed_event(timed_event)
        self.api.information(
            'Task %s added: %s every %s.' %
            (self.count, args[1], common.parse_secs_to_str(time)), 'Info')
        self.count += 1
コード例 #9
0
ファイル: conversationtab.py プロジェクト: fmeynadier/poezio
 def callback(iq):
     if iq['type'] != 'result':
         if iq['error']['type'] == 'auth':
             self.core.information('You are not allowed to see the activity of this contact.', 'Error')
         else:
             self.core.information('Error retrieving the activity', 'Error')
         return
     seconds = iq['last_activity']['seconds']
     status = iq['last_activity']['status']
     from_ = iq['from']
     msg = '\x19%s}The last activity of %s was %s ago%s'
     if not safeJID(from_).user:
         msg = '\x19%s}The uptime of %s is %s.' % (
                 dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
                 from_,
                 common.parse_secs_to_str(seconds))
     else:
         msg = '\x19%s}The last activity of %s was %s ago%s' % (
             dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
             from_,
             common.parse_secs_to_str(seconds),
             (' and his/her last status was %s' % status) if status else '',)
     self.add_message(msg)
     self.core.refresh_window()
コード例 #10
0
ファイル: uptime.py プロジェクト: adamkijak/poezio
 def callback(iq):
     for query in iq.xml.getiterator('{jabber:iq:last}query'):
         self.core.information('Server %s online since %s' % (iq['from'], parse_secs_to_str(int(query.attrib['seconds']))), 'Info')
         return
     self.core.information('Could not retrieve uptime', 'Error')
コード例 #11
0
def test_parse_secs_to_str():
    assert parse_secs_to_str(3601) == '1h1s'
    assert parse_secs_to_str(0) == '0s'

    with pytest.raises(TypeError):
        parse_secs_to_str('toto')
コード例 #12
0
def test_parse_secs_to_str():
    assert parse_secs_to_str(3601) == '1h1s'
    assert parse_secs_to_str(0) == '0s'

    with pytest.raises(TypeError):
        parse_secs_to_str('toto')
コード例 #13
0
ファイル: test_common.py プロジェクト: manasb/poezio
def test_parse_secs_to_str():
    assert parse_secs_to_str(3601) == "1h1s"
    assert parse_secs_to_str(0) == "0s"

    with pytest.raises(TypeError):
        parse_secs_to_str("toto")