1
2 """
3
4 @author: Fabio Erculiani <lxnay@sabayonlinux.org>
5 @contact: lxnay@sabayonlinux.org
6 @copyright: Fabio Erculiani
7 @license: GPL-2
8
9 B{Entropy Client Services Base Mixin Interfaces}.
10
11 """
12 from entropy.const import const_get_stringtype
13 from entropy.i18n import _
14
16
17 - def __init__(self, SystemManagerClientInstance):
18 self.Manager = SystemManagerClientInstance
19 str_type = const_get_stringtype()
20 self.available_commands = {
21 'get_available_commands': {
22 'desc': _("Get a list of remotely available commands"),
23 'params': [],
24 'call': self.get_available_commands,
25 'private': True,
26 },
27 'get_queue': {
28 'desc': _("Get current queue content"),
29 'params': [
30 ('extended', bool, _('Extended results'), False,)
31 ],
32 'call': self.get_queue,
33 'private': True,
34 },
35 'get_queue_item_by_id': {
36 'desc': _("Get queue item using its queue unique identifier"),
37 'params': [('queue_id', int, _('Queue Identifier'), True,)],
38 'call': self.get_queue_item_by_id,
39 'private': True,
40 },
41 'get_queue_id_stdout': {
42 'desc': _("Get queue stdout/stderr using its queue unique identifier"),
43 'params': [('queue_id', int, _('Queue Identifier'), True,)],
44 'call': self.get_queue_id_stdout,
45 'private': True,
46 },
47 'get_queue_id_stdout': {
48 'desc': _("Get queued command result using its queue unique identifier"),
49 'params': [('queue_id', int, _('Queue Identifier'), True,)],
50 'call': self.get_queue_id_result,
51 'private': True,
52 },
53 'remove_queue_ids': {
54 'desc': _("Remove queued commands using their queue unique identifiers"),
55 'params': [('queue_ids', list, _('Queue Identifiers'), True,)],
56 'call': self.remove_queue_ids,
57 'private': True,
58 },
59 'pause_queue': {
60 'desc': _("Toggle queue pause (True/False)"),
61 'params': [('do_pause', bool, _('Pause or not'), True,)],
62 'call': self.pause_queue,
63 'private': True,
64 },
65 'kill_processing_queue_id': {
66 'desc': _("Kill a running process through its queue id"),
67 'params': [('queue_id', int, _('Queue Identifier'), True,)],
68 'call': self.kill_processing_queue_id,
69 'private': True,
70 },
71 'swap_items_in_queue': {
72 'desc': _("Swap items in queue using their queue ids"),
73 'params': [
74 ('queue_id1', int, _('Queue Identifier'), True,),
75 ('queue_id2', int, _('Queue Identifier'), True,)
76 ],
77 'call': self.swap_items_in_queue,
78 'private': True,
79 },
80 'get_pinboard_data': {
81 'desc': _("Get pinboard content"),
82 'params': [],
83 'call': self.get_pinboard_data,
84 'private': True,
85 },
86 'add_to_pinboard': {
87 'desc': _("Add item to pinboard"),
88 'params': [
89 ('note', str_type, _('Note'), True,),
90 ('extended_text', str_type, _('Extended text'), True,)
91 ],
92 'call': self.add_to_pinboard,
93 'private': True,
94 },
95 'remove_from_pinboard': {
96 'desc': _("Remove item from pinboard"),
97 'params': [('pinboard_ids', list, _('Pinboard identifiers'), True,)],
98 'call': self.remove_from_pinboard,
99 'private': True,
100 },
101 'set_pinboard_items_done': {
102 'desc': _("Set pinboard items status (done/not done)"),
103 'params': [
104 ('pinboard_ids', list, _('Pinboard identifiers'), True,),
105 ('done_status', bool, _('Done status'), True,),
106 ],
107 'call': self.set_pinboard_items_done,
108 'private': True,
109 },
110 'write_to_running_command_pipe': {
111 'desc': _("Write to a remote running command stdin"),
112 'params': [
113 ('queue_id', int, _('Queue Identifier'), True,),
114 ('write_to_stdout', bool, _('Write to stdout?'), True,),
115 ('txt', str_type, _('Text'), True,),
116 ],
117 'call': self.write_to_running_command_pipe,
118 'private': True,
119 },
120 }
121
123 return self.Manager.do_cmd(False, "available_commands", [], {})
124
126 return self.Manager.do_cmd(True, "get_queue", [extended], {})
127
129 return self.Manager.do_cmd(True, "get_queue_item_by_id", [queue_id], {})
130
132 return self.Manager.do_cmd(True, "get_queue_id_stdout", [queue_id, last_bytes], {})
133
135 return self.Manager.do_cmd(True, "get_queue_id_result", [queue_id], {})
136
138 return self.Manager.do_cmd(True, "remove_queue_ids", [queue_ids], {})
139
141 return self.Manager.do_cmd(True, "pause_queue", [do_queue], {})
142
144 return self.Manager.do_cmd(True, "kill_processing_queue_id", [queue_id], {})
145
147 return self.Manager.do_cmd(True, "swap_items_in_queue", [queue_id1, queue_id2], {})
148
150 return self.Manager.do_cmd(True, "get_pinboard_data", [], {})
151
153 return self.Manager.do_cmd(True, "add_to_pinboard", [note, extended_text], {})
154
156 return self.Manager.do_cmd(True, "remove_from_pinboard", [pinboard_ids], {})
157
159 return self.Manager.do_cmd(True, "set_pinboard_items_done", [pinboard_ids, done_status], {})
160
162 return self.Manager.do_cmd(True, "write_to_running_command_pipe", [queue_id, write_to_stdout, txt], {})
163
164
166
168 BaseMixin.__init__(self, *args, **kwargs)
169 str_type = const_get_stringtype()
170 self.available_commands.update({
171 'sync_spm': {
172 'desc': _("Update Spm Repository (emerge --sync)"),
173 'params': [],
174 'call': self.sync_spm,
175 'private': False,
176 },
177 'compile_atoms': {
178 'desc': _("Compile specified atoms with specified parameters"),
179 'params': [
180 ('atoms', list, _('Atoms'), True,),
181 ('pretend', bool, _('Pretend'), False,),
182 ('oneshot', bool, _('Oneshot'), False,),
183 ('verbose', bool, _('Verbose'), False,),
184 ('nocolor', bool, _('No color'), False,),
185 ('fetchonly', bool, _('Fetch only'), False,),
186 ('buildonly', bool, _('Build only'), False,),
187 ('nodeps', bool, _('No dependencies'), False,),
188 ('custom_use', str_type, _('Custom USE'), False,),
189 ('ldflags', str_type, _('Custom LDFLAGS'), False,),
190 ('cflags', str_type, _('Custom CFLAGS'), False,),
191 ],
192 'call': self.compile_atoms,
193 'private': False,
194 },
195 'spm_remove_atoms': {
196 'desc': _("Remove specified atoms with specified parameters"),
197 'params': [
198 ('atoms', list, _('Atoms'), True,),
199 ('pretend', bool, _('Pretend'), False,),
200 ('verbose', bool, _('Verbose'), False,),
201 ('nocolor', bool, _('No color'), False,),
202 ],
203 'call': self.spm_remove_atoms,
204 'private': False,
205 },
206 'get_spm_categories_updates': {
207 'desc': _("Get SPM updates for the specified categories"),
208 'params': [('categories', list, _('Categories'), True,)],
209 'call': self.get_spm_categories_updates,
210 'private': False,
211 },
212 'get_spm_categories_installed': {
213 'desc': _("Get SPM installed packages for the specified categories"),
214 'params': [('categories', list, _('Categories'), True,)],
215 'call': self.get_spm_categories_installed,
216 'private': False,
217 },
218 'enable_uses_for_atoms': {
219 'desc': _("Enable USE flags for the specified atoms"),
220 'params': [
221 ('atoms', list, _('Atoms'), True,),
222 ('useflags', list, _('USE flags'), True,)
223 ],
224 'call': self.enable_uses_for_atoms,
225 'private': False,
226 },
227 'disable_uses_for_atoms': {
228 'desc': _("Disable USE flags for the specified atoms"),
229 'params': [
230 ('atoms', list, _('Atoms'), True,),
231 ('useflags', list, _('USE flags'), True,)
232 ],
233 'call': self.disable_uses_for_atoms,
234 'private': False,
235 },
236 'get_spm_atoms_info': {
237 'desc': _("Get info for the specified atoms"),
238 'params': [('atoms', list, _('Atoms'), True,)],
239 'call': self.get_spm_atoms_info,
240 'private': False,
241 },
242 'run_spm_info': {
243 'desc': _("Run SPM info command"),
244 'params': [],
245 'call': self.run_spm_info,
246 'private': False,
247 },
248 'run_custom_shell_command': {
249 'desc': _("Run custom shell command"),
250 'params': [
251 ('command', str_type, _('Command'), True,)
252 ],
253 'call': self.run_custom_shell_command,
254 'private': False,
255 },
256 'get_spm_glsa_data': {
257 'desc': _("Get Spm security updates information"),
258 'params': [
259 ('list_type', str_type, _('List type (affected,new,all)'), True,)
260 ],
261 'call': self.get_spm_glsa_data,
262 'private': False,
263 },
264 'get_available_repositories': {
265 'desc': _("Get information about available Entropy repositories"),
266 'params': [],
267 'call': self.get_available_repositories,
268 'private': False,
269 },
270 'set_default_repository': {
271 'desc': _("Set default Entropy Server repository"),
272 'params': [
273 ('repoid', str_type, _('Repository Identifier'), True,)
274 ],
275 'call': self.set_default_repository,
276 'private': False,
277 },
278 'get_available_entropy_packages': {
279 'desc': _("Get available packages inside the specified repository"),
280 'params': [
281 ('repoid', str_type, _('Repository Identifier'), True,)
282 ],
283 'call': self.get_available_entropy_packages,
284 'private': False,
285 },
286 'get_entropy_idpackage_information': {
287 'desc': _("Get idpackage metadata using its idpackage in the specified repository"),
288 'params': [
289 ('idpackage', int, _('Package Identifier'), True,),
290 ('repoid', str_type, _('Repository Identifier'), True,)
291 ],
292 'call': self.get_entropy_idpackage_information,
293 'private': False,
294 },
295 'remove_entropy_packages': {
296 'desc': _("Remove the specified Entropy package matches (idpackage,repoid)"),
297 'params': [
298 ('matched_atoms', list, _('Matched atoms'), True,)
299 ],
300 'call': self.remove_entropy_packages,
301 'private': False,
302 },
303 'search_entropy_packages': {
304 'desc': _("Search Entropy packages using a defined set of search types in the specified repository"),
305 'params': [
306 ('search_type', str_type, _('Search type'), True,),
307 ('search_string', str_type, _('Search string'), True,),
308 ('repoid', str_type, _('Repository Identifier'), True,)
309 ],
310 'call': self.search_entropy_packages,
311 'private': False,
312 },
313 'move_entropy_packages_to_repository': {
314 'desc': _("Move or copy a package from a repository to another"),
315 'params': [
316 ('idpackages', list, _('Package identifiers'), True,),
317 ('from_repo', str_type, _('From repository'), True,),
318 ('to_repo', str_type, _('To repository'), True,),
319 ('do_copy', bool, _('Copy instead of move?'), False,)
320 ],
321 'call': self.search_entropy_packages,
322 'private': False,
323 },
324 'scan_entropy_packages_database_changes': {
325 'desc': _("Scan Spm package changes and retrieve a list of action that should be run on the repositories"),
326 'params': [],
327 'call': self.scan_entropy_packages_database_changes,
328 'private': False,
329 },
330 'run_entropy_database_updates': {
331 'desc': _("Run Entropy database updates"),
332 'params': [
333 ('to_add', list, _('Matches to add from Spm'), True,),
334 ('to_remove', list, _('Matches to remove from repository database'), True,),
335 ('to_inject', list, _('Matches to inject on repository database'), True,),
336 ],
337 'call': self.run_entropy_database_updates,
338 'private': False,
339 },
340 'run_entropy_dependency_test': {
341 'desc': _("Run Entropy dependency test"),
342 'params': [],
343 'call': self.run_entropy_dependency_test,
344 'private': False,
345 },
346 'run_entropy_library_test': {
347 'desc': _("Run Entropy library test"),
348 'params': [],
349 'call': self.run_entropy_library_test,
350 'private': False,
351 },
352 'run_entropy_treeupdates': {
353 'desc': _("Run Entropy tree updates"),
354 'params': [
355 ('repoid', str_type, _('Repository Identifier'), True,),
356 ],
357 'call': self.run_entropy_treeupdates,
358 'private': False,
359 },
360 'scan_entropy_mirror_updates': {
361 'desc': _("Scan for Mirror updates and retrieve a list of action that should be run"),
362 'params': [
363 ('repositories', list, _('list of repository identifiers'), True,),
364 ],
365 'call': self.scan_entropy_mirror_updates,
366 'private': False,
367 },
368 'run_entropy_mirror_updates': {
369 'desc': _("Run Mirror updates for the provided repositories and its data"),
370 'params': [
371 ('repository_data', dict, _('composed repository data'), True,),
372 ],
373 'call': self.run_entropy_mirror_updates,
374 'private': False,
375 },
376 'run_entropy_checksum_test': {
377 'desc': _("Run Entropy packages digest verification test"),
378 'params': [
379 ('repoid', str_type, _('Repository Identifier'), True,),
380 ('mode', str_type, _('Check mode'), False,),
381 ],
382 'call': self.run_entropy_mirror_updates,
383 'private': False,
384 },
385 'get_notice_board': {
386 'desc': _("Get repository notice board"),
387 'params': [('repoid', str_type, _('Repository Identifier'), True,),],
388 'call': self.get_notice_board,
389 'private': False,
390 },
391 'remove_notice_board_entries': {
392 'desc': _("Remove notice board entry"),
393 'params': [
394 ('repoid', str_type, _('Repository Identifier'), True,),
395 ('entry_ids', list, _('Entry Identifiers'), True,),
396 ],
397 'call': self.remove_notice_board_entries,
398 'private': False,
399 },
400 'add_notice_board_entry': {
401 'desc': _("Add notice board entry"),
402 'params': [
403 ('repoid', str_type, _('Repository Identifier'), True,),
404 ('title', str_type, _('Title'), True,),
405 ('notice_text', str_type, _('Text'), True,),
406 ('link', str_type, _('Notice link'), True,),
407 ],
408 'call': self.add_notice_board_entry,
409 'private': False,
410 },
411 })
412
414 return self.Manager.do_cmd(True, "sync_spm", [], {})
415
416 - def compile_atoms(self, atoms, pretend = False, oneshot = False,
417 verbose = True, nocolor = True, fetchonly = False, buildonly = False,
418 nodeps = False, custom_use = '', ldflags = '', cflags = ''):
419
420 return self.Manager.do_cmd(
421 True,
422 "compile_atoms",
423 [atoms],
424 {
425 'pretend': pretend,
426 'oneshot': oneshot,
427 'verbose': verbose,
428 'nocolor': nocolor,
429 'fetchonly': fetchonly,
430 'buildonly': buildonly,
431 'nodeps': nodeps,
432 'custom_use': custom_use,
433 'ldflags': ldflags,
434 'cflags': cflags,
435 }
436 )
437
438 - def spm_remove_atoms(self, atoms, pretend = True, verbose = True, nocolor = True):
439 return self.Manager.do_cmd(
440 True,
441 "spm_remove_atoms",
442 [atoms],
443 {
444 'pretend': pretend,
445 'verbose': verbose,
446 'nocolor': nocolor,
447 }
448 )
449
451 return self.Manager.do_cmd(True, "get_spm_categories_updates", [categories], {})
452
454 return self.Manager.do_cmd(True, "get_spm_categories_installed", [categories], {})
455
457 return self.Manager.do_cmd(True, "enable_uses_for_atoms", [atoms, useflags], {})
458
460 return self.Manager.do_cmd(True, "disable_uses_for_atoms", [atoms, useflags], {})
461
463 return self.Manager.do_cmd(True, "get_spm_atoms_info", [atoms], {})
464
466 return self.Manager.do_cmd(True, "run_spm_info", [], {})
467
469 return self.Manager.do_cmd(True, "run_custom_shell_command", [command], {})
470
472 return self.Manager.do_cmd(True, "get_spm_glsa_data", [list_type], {})
473
475 return self.Manager.do_cmd(True, "get_available_repositories", [], {})
476
478 return self.Manager.do_cmd(True, "set_default_repository", [repoid], {})
479
481 return self.Manager.do_cmd(True, "get_available_entropy_packages", [repoid], {})
482
485
487 return self.Manager.do_cmd(True, "remove_entropy_packages", [matched_atoms], {})
488
490 return self.Manager.do_cmd(True, "search_entropy_packages", [search_type, search_string, repoid], {})
491
493 return self.Manager.do_cmd(True, "move_entropy_packages_to_repository", [idpackages, from_repo, to_repo, do_copy], {})
494
496 return self.Manager.do_cmd(True, "scan_entropy_packages_database_changes", [], {})
497
499 return self.Manager.do_cmd(True, "run_entropy_database_updates", [to_add, to_remove, to_inject], {})
500
502 return self.Manager.do_cmd(True, "run_entropy_dependency_test", [], {})
503
505 return self.Manager.do_cmd(True, "run_entropy_library_test", [], {})
506
508 return self.Manager.do_cmd(True, "run_entropy_treeupdates", [repoid], {})
509
511 return self.Manager.do_cmd(True, "scan_entropy_mirror_updates", [repositories], {})
512
514 return self.Manager.do_cmd(True, "run_entropy_mirror_updates", [repository_data], {})
515
517 return self.Manager.do_cmd(True, "run_entropy_checksum_test", [repoid, mode], {})
518
520 return self.Manager.do_cmd(True, "get_notice_board", [repoid], {})
521
523 return self.Manager.do_cmd(True, "remove_notice_board_entries", [repoid, entry_ids], {})
524
525 - def add_notice_board_entry(self, repoid, title, notice_text, link):
526 return self.Manager.do_cmd(True, "add_notice_board_entry", [repoid, title, notice_text, link], {})
527