forked from xibosignage/xibo-pyclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
XiboClient.py
executable file
·4814 lines (4118 loc) · 212 KB
/
XiboClient.py
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Xibo - Digitial Signage - http://www.xibo.org.uk
# Copyright (C) 2009-2014 Alex Harrington
#
# This file is part of Xibo.
#
# Xibo is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# Xibo is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Xibo. If not, see <http://www.gnu.org/licenses/>.
#
from libavg import *
from SOAPpy import WSDL
import SOAPpy.Types
import SOAPpy.Errors
import xml.parsers.expat
from xml.dom import minidom
import time
import uuid
import hashlib
import Queue
import ConfigParser
import gettext
import os
import fnmatch
import re
import datetime
import sys
import socket
import inspect
from collections import defaultdict
from threading import Thread, Semaphore
import threading
import urlparse
import PIL.Image
import math
import platform
import shutil
from ThirdParty.period.period import in_period
version = "1.6.0-rc2"
# What layout schema version is supported
schemaVersion = 1
#### Abstract Classes
class XiboLog:
"Abstract Class - Interface for Loggers"
level = 0
def __init__(self, level): abstract
def log(self, level, category, message, osd = False): abstract
def stat(self, statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID): abstract
def setXmds(self, xmds):
pass
def flush(self):
pass
def setupInfo(self, p):
self.p = p
try:
self.liftEnabled = config.get('Lift', 'enabled')
if self.liftEnabled == "false":
self.liftEnabled = False
log.log(3, "audit", _("Disabling lift functionality in Logger"))
else:
self.liftEnabled = True
log.log(3, "audit", _("Enabling lift functionality in Logger"))
except:
self.liftEnabled = False
log.log(3, "error", _("Lift->enabled not defined in configuration. Disabling lift functionality in Logger"))
# Populate the info screen
# Background.
tmpXML = '<rect fillcolor="ffffff" id="infoBG" fillopacity="0.75" size="(400,300)" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Logo + version bottom right
tmpXML = '<image href="resources/logo.png" id="infoLOGO" opacity="1" width="50" height="18" x="345" y="276" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words x="290" y="280" opacity="1" text="v' + version + '" font="Arial" color="000000" fontsize="12" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Required Files Traffic Light
tmpXML = '<image href="resources/dotgrey.png" id="infoRFGrey" opacity="1" width="20" height="20" x="5" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoRFRed" opacity="0" width="20" height="20" x="5" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoRFAmber" opacity="0" width="20" height="20" x="5" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoRFGreen" opacity="0" width="20" height="20" x="5" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words x="10" y="270" opacity="1" text="Required Files" font="Arial" color="000000" fontsize="10" angle="-1.57079633" pivot="(0,0)"/>'
self.p.enqueue('add' ,(tmpXML, 'info'))
# GetFile Traffic Light
tmpXML = '<image href="resources/dotgrey.png" id="infoGFGrey" opacity="1" width="20" height="20" x="30" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoGFRed" opacity="0" width="20" height="20" x="30" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoGFAmber" opacity="0" width="20" height="20" x="30" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoGFGreen" opacity="0" width="20" height="20" x="30" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words x="35" y="270" opacity="1" text="Get File" font="Arial" color="000000" fontsize="10" angle="-1.57079633" pivot="(0,0)"/>'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words id="infoRunningDownloads" x="37" y="278" opacity="1" text="0" font="Arial" color="000000" fontsize="10" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Schedule Traffic Light
tmpXML = '<image href="resources/dotgrey.png" id="infoSGrey" opacity="1" width="20" height="20" x="55" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoSRed" opacity="0" width="20" height="20" x="55" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoSAmber" opacity="0" width="20" height="20" x="55" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoSGreen" opacity="0" width="20" height="20" x="55" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words x="60" y="270" opacity="1" text="Schedule" font="Arial" color="000000" fontsize="10" angle="-1.57079633" pivot="(0,0)"/>'
self.p.enqueue('add', (tmpXML, 'info'))
# RegisterDisplay Traffic Light
tmpXML = '<image href="resources/dotgrey.png" id="infoRDGrey" opacity="1" width="20" height="20" x="80" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoRDRed" opacity="0" width="20" height="20" x="80" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoRDAmber" opacity="0" width="20" height="20" x="80" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoRDGreen" opacity="0" width="20" height="20" x="80" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words x="85" y="270" opacity="1" text="Register Display" font="Arial" color="000000" fontsize="10" angle="-1.57079633" pivot="(0,0)"/>'
self.p.enqueue('add', (tmpXML, 'info'))
# Logs Traffic Light
tmpXML = '<image href="resources/dotgrey.png" id="infoLogGrey" opacity="1" width="20" height="20" x="105" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLogRed" opacity="0" width="20" height="20" x="105" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLogAmber" opacity="0" width="20" height="20" x="105" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLogGreen" opacity="0" width="20" height="20" x="105" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words x="110" y="270" opacity="1" text="Log" font="Arial" color="000000" fontsize="10" angle="-1.57079633" pivot="(0,0)"/>'
self.p.enqueue('add', (tmpXML, 'info'))
# Stats Traffic Light
tmpXML = '<image href="resources/dotgrey.png" id="infoStatGrey" opacity="1" width="20" height="20" x="130" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoStatRed" opacity="0" width="20" height="20" x="130" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoStatAmber" opacity="0" width="20" height="20" x="130" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoStatGreen" opacity="0" width="20" height="20" x="130" y="275" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words x="135" y="270" opacity="1" text="Stats" font="Arial" color="000000" fontsize="10" angle="-1.57079633" pivot="(0,0)"/>'
self.p.enqueue('add', (tmpXML, 'info'))
# Offline Update traffic light
tmpXML = '<image href="resources/dotamber.png" id="offlineUpdateAmber" opacity="0" width="20" height="20" x="20" y="20" />'
self.p.enqueue('add', (tmpXML, 'offlineUpdate'))
tmpXML = '<image href="resources/dotgreen.png" id="offlineUpdateGreen" opacity="0" width="20" height="20" x="20" y="20" />'
self.p.enqueue('add', (tmpXML, 'offlineUpdate'))
# IP Address
tmpXML = '<words x="5" y="5" opacity="1" text="IP Address: " font="Arial" color="000000" fontsize="11" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words id="infoIP" x="75" y="5" opacity="1" text="" font="Arial" color="000000" fontsize="11" width="180" linespacing="10" alignment="left" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Disk Space
tmpXML = '<words x="5" y="18" opacity="1" text="Disk Space: " font="Arial" color="000000" fontsize="11" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words id="infoDisk" x="75" y="18" opacity="1" text="" font="Arial" color="000000" fontsize="11" width="180" linespacing="10" alignment="left" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Lift Traffic Lights
if self.liftEnabled:
tmpXML = '<image href="resources/dotgrey.png" id="infoLift1Grey" opacity="1" width="5" height="5" x="165" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift1Red" opacity="0" width="5" height="5" x="165" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift1Amber" opacity="0" width="5" height="5" x="165" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift1Green" opacity="0" width="5" height="5" x="165" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift2Grey" opacity="1" width="5" height="5" x="170" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift2Red" opacity="0" width="5" height="5" x="170" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift2Amber" opacity="0" width="5" height="5" x="170" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift2Green" opacity="0" width="5" height="5" x="170" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift3Grey" opacity="1" width="5" height="5" x="175" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift3Red" opacity="0" width="5" height="5" x="175" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift3Amber" opacity="0" width="5" height="5" x="175" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift3Green" opacity="0" width="5" height="5" x="175" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift4Grey" opacity="1" width="5" height="5" x="180" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift4Red" opacity="0" width="5" height="5" x="180" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift4Amber" opacity="0" width="5" height="5" x="180" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift4Green" opacity="0" width="5" height="5" x="180" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift5Grey" opacity="1" width="5" height="5" x="190" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift5Red" opacity="0" width="5" height="5" x="190" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift5Amber" opacity="0" width="5" height="5" x="190" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift5Green" opacity="0" width="5" height="5" x="190" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift6Grey" opacity="1" width="5" height="5" x="195" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift6Red" opacity="0" width="5" height="5" x="195" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift6Amber" opacity="0" width="5" height="5" x="195" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift6Green" opacity="0" width="5" height="5" x="195" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift7Grey" opacity="1" width="5" height="5" x="200" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift7Red" opacity="0" width="5" height="5" x="200" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift7Amber" opacity="0" width="5" height="5" x="200" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift7Green" opacity="0" width="5" height="5" x="200" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift8Grey" opacity="1" width="5" height="5" x="205" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift8Red" opacity="0" width="5" height="5" x="205" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift8Amber" opacity="0" width="5" height="5" x="205" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift8Green" opacity="0" width="5" height="5" x="205" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift9Grey" opacity="1" width="5" height="5" x="215" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift9Red" opacity="0" width="5" height="5" x="215" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift9Amber" opacity="0" width="5" height="5" x="215" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift9Green" opacity="0" width="5" height="5" x="215" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift10Grey" opacity="1" width="5" height="5" x="220" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift10Red" opacity="0" width="5" height="5" x="220" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift10Amber" opacity="0" width="5" height="5" x="220" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift10Green" opacity="0" width="5" height="5" x="220" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift11Grey" opacity="1" width="5" height="5" x="225" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift11Red" opacity="0" width="5" height="5" x="225" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift11Amber" opacity="0" width="5" height="5" x="225" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift11Green" opacity="0" width="5" height="5" x="225" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift12Grey" opacity="1" width="5" height="5" x="230" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift12Red" opacity="0" width="5" height="5" x="230" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift12Amber" opacity="0" width="5" height="5" x="230" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift12Green" opacity="0" width="5" height="5" x="230" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift13Grey" opacity="1" width="5" height="5" x="240" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift13Red" opacity="0" width="5" height="5" x="240" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift13Amber" opacity="0" width="5" height="5" x="240" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift13Green" opacity="0" width="5" height="5" x="240" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift14Grey" opacity="1" width="5" height="5" x="245" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift14Red" opacity="0" width="5" height="5" x="245" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift14Amber" opacity="0" width="5" height="5" x="245" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift14Green" opacity="0" width="5" height="5" x="245" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift15Grey" opacity="1" width="5" height="5" x="250" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift15Red" opacity="0" width="5" height="5" x="250" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift15Amber" opacity="0" width="5" height="5" x="250" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift15Green" opacity="0" width="5" height="5" x="250" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgrey.png" id="infoLift16Grey" opacity="1" width="5" height="5" x="255" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotred.png" id="infoLift16Red" opacity="0" width="5" height="5" x="255" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotamber.png" id="infoLift16Amber" opacity="0" width="5" height="5" x="255" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<image href="resources/dotgreen.png" id="infoLift16Green" opacity="0" width="5" height="5" x="255" y="285" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Lift Tag
tmpXML = '<words id="infoLiftTag" x="165" y="265" opacity="1" text="Current Tag: default" font="Arial" color="000000" fontsize="11" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Schedule
tmpXML = '<words x="5" y="75" opacity="1" text="Schedule" font="Arial" color="000000" fontsize="14" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words id="infoCurrentSchedule" x="5" y="90" opacity="1" text="" font="Arial" color="000000" fontsize="11" width="180" linespacing="10" alignment="left" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Now Playing
tmpXML = '<words x="5" y="40" opacity="1" text="Now Playing" font="Arial" color="000000" fontsize="14" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words id="infoNowPlaying" x="5" y="55" opacity="1" text="" font="Arial" color="000000" fontsize="11" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Media
tmpXML = '<words x="205" y="5" opacity="1" text="Media" font="Arial" color="000000" fontsize="14" />'
self.p.enqueue('add', (tmpXML, 'info'))
tmpXML = '<words id="infoMedia" x="205" y="20" opacity="1" text="" font="Arial" color="000000" fontsize="11" />'
self.p.enqueue('add', (tmpXML, 'info'))
# On Screen Logging
tmpXML = '<rect fillcolor="ffffff" id="osLogBG" fillopacity="0.75" size="(%d,%d)" />' % (self.p.osLogX, 20)
self.p.enqueue('add', (tmpXML, 'osLog'))
tmpXML = '<words id="osLogText" x="5" y="3" opacity="1" text="Xibo Client v%s" font="Arial" color="000000" fontsize="11" />' % version
self.p.enqueue('add', (tmpXML, 'osLog'))
def lights(self, field, value):
if value == "green":
self.p.enqueue('setOpacity', ("info" + field + "Green", 1))
self.p.enqueue('setOpacity', ("info" + field + "Grey", 0))
self.p.enqueue('setOpacity', ("info" + field + "Amber", 0))
self.p.enqueue('setOpacity', ("info" + field + "Red", 0))
if value == "red":
self.p.enqueue('setOpacity', ("info" + field + "Green", 0))
self.p.enqueue('setOpacity', ("info" + field + "Grey", 0))
self.p.enqueue('setOpacity', ("info" + field + "Amber", 0))
self.p.enqueue('setOpacity', ("info" + field + "Red", 1))
if value == "amber":
self.p.enqueue('setOpacity', ("info" + field + "Green", 0))
self.p.enqueue('setOpacity', ("info" + field + "Grey", 0))
self.p.enqueue('setOpacity', ("info" + field + "Amber", 1))
self.p.enqueue('setOpacity', ("info" + field + "Red", 0))
if value == "grey":
self.p.enqueue('setOpacity', ("info" + field + "Green", 0))
self.p.enqueue('setOpacity', ("info" + field + "Grey", 1))
self.p.enqueue('setOpacity', ("info" + field + "Amber", 0))
self.p.enqueue('setOpacity', ("info" + field + "Red", 0))
if value == "start":
self.p.enqueue('setOpacity', ("%sAmber" % field, 1))
self.p.enqueue('setOpacity', ("%sGreen" % field, 0))
if value == "finish":
self.p.enqueue('setOpacity', ("%sAmber" % field, 0))
self.p.enqueue('setOpacity', ("%sGreen" % field, 1))
self.p.enqueue('anim', ('fadeOut', '%sGreen' % field, 3000, None))
def updateSchedule(self, schedule):
self.p.enqueue('del', 'infoCurrentSchedule')
tmpXML = '<words id="infoCurrentSchedule" x="5" y="90" opacity="1" text="' + schedule + '" font="Arial" color="000000" fontsize="11" width="180" linespacing="10" alignment="left" />'
self.p.enqueue('add', (tmpXML, 'info'))
def updateNowPlaying(self, now):
self.p.enqueue('del', 'infoNowPlaying')
tmpXML = '<words id="infoNowPlaying" x="5" y="55" opacity="1" text="' + now + '" font="Arial" color="000000" fontsize="11" />'
self.p.enqueue('add', (tmpXML, 'info'))
def updateMedia(self, media):
self.p.enqueue('del', 'infoMedia')
tmpXML = '<words id="infoMedia" x="205" y="20" opacity="1" font="Arial" color="000000" fontsize="11" width="180">' + media + '</words>'
self.p.enqueue('add', (tmpXML, 'info'))
def updateRunningDownloads(self, num):
self.p.enqueue('del', 'infoRunningDownloads')
tmpXML = '<words id="infoRunningDownloads" x="37" y="278" opacity="1" text="' + str(num) + '" font="Arial" color="000000" fontsize="10" />'
self.p.enqueue('add', (tmpXML, 'info'))
def updateIP(self, serverIP):
self.p.enqueue('del', 'infoIP')
tmpXML = '<words id="infoIP" x="75" y="5" opacity="1" text="' + str(serverIP) + '" font="Arial" color="000000" fontsize="10" />'
self.p.enqueue('add', (tmpXML, 'info'))
def updateFreeSpace(self, tup):
perc = int((tup[1] * 1.0 / tup[0]) * 100)
self.p.enqueue('del', 'infoDisk')
tmpXML = '<words id="infoDisk" x="75" y="18" opacity="1" text="' + self.bytestr(tup[1]) + ' (' + str(perc) + '%) free" font="Arial" color="000000" fontsize="10" />'
self.p.enqueue('add', (tmpXML, 'info'))
# Convert a value in bytes to human readable format
# Taken from http://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
# By Sridhar Ratnakumar
# Assumed Public Domain
def bytestr(self, size):
for x in ['bytes', 'KB', 'MB', 'GB', 'TB']:
if size < 1024.0:
return "%3.1f %s" % (size, x)
size /= 1024.0
def updateLift(self, tag):
# Break out if lift is disabled
if not self.liftEnabled:
return
self.p.enqueue('del', 'infoLiftTag')
tmpXML = '<words id="infoLiftTag" x="165" y="265" opacity="1" text="Current Tag: ' + tag + '" font="Arial" color="000000" fontsize="11" />'
self.p.enqueue('add', (tmpXML, 'info'))
def osLog(self, message):
self.p.enqueue('del', 'osLogText')
tmpXML = '<words id="osLogText" x="5" y="3" opacity="1" text="%s" font="Arial" color="000000" fontsize="11" />' % message
self.p.enqueue('add', (tmpXML, 'osLog'))
class XiboScheduler(Thread):
"Abstract Class - Interface for Schedulers"
def run(self): abstract
def nextLayout(self): abstract
def hasNext(self): abstract
#### Finish Abstract Classes
#### Log Classes
class XiboLogSplit(XiboLog):
"Xibo Log Splitter - so log output can go to two log objects"
# Currently non-functional
def __init__(self,level):
self.level = int(level)
logWriter1 = config.get('Logging','splitLogWriter1')
logWriter2 = config.get('Logging','splitLogWriter2')
self.log1 = eval(logWriter1)(self.level)
self.log2 = eval(logWriter2)(self.level)
self.log(2,"info",_("XiboLogSplit logger started at level ") + str(level))
def log(self, severity, category, message, osd=False):
self.log1.log(severity, category, message, osd)
self.log2.log(severity, category, message, osd)
def stat(self, statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID=""):
self.log1.stat(statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID)
self.log2.stat(statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID)
def flush(self):
self.log1.flush()
self.log2.flush()
class XiboLogFile(XiboLog):
"Xibo Logger - to file"
def __init__(self,level):
try:
self.fh = open('run.log','w')
except:
print "Unable to open run.log for writing."
# Make sure level is sane
if level == "" or int(level) < 0:
level=0
self.level = int(level)
self.log(2,"info",_("XiboLogFile logger started at level ") + str(level))
def log(self, severity, category, message, osd=False):
if self.level >= severity:
# Define these two here incase an exception is thrown below.
callingMethod = "unknown"
callingClass = ""
try:
currFrame = inspect.currentframe().f_back
inspArray = inspect.getframeinfo(currFrame)
callingMethod = inspArray[2]
callingLineNumber = inspArray[1]
# TODO: Figure out how to get the class name too
callingClass = ""
finally:
del currFrame
function = callingClass + "." + callingMethod
date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
self.fh.write("LOG: " + str(date) + " (" + str(function) + ":" + str(callingLineNumber) + ") " + str(severity) + " " + category + " " + message + "\n")
self.fh.flush()
# If osLog is enabled, update the status
if osd and self.p.osLog:
self.osLog(message)
def stat(self,statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID):
pass
class XiboLogScreen(XiboLog):
"Xibo Logger - to screen"
def __init__(self,level):
# Make sure level is sane
if level == "" or int(level) < 0:
level=0
self.level = int(level)
self.log(2,"info",_("XiboLogScreen logger started at level ") + str(level))
def log(self, severity, category, message, osd=False):
if self.level >= severity:
print "LOG: " + str(time.time()) + " " + str(severity) + " " + category + " " + message
# If osLog is enabled, update the status
if osd and self.p.osLog:
self.osLog(message)
def stat(self, statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID=""):
print "STAT: " + statType + " " + tag + " " + str(layoutID) + " " + str(scheduleID) + " " + str(mediaID)
class XiboLogXmds(XiboLog):
def __init__(self,level):
# Make sure level is sane
if level == "" or int(level) < 0:
level=0
self.level = int(level)
self.logs = Queue.Queue(0)
self.stats = Queue.Queue(0)
# Find out if we're doing stats, and how big the queue should be...
try:
statsOn = config.get('Stats','collect')
if statsOn == 'true':
self.statsOn = True
else:
self.statsOn = False
except ConfigParser.NoOptionError:
self.statsOn = False
try:
self.statsQueueSize = int(config.get('Stats','queueSize'))
except ConfigParser.NoOptionError:
self.statsQueueSize = 99
self.worker = XiboLogXmdsWorker(self.logs,self.stats,self.statsQueueSize)
self.worker.start()
# Fast non-blocking log and stat functions
# Logs and Stats pushed in native format on to the queue.
# A worker thread will then format the messages in to XML
# ready for transmission to the server.
def log(self, severity, category, message, osd=False):
if self.level >= severity:
try:
currFrame = inspect.currentframe().f_back
inspArray = inspect.getframeinfo(currFrame)
callingMethod = inspArray[2]
callingLineNumber = inspArray[1]
# TODO: Figure out how to get the class name too
callingClass = ""
finally:
del currFrame
function = callingClass + "." + callingMethod
date = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
self.logs.put((date,severity,category,function,callingLineNumber,message),False)
# If osLog is enabled, update the status
if osd and self.p.osLog:
self.osLog(message)
def stat(self, statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID):
if self.statsOn:
self.stats.put((statType,fromDT,toDT,tag,layoutID,scheduleID,mediaID),False)
return
def setXmds(self,xmds):
self.worker.xmds = xmds
def flush(self):
# TODO: Seems to cause the client to hang on quit?
if not self.worker.xmds is None:
self.worker.flush = True
self.worker.process()
class XiboLogXmdsWorker(Thread):
def __init__(self,logs,stats,statsQueueSize):
Thread.__init__(self)
self.xmds = None
self.logs = logs
self.stats = stats
self.running = True
self.statXml = minidom.Document()
self.statsE = self.statXml.createElement("stat")
self.statXml.appendChild(self.statsE)
self.statsQueueSize = statsQueueSize
self.logXml = minidom.Document()
self.logE = self.logXml.createElement("log")
self.logXml.appendChild(self.logE)
self.flush = False
self.processing = False
self.__lock = Semaphore()
def run(self):
# Wait for XMDS to be initialised and available to us
while self.xmds is None:
time.sleep(60)
while self.running:
if (self.processing):
pass
else:
self.process()
time.sleep(30)
def process(self):
self.__lock.acquire()
self.processing = True
# Deal with logs:
try:
# Prepare logs to XML and store in self.logXml
while True:
date, severity, category, function, lineNo, message = self.logs.get(False)
traceE = self.logXml.createElement("trace")
traceE.setAttribute("date",date)
traceE.setAttribute("category",category)
self.logE.appendChild(traceE)
messageE = self.logXml.createElement("message")
messageTxt = self.logXml.createTextNode(message)
messageE.appendChild(messageTxt)
scheduleE = self.logXml.createElement("scheduleid")
layoutE = self.logXml.createElement("layoutid")
mediaE = self.logXml.createElement("mediaid")
methodE = self.logXml.createElement("method")
methodTxt = self.logXml.createTextNode(function)
methodE.appendChild(methodTxt)
lineE = self.logXml.createElement("line")
lineTxt = self.logXml.createTextNode(str(lineNo))
lineE.appendChild(lineTxt)
traceE.appendChild(messageE)
traceE.appendChild(scheduleE)
traceE.appendChild(layoutE)
traceE.appendChild(mediaE)
traceE.appendChild(methodE)
traceE.appendChild(lineE)
except Queue.Empty:
# Exception thrown breaks the inner while loop
# Do nothing
pass
if len(self.logE.childNodes) > 0:
# Get each trace in turn and send it to XMDS
traceNodes = self.logXml.getElementsByTagName('trace')
nExceptions = 0
xml = '<log>'
nodes = []
nProcessed = 0
for trace in traceNodes:
# Ship the logXml off to XMDS
if len(nodes) < 10:
nProcessed += 1
nodes.append(trace)
xml += trace.toxml()
if len(nodes) >= 10 or nProcessed == len(traceNodes):
try:
self.xmds.SubmitLog(xml + "</log>")
xml = '<log>'
for n in nodes:
self.logE.removeChild(n)
nodes = []
except XMDSException:
nExceptions += 1
if nExceptions > 4:
break
except:
pass
if len(self.logXml.getElementsByTagName('trace')) > 0:
# Some logs didn't send
# Flush to disk
# Check the log folder exists:
try:
os.makedirs(config.get('Main','libraryDir') + os.sep + 'log')
except:
pass
try:
try:
f = open(config.get('Main','libraryDir') + os.sep + 'log' + os.sep + 'log' + str(time.time()) + '.ready','w')
f.write(self.logXml.toprettyxml())
self.logXml.unlink()
self.logXml = minidom.Document()
self.logE = self.logXml.createElement("log")
self.logXml.appendChild(self.logE)
finally:
f.close()
except:
pass
else:
# All the logs send
# Read in a past log file and append to logE for processing on the next run
readOne = False
# If this is a flush being called, skip reading in a new file as it will be lost in memory.
if self.flush:
readOne = True
# Check the log folder exists:
try:
os.makedirs(config.get('Main','libraryDir') + os.sep + 'log')
except:
pass
for f in os.listdir(config.get('Main','libraryDir') + os.sep + 'log'):
if readOne == False:
if fnmatch.fnmatch(f, '*.ready'):
try:
self.logXml.unlink()
self.logXml = minidom.parse(config.get('Main','libraryDir') + os.sep + 'log' + os.sep + f)
for n in self.logXml.getElementsByTagName('log'):
self.logE = n
except:
# File must be invalid. Delete it
try:
os.remove(config.get('Main','libraryDir') + os.sep + 'log' + os.sep + f)
except:
readOne = False
continue
# Now the file is back in memory, delete it
try:
os.remove(config.get('Main','libraryDir') + os.sep + 'log' + os.sep + f)
readOne = True
except:
pass
# Deal with stats:
try:
# Prepare stats to XML and store in self.statXml
while True:
statType, fromDT, toDT, tag, layoutID, scheduleID, mediaID = self.stats.get(False)
statE = self.statXml.createElement("stat")
statE.setAttribute("type",statType)
statE.setAttribute("fromdt",fromDT)
statE.setAttribute("todt",toDT)
if statType == "event":
statE.setAttribute("tag",tag)
elif statType == "media":
statE.setAttribute("mediaid",mediaID)
statE.setAttribute("layoutid",layoutID)
elif statType == "layout":
statE.setAttribute("layoutid",layoutID)
statE.setAttribute("scheduleid",scheduleID)
self.statsE.appendChild(statE)
except Queue.Empty:
# Exception thrown breaks the inner while loop
# Do nothing
pass
if len(self.statsE.childNodes) >= self.statsQueueSize or self.flush:
self.flush = False
try:
# Ship the statXml off to XMDS
self.xmds.SubmitStats(self.statXml.toxml())
# Reset statXml
self.statXml = minidom.Document()
self.statsE = self.logXml.createElement("stats")
self.statXml.appendChild(self.statsE)
try:
os.remove(config.get('Main','libraryDir') + os.sep + 'stats.xml')
except:
pass
except XMDSException:
# Flush to disk incase we crash before getting another chance
try:
try:
f = open(config.get('Main','libraryDir') + os.sep + 'stats.xml','w')
f.write(self.statXml.toprettyxml())
finally:
f.close()
except:
pass
self.processing = False
self.__lock.release()
#### Finish Log Classes
#### Download Manager
class XiboFile(object):
def __init__(self,fileName,targetHash,fileId,fileType,mtime=0):
self.__path = os.path.join(config.get('Main','libraryDir'),fileName)
self.__fileName = fileName
self.md5 = "NOT CALCULATED"
self.checkTime = 1
self.fileType = fileType
self.fileId = fileId
self.targetHash = targetHash
self.mtime = mtime
self.paranoid = config.getboolean('Main','checksumPreviousDownloads')
if self.paranoid:
self.update()
else:
self.paranoid = False
try:
if os.path.getmtime(self.__path) == self.mtime:
self.md5 = self.targetHash
else:
self.update()
except:
self.update()
def update(self):
# Generate MD5
m = hashlib.md5()
try:
# print "*** GENERATING MD5 for file %s" % self.__fileName
for line in open(self.__path,"rb"):
m.update(line)
except IOError:
# print "*** IOERROR"
return False
self.md5 = m.hexdigest()
self.mtime = os.path.getmtime(self.__path)
self.checkTime = time.time()
return True
def isExpired(self):
if self.paranoid:
return self.checkTime + 3600 < time.time()
else:
try:
tmpMtime = os.path.getmtime(self.__path)
except:
return False
return not self.mtime == tmpMtime
def isValid(self):
try:
tmpMtime = os.path.getmtime(self.__path)
except:
return False
return (self.md5 == self.targetHash) and (self.mtime == tmpMtime)
def toTuple(self):
return (self.__fileName,self.md5,self.targetHash,self.checkTime,self.mtime,self.fileId,self.fileType)
class XiboResourceFile(object):
def __init__(self,fileName,targetHash,fileId,fileType,mtime=0):
self.__path = os.path.join(config.get('Main','libraryDir'),fileName)
self.__fileName = fileName
self.md5 = "NOT CALCULATED"
self.checkTime = 1
self.fileType = fileType
self.fileId = fileId
self.paranoid = False
self.targetHash = targetHash
self.mtime = mtime
try:
if os.path.getmtime(self.__path) == self.mtime:
self.md5 = self.targetHash
else:
self.update()
except:
self.update()
def update(self):
try:
tmpMtime = os.path.getmtime(self.__path)
except:
return False
self.mtime = tmpMtime
self.checkTime = time.time()
return True
def isExpired(self):
try:
tmpMtime = os.path.getmtime(self.__path)
except:
return False
return not self.mtime == tmpMtime
def isValid(self):
try:
tmpMtime = os.path.getmtime(self.__path)
except:
return False
return True
def toTuple(self):
return (self.__fileName,self.targetHash,self.targetHash,self.checkTime,self.mtime,self.fileId,self.fileType)
class XiboDownloadManager(Thread):
def __init__(self,xmds,player,parent):
Thread.__init__(self)
log.log(3,"info",_("New XiboDownloadManager instance created."))
self.xmds = xmds
self.running = True
self.dlQueue = Queue.Queue(0)
self.p = player # XiboPlayer Instance
self.parent = parent # Parent XiboDisplayManager Instance
self.__lock = Semaphore()
self.__lock.acquire()
self.offline = config.getboolean('Main','manualUpdate')
self.nextLayoutOnComplete = False
self.chainScheduler = False
self.cleanup = config.getboolean('Main','cleanOldMediaFiles')
self.lastCleanup = 0
# Store a dictionary of XiboDownloadThread objects so we know
# which files are downloading and how many download slots
# there are free
self.runningDownloads = defaultdict(XiboDownloadThread)
# How many XiboDownloadThreads should run at once
self.maxDownloads = 5
# Populate md5Cache
if config.get('Main','checksumPreviousDownloads') == "false":
try:
tmpDoc = minidom.parse(os.path.join(config.get('Main','libraryDir'),'cache.xml'))
for f in tmpDoc.getElementsByTagName('file'):
tmpFileName = str(f.attributes['name'].value)
tmpHash = str(f.attributes['md5'].value)
tmpMtime = float(f.attributes['mtime'].value)
tmpId = int(f.attributes['id'].value)
tmpType = str(f.attributes['type'].value)
if tmpType == 'resource':
tmpFile = XiboResourceFile(tmpFileName,tmpHash,tmpId,tmpType,tmpMtime)
else:
tmpFile = XiboFile(tmpFileName,tmpHash,tmpId,tmpType,tmpMtime)
md5Cache[tmpFileName] = tmpFile
except IOError:
log.log(0,"warning",_("Could not open cache.xml. Starting with an empty cache"),True)
except:
log.log(0,"warning",_("md5Cache file is corrupted. Ignoring."),True)
def run(self):
log.log(2,"info",_("New XiboDownloadManager instance started."))
while (self.running):
self.interval = 300
# Flag to note if on this loop we downloaded new files
updatedContent = False
# Find out how long we should wait between updates.
try:
self.interval = int(config.get('Main','xmdsUpdateInterval'))
except:
# self.interval has been set to a sensible default in this case.
log.log(0,"warning",_("No XMDS Update Interval specified in your configuration"),True)
log.log(0,"warning",_("Please check your xmdsUpdateInterval configuration option"))