1
2
3
4
5
6
7
8
9
10
11
12
13
14 """
15 Global configuration variables.
16 """
17
18
19
20
21 import os, platform, re
22 import threading
23
24 from const import TSDIRNONE, MDDELTA_DEFAULT, REPORTFORMAT_DEFAULT,\
25 REPORTPATT_DEFAULT, REPORTTYPE_DEFAULT, REPORTPAGE_DEFAULT,\
26 REPORTFILTER_DEFAULT, LI_LENGTH, LI_CANCEL, LI_PERCENT, LI_PERCENT100,\
27 LI_PERCENTGLOBAL, LI_PERCENTPART, LI_DESC, LI_FUN2, LI_UPDATEFILTER,\
28 LI_FILTERRUNNING, LI_THREAD
29
30
31 arguments = None
32
33 z_epdl = None
34 z_epde = None
35 z_epse = None
36 Z_INEP = None
37 z_outep = None
38
39
40
41 Z_APP = None
42
43 Z_GUI = None
44
45 ISGUI = False
46
47 PYBAG_COLORIZE = True
48
49 PYBAG_DEBUG = False
50
51 PYBAG_LOG = True
52
53 PYBAG_EMUL = True
54
55
56 TSBAG = 0
57 TSORIG = 0
58 TSDIR = TSDIRNONE
59
60 VERBOSE = 3
61
62 BACKUPMODE = False
63
64 TIMEFORMAT = u'%Y-%m-%d %H:%M:%S'
65
66 IMGINDEX = {}
67
68 WRITECOLSATEXIT = False
69
70 SHOWTIPS = 0
71 TIPSNUMBER = 0
72
73
74
75
76 Z_LISTKS = []
77
78 IsDBReaded = False
79
80 IsDBCompared = False
81
82 IsDBSynced = False
83
84
85
86 Z_COLUMN_CHOISE_DEFAULT = []
87 """Columns in default order for GUI list."""
88
89 Z_COLUMN_CHOISE = []
90 """Columns."""
91
92
93
94 MDDELTA = MDDELTA_DEFAULT
95
96 REPORTFORMAT = REPORTFORMAT_DEFAULT
97 """Report format, short by default."""
98
99 REPORTPATT = REPORTPATT_DEFAULT
100 """Report wilds or RegExp filter for paths."""
101
102 REPORTPATTCMP = None
103 """Compiled report pattern."""
104
105
106
107 REPORTTYPE = REPORTTYPE_DEFAULT
108 """Report type, all by default."""
109
110
111
112 REPORTPAGE = REPORTPAGE_DEFAULT
113 """Report page size in items, unlimit by default."""
114
115
116
117 REPORTFILTER = REPORTFILTER_DEFAULT
118 """Report filter settings."""
119
120
121
122 REPORTSHOW = True
123
124
125
126
127
128
129 SYMLINKEMUL = True
130 """If True then used symlink emulation if no native support.
131 Used as default parameter in symlink functions (L{cli.symlink}, L{cli.readlink}, L{cli.symlinktest})."""
132
133 OSSEP = os.sep
134
135 OSASEP = os.altsep
136
137 OSWIN = platform.system().lower().startswith('windows')
138
139 fstream = None
140
141 Z_CP = None
142
143 Z_DB = {}
144
145 Z_KS = []
146
147 z_re_rootsec=re.compile(ur'(r\d+)')
148
149
151 """
152 Class target for easy multithreading access to variables (in list).
153
154 You create instance of this class and can from any thread easy access to
155 you variables by index (as in dictionary).
156 Example::
157 LOCK = lock_list(10)
158 LOCK[3] = False
159 val = LOCK[3]
160
161 All I{get}, I{set} and I{del} for index key will be auto locked.
162
163 @note: Safe for multithreading.
164 """
165
167 """
168 Initialize instance.
169 """
170 self._lock = threading.Lock()
171 self._attrs = range(length)
172
174 """
175 Return value for index.
176 If no such key then raise IndexError.
177 """
178 self._lock.acquire()
179 try:
180 return self._attrs[key]
181 finally:
182 self._lock.release()
183
185 """
186 Set value for index.
187 """
188 self._lock.acquire()
189 try:
190 self._attrs[key] = val
191 finally:
192 self._lock.release()
193
195 """
196 Delete index key.
197 If no such key then raise IndexError.
198
199 @raise IndexError: Index error.
200 """
201 self._lock.acquire()
202 try:
203 del self._attrs[key]
204 finally:
205 self._lock.release()
206
207
208 LOCK = lock_list(LI_LENGTH)
209
210
211
212 LOCK[LI_CANCEL] = False
213 LOCK[LI_PERCENT] = 0
214 LOCK[LI_PERCENT100] = 100
215 LOCK[LI_PERCENTGLOBAL] = 100
216 LOCK[LI_PERCENTPART] = 0
217 LOCK[LI_DESC] = u'Operation description'
218 LOCK[LI_FUN2] = False
219 LOCK[LI_UPDATEFILTER] = False
220 LOCK[LI_FILTERRUNNING] = False
221 LOCK[LI_THREAD] = False
222