|
1
|
|
|
"""Data structures for application information.""" |
|
2
|
|
|
|
|
3
|
1 |
|
import logging |
|
4
|
|
|
|
|
5
|
1 |
|
import yorm |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
1 |
|
from .base import NameMixin |
|
8
|
|
|
|
|
9
|
|
|
|
|
10
|
1 |
|
log = logging.getLogger(__name__) |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
1 |
|
@yorm.attr(mac=yorm.types.NullableString) |
|
|
|
|
|
|
14
|
1 |
|
@yorm.attr(windows=yorm.types.NullableString) |
|
15
|
1 |
|
@yorm.attr(linux=yorm.types.NullableString) |
|
16
|
1 |
|
class Versions(yorm.types.AttributeDictionary): |
|
17
|
|
|
"""Dictionary of OS-specific application filenames.""" |
|
18
|
|
|
|
|
19
|
|
|
|
|
20
|
1 |
|
@yorm.attr(auto_queue=yorm.types.Boolean) |
|
|
|
|
|
|
21
|
1 |
|
@yorm.attr(single_instance=yorm.types.Boolean) |
|
22
|
1 |
|
class Properties(yorm.types.AttributeDictionary): |
|
23
|
|
|
"""Dictionary of application management settings.""" |
|
24
|
|
|
|
|
25
|
|
|
|
|
26
|
1 |
|
@yorm.attr(name=yorm.types.String) |
|
27
|
1 |
|
@yorm.attr(properties=Properties) |
|
28
|
1 |
|
@yorm.attr(versions=Versions) |
|
29
|
1 |
|
class Application(NameMixin, yorm.types.AttributeDictionary): |
|
30
|
|
|
"""Dictionary of application information.""" |
|
31
|
|
|
|
|
32
|
|
|
# pylint: disable=E1101 |
|
33
|
|
|
|
|
34
|
1 |
|
def __init__(self, name, properties=None, filename=None, versions=None): |
|
35
|
1 |
|
super().__init__() |
|
36
|
1 |
|
self.name = name |
|
37
|
1 |
|
self.properties = properties or Properties() |
|
38
|
1 |
|
self.versions = versions or Versions(mac=filename, |
|
39
|
|
|
windows=filename, |
|
40
|
|
|
linux=filename) |
|
41
|
|
|
|
|
42
|
1 |
|
@property |
|
43
|
|
|
def auto_queue(self): |
|
44
|
|
|
return self.properties.auto_queue |
|
45
|
|
|
|
|
46
|
1 |
|
@property |
|
47
|
|
|
def no_wait(self): |
|
48
|
|
|
return not self.properties.single_instance |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
1 |
|
@yorm.attr(all=Application) |
|
|
|
|
|
|
52
|
1 |
|
class Applications(yorm.types.SortedList): |
|
53
|
|
|
"""List of monitored applications.""" |
|
54
|
|
|
|
|
55
|
1 |
|
def get(self, name): |
|
56
|
|
|
"""Get the application with the given name.""" |
|
57
|
1 |
|
application = self.find(name) |
|
58
|
1 |
|
assert application, name |
|
59
|
1 |
|
return application |
|
60
|
|
|
|
|
61
|
1 |
|
def find(self, name): |
|
62
|
|
|
"""Find the application with the given name, else None.""" |
|
63
|
1 |
|
log.debug("Finding application for '%s'...", name) |
|
64
|
1 |
|
for application in self: |
|
65
|
1 |
|
if application == name: |
|
66
|
|
|
return application |
|
67
|
|
|
|
This can be caused by one of the following:
1. Missing Dependencies
This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.
2. Missing __init__.py files
This error could also result from missing
__init__.pyfiles in your module folders. Make sure that you place one file in each sub-folder.