File: worker.rst

package info (click to toggle)
gammu 1.28.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 21,972 kB
  • ctags: 8,504
  • sloc: ansic: 104,965; pascal: 7,209; cpp: 4,023; python: 3,639; php: 1,622; sh: 1,534; sql: 450; cs: 260; makefile: 192; perl: 107; asm: 31
file content (162 lines) | stat: -rw-r--r-- 4,173 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
:mod:`gammu.worker` - Asynchronous communication to phone.
==========================================================

.. module:: gammu.worker
    :synopsis: Asynchronous communication to phone.

Mostly you should use only :class:`GammuWorker` class, others are only helpers
which are used by this class.


.. class:: GammuCommand(command, params=None, percentage=100)
   :module: gammu.worker

   Storage of single command for gammu.
   
   
   .. method:: GammuCommand.get_command()
      :module: gammu.worker
   
      Returns command name.
      
   
   .. method:: GammuCommand.get_params()
      :module: gammu.worker
   
      Returns command params.
      
   
   .. method:: GammuCommand.get_percentage()
      :module: gammu.worker
   
      Returns percentage of current task.
      

.. class:: GammuTask(name, commands)
   :module: gammu.worker

   Storage of taks for gammu.
   
   
   .. method:: GammuTask.get_name()
      :module: gammu.worker
   
      Returns task name.
      
   
   .. method:: GammuTask.get_next()
      :module: gammu.worker
   
      Returns next command to be executed as :class:`GammuCommand`.
      

.. class:: GammuThread(queue, config, callback)
   :module: gammu.worker

   Thread for phone communication.
   
   
   .. method:: GammuThread.join(timeout=None)
      :module: gammu.worker
   
      Terminates thread and waits for it.
      
   
   .. method:: GammuThread.kill()
      :module: gammu.worker
   
      Forces thread end without emptying queue.
      
   
   .. method:: GammuThread.run()
      :module: gammu.worker
   
      Thread body, which handles phone communication. This should not
      be used from outside.
      

.. class:: GammuWorker(callback)
   :module: gammu.worker

   Wrapper class for asynchronous communication with Gammu. It spaws
   own thread and then passes all commands to this thread. When task is
   done, caller is notified via callback.
   
   
   .. method:: GammuWorker.abort()
      :module: gammu.worker
   
      Aborts any remaining operations.
      
   
   .. method:: GammuWorker.configure(config)
      :module: gammu.worker
   
      Configures gammu instance according to config.
      
      :param config: Gammu configuration, same as :meth:`gammu.StateMachine.SetConfig` accepts.
      :type config: hash
      
   
   .. method:: GammuWorker.enqueue(command, params=None, commands=None)
      :module: gammu.worker
   
      Enqueues command or task.
      
      :param command: Command(s) to execute. Each command is tuple containing function name and it's parameters.
      :type command: tuple of list of tuples
      :param params: Parameters to command.
      :type params: tuple or string
      :param commands: List of commands to execute. When this is not none, params are ignored and command is taken as task name.
      :type commands: list of tuples or strings
      
   
   .. method:: GammuWorker.enqueue_command(command, params)
      :module: gammu.worker
   
      Enqueues command.
      
      :param command: Command(s) to execute. Each command is tuple containing function name and it's parameters.
      :type command: tuple of list of tuples
      :param params: Parameters to command.
      :type params: tuple or string
      
   
   .. method:: GammuWorker.enqueue_task(command, commands)
      :module: gammu.worker
   
      Enqueues task.
      
      :param command: Command(s) to execute. Each command is tuple containing function name and it's parameters.
      :type command: tuple of list of tuples
      :param commands: List of commands to execute.
      :type commands: list of tuples or strings
      
   
   .. method:: GammuWorker.initiate()
      :module: gammu.worker
   
      Connects to phone.
      
   
   .. method:: GammuWorker.terminate(timeout=None)
      :module: gammu.worker
   
      Terminates phone connection.
      

.. exception:: InvalidCommand(value)
   :module: gammu.worker

   Exception indicating invalid command.
   

.. function:: check_worker_command(command)
   :module: gammu.worker

   Checks whether command is valid.
   
   :param command: Name of command.
   :type command: string