• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 Google Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14import logging
15
16logging.warning('The module mobly.controllers.android_device_lib.snippet_event '
17                'is deprecated and will be removed in a future version. Use '
18                'module mobly.snippet.callback_event instead.')
19
20
21def from_dict(event_dict):
22  """Create a SnippetEvent object from a dictionary.
23
24  DEPRECATED: Use mobly.snippet.callback_event.from_dict instead.
25
26  Args:
27    event_dict: a dictionary representing an event.
28
29  Returns:
30    A SnippetEvent object.
31  """
32  return SnippetEvent(callback_id=event_dict['callbackId'],
33                      name=event_dict['name'],
34                      creation_time=event_dict['time'],
35                      data=event_dict['data'])
36
37
38class SnippetEvent:
39  """The class that represents callback events for mobly snippet library.
40
41  DEPRECATED: Use mobly.snippet.callback_event.CallbackEvent instead.
42
43  Attributes:
44    callback_id: string, the callback ID associated with the event.
45    name: string, the name of the event.
46    creation_time: int, the epoch time when the event is created on the
47      Rpc server side.
48    data: dictionary, the data held by the event. Can be None.
49  """
50
51  def __init__(self, callback_id, name, creation_time, data):
52    self.callback_id = callback_id
53    self.name = name
54    self.creation_time = creation_time
55    self.data = data
56
57  def __repr__(self):
58    return ('SnippetEvent(callback_id: %s, name: %s, creation_time: %s, '
59            'data: %s)') % (self.callback_id, self.name, self.creation_time,
60                            self.data)
61