@@ 12-66 (lines=55) @@ | ||
9 | from ..helpers import field_from_ini, field_to_ini |
|
10 | ||
11 | ||
12 | @zope.interface.implementer(INISerializable) |
|
13 | @zope.interface.implementer(DefaultProvider) |
|
14 | class Speedhack(Model): |
|
15 | check_server_time_speed = BooleanType( |
|
16 | default=True, |
|
17 | required=True, |
|
18 | ) |
|
19 | check_client_time_speed = BooleanType( |
|
20 | default=False, |
|
21 | required=True, |
|
22 | ) |
|
23 | max_time_difference = FloatType( |
|
24 | min_value=0.01, |
|
25 | default=0.2, |
|
26 | required=True, |
|
27 | ) |
|
28 | max_time_difference_period = FloatType( |
|
29 | min_value=1, |
|
30 | max_value=1000, |
|
31 | default=17, |
|
32 | required=True, |
|
33 | ) |
|
34 | ||
35 | @classmethod |
|
36 | def from_ini(cls, ini): |
|
37 | return cls({ |
|
38 | 'check_server_time_speed': field_from_ini( |
|
39 | cls.check_server_time_speed, ini, |
|
40 | 'NET', 'checkServerTimeSpeed', |
|
41 | ), |
|
42 | 'check_client_time_speed': field_from_ini( |
|
43 | cls.check_client_time_speed, ini, |
|
44 | 'NET', 'checkClientTimeSpeed', |
|
45 | ), |
|
46 | 'max_time_difference': field_from_ini( |
|
47 | cls.max_time_difference, ini, |
|
48 | 'NET', 'checkTimeSpeedDifferense', |
|
49 | ), |
|
50 | 'max_time_difference_period': field_from_ini( |
|
51 | cls.max_time_difference_period, ini, |
|
52 | 'NET', 'checkTimeSpeedInterval', |
|
53 | ), |
|
54 | }) |
|
55 | ||
56 | def to_ini(self, ini): |
|
57 | field_to_ini(self.check_server_time_speed, ini, 'NET', 'checkServerTimeSpeed') |
|
58 | field_to_ini(self.check_client_time_speed, ini, 'NET', 'checkClientTimeSpeed') |
|
59 | field_to_ini(self.max_time_difference, ini, 'NET', 'checkTimeSpeedDifferense') |
|
60 | field_to_ini(self.max_time_difference_period, ini, 'NET', 'checkTimeSpeedInterval') |
|
61 | ||
62 | @classmethod |
|
63 | def default(cls): |
|
64 | return cls({ |
|
65 | field_name: field.default |
|
66 | for field_name, field in cls.fields.items() |
|
67 | }) |
|
68 |
@@ 13-66 (lines=54) @@ | ||
10 | from .helpers import field_from_ini, field_to_ini |
|
11 | ||
12 | ||
13 | @zope.interface.implementer(INISerializable) |
|
14 | @zope.interface.implementer(DefaultProvider) |
|
15 | class Proxy(Model): |
|
16 | host = StringType( |
|
17 | default="", |
|
18 | required=True, |
|
19 | ) |
|
20 | port = IntType( |
|
21 | min_value=1000, |
|
22 | max_value=65000, |
|
23 | default=1080, |
|
24 | required=True, |
|
25 | ) |
|
26 | user = StringType( |
|
27 | default="", |
|
28 | required=True, |
|
29 | ) |
|
30 | password = StringType( |
|
31 | default="", |
|
32 | required=True, |
|
33 | ) |
|
34 | ||
35 | @classmethod |
|
36 | def from_ini(cls, ini): |
|
37 | return cls({ |
|
38 | 'host': field_from_ini( |
|
39 | cls.host, ini, |
|
40 | 'NET', 'socksHost', |
|
41 | ), |
|
42 | 'port': field_from_ini( |
|
43 | cls.port, ini, |
|
44 | 'NET', 'socksPort', |
|
45 | ), |
|
46 | 'user': field_from_ini( |
|
47 | cls.user, ini, |
|
48 | 'NET', 'socksUser', |
|
49 | ), |
|
50 | 'password': field_from_ini( |
|
51 | cls.password, ini, |
|
52 | 'NET', 'socksPwd', |
|
53 | ), |
|
54 | }) |
|
55 | ||
56 | def to_ini(self, ini): |
|
57 | field_to_ini(self.host, ini, 'NET', 'socksHost') |
|
58 | field_to_ini(self.port, ini, 'NET', 'socksPort') |
|
59 | field_to_ini(self.user, ini, 'NET', 'socksUser') |
|
60 | field_to_ini(self.password, ini, 'NET', 'socksPwd') |
|
61 | ||
62 | @classmethod |
|
63 | def default(cls): |
|
64 | return cls({ |
|
65 | field_name: field.default |
|
66 | for field_name, field in cls.fields.items() |
|
67 | }) |
|
68 | ||
69 |
@@ 72-124 (lines=53) @@ | ||
69 | }) |
|
70 | ||
71 | ||
72 | @zope.interface.implementer(INISerializable) |
|
73 | @zope.interface.implementer(DefaultProvider) |
|
74 | class Logging(Model): |
|
75 | enabled = BooleanType( |
|
76 | default=False, |
|
77 | required=True, |
|
78 | ) |
|
79 | file_name = StringType( |
|
80 | default="log.lst", |
|
81 | min_length=1, |
|
82 | required=True, |
|
83 | ) |
|
84 | keep_file = BooleanType( |
|
85 | default=True, |
|
86 | required=True, |
|
87 | ) |
|
88 | log_time = BooleanType( |
|
89 | default=False, |
|
90 | required=True, |
|
91 | ) |
|
92 | ||
93 | @classmethod |
|
94 | def from_ini(cls, ini): |
|
95 | return cls({ |
|
96 | 'enabled': field_from_ini( |
|
97 | cls.enabled, ini, |
|
98 | 'Console', 'LOG', |
|
99 | ), |
|
100 | 'file_name': field_from_ini( |
|
101 | cls.file_name, ini, |
|
102 | 'Console', 'LOGFILE', |
|
103 | ), |
|
104 | 'log_time': field_from_ini( |
|
105 | cls.log_time, ini, |
|
106 | 'Console', 'LOGTIME', |
|
107 | ), |
|
108 | 'keep_file': field_from_ini( |
|
109 | cls.keep_file, ini, |
|
110 | 'Console', 'LOGKEEP', |
|
111 | ), |
|
112 | }) |
|
113 | ||
114 | def to_ini(self, ini): |
|
115 | field_to_ini(self.enabled, ini, 'Console', 'LOG') |
|
116 | field_to_ini(self.file_name, ini, 'Console', 'LOGFILE') |
|
117 | field_to_ini(self.log_time, ini, 'Console', 'LOGTIME') |
|
118 | field_to_ini(self.keep_file, ini, 'Console', 'LOGKEEP') |
|
119 | ||
120 | @classmethod |
|
121 | def default(cls): |
|
122 | return cls({ |
|
123 | field_name: field.default |
|
124 | for field_name, field in cls.fields.items() |
|
125 | }) |
|
126 | ||
127 |