3
# -*- coding: utf-8 -*-
6
# Xibo - Digitial Signage - http://www.xibo.org.uk
7
# Copyright (C) 2011 Matt Holder
9
# This file is part of Xibo.
11
# Xibo is free software: you can redistribute it and/or modify
12
# it under the terms of the GNU Affero General Public License as published by
13
# the Free Software Foundation, either version 3 of the License, or
16
# Xibo is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU Affero General Public License for more details.
21
# You should have received a copy of the GNU Affero General Public License
22
# along with Xibo. If not, see <http://www.gnu.org/licenses/>.
25
gettextAvailable = None
29
gettextAvailable = True
31
print "Could not import gettext"
32
print "Creating dummy function for _()"
38
print "Could not import sys module"
44
print "Could not import uuid module"
50
print "Could not import ConfigParser module"
56
print "Could not import os module"
62
print "Could not import logging module"
69
print "Could not import pygtk"
75
print "Could not import gtk"
81
print "Could not import gtk.glade"
87
print "Could not import gobject"
90
#Only run this if gettext is available
92
gettext.install('ivcm', './locale', unicode=False)
96
"""This is the PyWine application"""
99
def __init__(self,clientConfFile,lift = False):
101
#This is the location of the config. file for the client
102
#itself. This comes from when the instance of the class
104
self.clientConfFile = clientConfFile
106
#Firstly, read in the values relating to log from the config. client config. file
109
config = ConfigParser.ConfigParser()
110
config.read(self.clientConfFile)
112
print "Could not open %s"%self.clientConfFile
114
#Xibo client configuration file name
115
logFileName="error.log"
117
logFileName = config.get('Main','logFileName')
121
logWriter="xiboLogScreen"
123
logWriter = config.get('Main','logWriter')
130
logLevel = config.get('Main','logLevel')
136
if logLevel == "INFO":
137
loggingLevel = a.INFO
138
elif logLevel == "WARNING":
139
loggingLevel = a.WARNING
140
elif logLevel == "ERROR":
141
loggingLevel = a.ERROR
143
if logWriter == "xiboLogScreen":
144
a.basicConfig(level=loggingLevel)
145
elif logWriter == "xiboLogFile":
147
a.basicConfig(level=loggingLevel,filename=logFileName,filemode="w")
150
# logging.basicConfig(level=logging.INFO,filename="error.log",filemode="w")
151
# #format='%(asctime)s %(levelname)s %(lineno)d %(message)s'
154
self.logger = a.getLogger("PyClientConfig")
155
self.logger1 = a.getLogger("PyClientConfig.GUI")
156
self.logger2 = a.getLogger('PyClientConfig.readConfig')
157
self.logger3 = a.getLogger("PyClientConfig.saveConfigSignal")
158
self.logger4 = a.getLogger("PyClientConfig.genClientID")
159
self.logger5 = a.getLogger("PyClientConfig.getConfValues")
160
self.logger6 = a.getLogger("PyClientConfig.advancedOptionsCheck")
161
self.logger7 = a.getLogger("PyClientConfig.readConfigAppConf")
162
self.logger8 = a.getLogger("PyClientConfig.offlineOperationToggle")
163
self.logger9 = a.getLogger("PyClientConfig.clearFormSignal")
164
self.logger10 = a.getLogger("PyClientConfig.onDestroy")
165
self.logger11 = a.getLogger("PyClientConfig.saveSignal")
166
self.logger12 = a.getLogger("PyclientConfig.LoadDefaultValues")
168
self.logger1.info('Config. client config. file: %s'%self.clientConfFile)
170
self.logger1.info("logWriter: %s"%logWriter)
171
self.logger1.info("logLevel: %s"%logLevel)
172
self.logger.info("logFileName: %s"%logFileName)
174
#Name of the default log file for the python client
175
self.pyClientLogName = "run.log"
178
#Read out the values from the client configuration file
179
configValues = self.readConfigAppConf()
181
#Take the options for log type from the file, and set the
182
#class instance variable. The combo box is then populated from this.
183
self.logWriterTypes = configValues["logTypeOptions"]
185
self.logger1.info("logWriter: %s"%self.logWriterTypes)
187
#Take the options for the human readable log type options
188
self.logWriterHumanTypes = configValues["logTypeHumanOptions"]
190
self.logger1.info("logWriteHumanOptions: %s"%self.logWriterHumanTypes)
192
#Take the location of the configuration file and set the class
193
#instance variable. This path is then used when the config.
196
self.pyClientConfName = configValues["xiboClientConf"]
199
self.logger1.info("Xibo client config. file: %s"%self.pyClientConfName)
201
self.pyClientConfDefaultsName = "defaults.cfg"
203
#Grab the directory location and check this directory exists.
205
self.pyclientConfPath = configValues["clientConfLoc"]
207
self.logger1.info("Xibo client config. file path: %s"%self.pyclientConfPath)
209
self.logger1.info("Config file combined path: %s"%os.path.join(self.pyclientConfPath,self.pyClientConfName))
211
#Take the options for scheduler type and add them to a class
214
self.schedulerOptions = configValues["schedulerOptions"]
216
#Add a blank entry to the combo box, so that a blank option
217
#can mean that the value is not written to the config. file
218
self.schedulerOptions.insert(0,"")
221
self.downloaderOptions = configValues["downloaderOptions"]
222
self.downloaderOptions.insert(0,"")
224
#Colour Depth options
225
self.colourDepthOptions = configValues["colourDepthOptions"]
226
self.colourDepthOptions.insert(0,"")
229
self.liftEnableOptions = ["True","False"]
231
#Manual update options
232
self.manualUpdateOptions = ["True","False"]
235
self.builder = gtk.Builder()
236
self.builder.add_from_file("gui.glade")
237
self.builder.connect_signals(self)
239
#Create instances of the text fields, window etc
240
self.window = self.builder.get_object("mainWindow")
241
self.clearButton = self.builder.get_object("clearFields")
242
self.saveButton = self.builder.get_object("saveConfig")
244
self.serverURLText = self.builder.get_object("serverURLText")
245
self.clientIDText = self.builder.get_object("clientIDText")
246
self.serverKeyText = self.builder.get_object("serverKeyText")
247
self.refreshText = self.builder.get_object("refreshText")
248
self.serverConnBool = self.builder.get_object("serverConnection")
249
self.fullScreenBool = self.builder.get_object("fullScreen")
250
self.screenWidthText = self.builder.get_object("screenWidthText")
251
self.screenHeightText = self.builder.get_object("screenHeightText")
252
self.captureStatisticsBool = self.builder.get_object("captureStatistics")
253
self.queueSizeText = self.builder.get_object("queueSizeText")
254
self.logLevelSpin = self.builder.get_object("logLevelSpin")
255
self.logTypeCombo = self.builder.get_object("logTypeCombo")
256
self.clientNameText = self.builder.get_object("clientNameText")
258
self.offlineCheckButton = self.builder.get_object("offlineCheckButton")
260
#Advanced options widgets
262
self.liftDefaultTagText = self.builder.get_object('liftDefaultTagText')
263
self.lift7TagText = self.builder.get_object('lift7TagText')
264
self.lift6TagText = self.builder.get_object('lift6TagText')
265
self.lift5TagText = self.builder.get_object('lift5TagText')
266
self.lift4TagText = self.builder.get_object('lift4TagText')
267
self.lift3TagText = self.builder.get_object('lift3TagText')
268
self.lift2TagText = self.builder.get_object('lift2TagText')
269
self.lift1TagText = self.builder.get_object('lift1TagText')
270
self.lift0TagText = self.builder.get_object('lift0TagText')
271
self.firstSerialText = self.builder.get_object('firstSerialText')
272
self.secondSerialText = self.builder.get_object('secondSerialText')
273
self.liftTriggerValue = self.builder.get_object('liftTriggerValue')
274
self.liftEnableCombo = self.builder.get_object('liftEnableCombo')
275
self.dateFormatEntry = self.builder.get_object('dateFormatEntry')
276
self.libraryEntry = self.builder.get_object('libraryEntry')
277
self.socketTimeSpin = self.builder.get_object('socketTimeSpin')
278
self.checksumCheckButton = self.builder.get_object('checksumCheckButton')
279
self.lowTextureCheckButton = self.builder.get_object('lowTextureCheckButton')
280
self.framesSpin = self.builder.get_object('framesSpin')
281
self.vwidthSpin = self.builder.get_object('vwidthSpin')
282
self.vheightSpin = self.builder.get_object('vheightSpin')
283
self.vrotateSpin = self.builder.get_object('vrotateSpin')
284
self.schedulerCombo = self.builder.get_object("schedulerCombo")
285
self.downloaderCombo = self.builder.get_object("downloaderCombo")
286
self.colourDepthCombo = self.builder.get_object("colourDepthCombo")
287
self.notebook1 = self.builder.get_object("notebook1")
289
self.errorDialog = self.builder.get_object("errorDialog")
290
self.messageDialog = self.builder.get_object("infoDialog")
292
self.statsCaptureLabel = self.builder.get_object("statsCaptureLabel")
293
self.statsQueueSizeLabel = self.builder.get_object("statsQueueSizeLabel")
295
#Grab the log file link button and make it invisible by default
296
self.logFileLinkButton = self.builder.get_object("logFileLinkButton")
297
self.logFileLinkButton.hide()
299
self.statsFrame = self.builder.get_object("frame2")
301
#We want to be able to hide the lift options if the command line flag
302
#has not been passed. We can do this by grabbing the 5th (4th when
303
#counting from zero) page, and using the hide method.
305
self.liftTabVisible = lift
306
print self.liftTabVisible
309
liftPage = self.notebook1.get_nth_page(4)
311
self.logger1.info("Lift options hidden")
313
#Hide the statistics options unless the lift
315
self.captureStatisticsBool.hide()
316
self.queueSizeText.hide()
317
self.statsCaptureLabel.hide()
318
self.statsQueueSizeLabel.hide()
319
self.statsFrame.hide()
322
self.logger1.info("Lift options available")
324
#Set a class instance variable for whether the advanced tab is shown or not
325
self.advancedTabVisible = False
328
advancedPage = self.notebook1.get_nth_page(3)
331
#Fill in the comboboxes
335
liststore = gtk.ListStore(gobject.TYPE_STRING)
336
print "ABC: ",self.logWriterHumanTypes
337
for elem in self.logWriterHumanTypes:
338
liststore.append([elem])
340
self.logTypeCombo.set_model(liststore)
341
self.logTypeCombo.set_active(0)
343
cell = gtk.CellRendererText()
344
self.logTypeCombo.pack_start(cell, True)
345
self.logTypeCombo.add_attribute(cell, "text", 0)
349
schedulerListStore = gtk.ListStore(gobject.TYPE_STRING)
351
for elem in self.schedulerOptions:
352
schedulerListStore.append([elem])
354
self.schedulerCombo.set_model(schedulerListStore)
355
self.schedulerCombo.set_active(0)
357
self.schedulerCombo.pack_start(cell, True)
358
self.schedulerCombo.add_attribute(cell, "text", 0)
363
downloaderListStore = gtk.ListStore(gobject.TYPE_STRING)
365
for elem in self.downloaderOptions:
366
downloaderListStore.append([elem])
368
self.downloaderCombo.set_model(downloaderListStore)
369
self.downloaderCombo.set_active(0)
371
self.downloaderCombo.pack_start(cell, True)
372
self.downloaderCombo.add_attribute(cell, "text", 0)
374
#colour depth combobox
376
colourDepthListStore = gtk.ListStore(gobject.TYPE_STRING)
378
for elem in self.colourDepthOptions:
379
colourDepthListStore.append([elem])
381
self.colourDepthCombo.set_model(colourDepthListStore)
382
self.colourDepthCombo.set_active(0)
384
self.colourDepthCombo.pack_start(cell, True)
385
self.colourDepthCombo.add_attribute(cell, "text", 0)
389
#lift enable combobox
391
liftEnableListStore = gtk.ListStore(gobject.TYPE_STRING)
393
liftEnableOptions = ["True","False"]
395
for elem in liftEnableOptions:
396
liftEnableListStore.append([elem])
398
self.liftEnableCombo.set_model(liftEnableListStore)
399
self.liftEnableCombo.set_active(0)
401
self.liftEnableCombo.pack_start(cell, True)
402
self.liftEnableCombo.add_attribute(cell, "text", 0)
405
#Set the range of values we accept for the spin controls
407
width_adj = gtk.Adjustment(1024, 1.0, 10000, 1.0, 5.0, 0.0)
408
height_adj = gtk.Adjustment(1024, 1.0, 10000, 1.0, 5.0, 0.0)
409
queue_adj = gtk.Adjustment(10, 1.0, 10000, 1.0, 5.0, 0.0)
410
refresh_adj = gtk.Adjustment(100, 1.0, 10000, 1.0, 5.0, 0.0)
411
logLevel_adj = gtk.Adjustment(0, 0, 10, 1.0, 2.0, 0.0)
413
socketTime_adj = gtk.Adjustment(0, 0, 100, 1.0, 2.0, 0.0)
414
frames_adj = gtk.Adjustment(0, 0, 100, 1.0, 2.0, 0.0)
415
vwidth_adj = gtk.Adjustment(0, 0, 10000, 1.0, 2.0, 0.0)
416
vheight_adj = gtk.Adjustment(0, 0, 10000, 1.0, 2.0, 0.0)
417
vrotate_adj = gtk.Adjustment(0, -359, 359, 1.0, 2.0, 0.0)
418
liftTrigger_adj = gtk.Adjustment(0, 0, 100, 1.0, 2.0, 0.0)
420
self.screenWidthText.configure(width_adj, 0, 0)
421
self.screenWidthText.set_wrap(True)
423
self.screenHeightText.configure(height_adj, 0, 0)
424
self.screenHeightText.set_wrap(True)
426
self.queueSizeText.configure(queue_adj, 0, 0)
427
self.queueSizeText.set_wrap(True)
429
self.refreshText.configure(refresh_adj, 0, 0)
430
self.refreshText.set_wrap(True)
432
self.logLevelSpin.configure(logLevel_adj, 0, 0)
433
self.logLevelSpin.set_wrap(True)
435
self.socketTimeSpin.configure(socketTime_adj,0,0)
436
self.socketTimeSpin.set_wrap(True)
438
self.framesSpin.configure(frames_adj,0,0)
439
self.framesSpin.set_wrap(True)
441
self.vwidthSpin.configure(vwidth_adj,0,0)
442
self.vwidthSpin.set_wrap(True)
444
self.vheightSpin.configure(vheight_adj,0,0)
445
self.vheightSpin.set_wrap(True)
447
self.vrotateSpin.configure(vrotate_adj,0,0)
448
self.vrotateSpin.set_wrap(True)
450
self.liftTriggerValue.configure(liftTrigger_adj,0,0)
451
self.liftTriggerValue.set_wrap(True)
453
#We want the labels to be translatable,
454
#Using the Glade stuff grab the labels
455
self.serverURLLabel = self.builder.get_object("serverURLLabel")
456
self.clientIDLabel = self.builder.get_object("clientIDLabel")
457
self.serverKeyLabel = self.builder.get_object("serverKeyLabel")
458
self.refreshLabel = self.builder.get_object("refreshLabel")
459
self.connectionLabel = self.builder.get_object("connectionLabel")
460
self.fullscreenLabel = self.builder.get_object("fullscreenLabel")
461
self.widthLabel = self.builder.get_object("widthLabel")
462
self.heightLabel = self.builder.get_object("heightLabel")
463
self.logLevelLabel = self.builder.get_object("logLevelLabel")
464
self.logTypeLabel = self.builder.get_object("logTypeLabel")
465
self.loggingFrameLabel = self.builder.get_object("loggingFrameLabel")
466
self.statsFrameLabel = self.builder.get_object("statsFrameLabel")
467
self.clientNameLabel = self.builder.get_object("clientNameLabel")
469
#Labels for advanced options and tabs
470
self.liftDefaultLabel = self.builder.get_object('liftDefaultLabel')
471
self.lift7Label = self.builder.get_object('lift7Label')
472
self.lift6Label = self.builder.get_object('lift6Label')
473
self.lift5Label = self.builder.get_object('lift5Label')
474
self.lift4Label = self.builder.get_object('lift4Label')
475
self.lift3Label = self.builder.get_object('lift3Label')
476
self.lift2Label = self.builder.get_object('lift2Label')
477
self.lift1Label = self.builder.get_object('lift1Label')
478
self.lift0Label = self.builder.get_object('lift0Label')
479
self.tagLiftLabel = self.builder.get_object('tagLiftLabel')
480
self.genLiftOptions = self.builder.get_object('genLiftOptions')
481
self.firstSerialLabel = self.builder.get_object('firstSerialLabel')
482
self.secondSerialLabel = self.builder.get_object('secondSerialLabel')
483
self.liftTriggerLabel = self.builder.get_object('liftTriggerLabel')
484
self.liftEnableLabel = self.builder.get_object('liftEnableLabel')
485
self.liftOptionsLabel = self.builder.get_object('liftOptionsLabel')
486
self.advancedOptionsLabel = self.builder.get_object('advancedOptionsLabel')
487
self.otherSettingsLabel = self.builder.get_object('otherSettingsLabel')
488
self.clientSettingsLabel = self.builder.get_object('clientSettingsLabel')
489
self.serverSettingsLabel = self.builder.get_object('serverSettingsLabel')
490
self.dateFormatLabel = self.builder.get_object('dateFormatLabel')
491
self.schedulerLabel = self.builder.get_object('schedulerLabel')
492
self.downloaderLabel = self.builder.get_object('downloaderLabel')
493
self.libraryLabel = self.builder.get_object('libraryLabel')
494
self.bppLabel = self.builder.get_object('bppLabel')
495
self.socketTimeLabel = self.builder.get_object('socketTimeLabel')
496
self.checksumLabel = self.builder.get_object('checksumLabel')
497
self.lowTextureLabel = self.builder.get_object('lowTextureLabel')
498
self.framesLabel = self.builder.get_object('framesLabel')
499
self.vwidthLabel = self.builder.get_object('vwidthLabel')
500
self.vheightLabel = self.builder.get_object('vheightLabel')
501
self.vrotationLabel = self.builder.get_object('vrotationLabel')
502
self.advancedOptionsCheck = self.builder.get_object("advancedOptionsCheck")
504
# self.manualUpdateLabel = self.builder.get_object("manualUpdateLabel")
505
# self.manualUpdateCombo = self.builder.get_object("manualUpdateCombo")
506
self.xmdsLicenseKeyLabel = self.builder.get_object("xmdsLicenseKeyLabel")
507
self.xmdsLicenseKeyEntry = self.builder.get_object("xmdsLicenseKeyEntry")
509
self.onlineOpLabel = self.builder.get_object("onlineOpLabel")
510
self.offlineOpLabel = self.builder.get_object("offlineOpLabel")
513
#Now set the text in the labels. This is useful so that we can
514
#then use this as a basis for translations on launchpad
516
# self.manualUpdateLabel.set_text(_("Manual Update"))
517
self.xmdsLicenseKeyLabel.set_text(_("xmdsLicenseKey"))
519
self.serverURLLabel.set_text(_("Server URL"))
520
self.clientIDLabel.set_text(_("Client ID"))
521
self.serverKeyLabel.set_text(_("Server Key"))
522
self.refreshLabel.set_text(_("Set the number of seconds between the client contacting the server for updates"))
523
self.connectionLabel.set_text(_("Require connection to server"))
524
self.fullscreenLabel.set_text(_("Fullscreen"))
525
self.widthLabel.set_text(_("Width"))
526
self.heightLabel.set_text(_("Height"))
527
self.logLevelLabel.set_text(_("Log Level"))
528
self.logTypeLabel.set_text(_("Log Type"))
529
self.statsCaptureLabel.set_text(_("Statistics Capturing"))
530
self.statsQueueSizeLabel.set_text(_("Queue Size"))
531
self.loggingFrameLabel.set_text(_("Logging"))
532
self.statsFrameLabel.set_text(_("Statistics Generation"))
534
self.clientNameLabel.set_text(_("Client Name"))
536
self.liftDefaultLabel.set_label(_('Default'))
537
self.lift7Label.set_label(_('Lift 7'))
538
self.lift6Label.set_label(_('Lift 6'))
539
self.lift5Label.set_label(_('Lift 5'))
540
self.lift4Label.set_label(_('Lift 4'))
541
self.lift3Label.set_label(_('Lift 3'))
542
self.lift2Label.set_label(_('Lift 2'))
543
self.lift1Label.set_label(_('Lift 1'))
544
self.lift0Label.set_label(_('Lift 0'))
545
self.tagLiftLabel.set_label(_('Tagging Lift Options'))
546
self.genLiftOptions.set_label(_('General Lift Options'))
547
self.firstSerialLabel.set_label(_('1st Serial Port'))
548
self.secondSerialLabel.set_label(_('2nd Serial Port'))
549
self.liftTriggerLabel.set_label(_('Lift Trigger'))
550
self.liftEnableLabel.set_label(_('Lift Enable'))
551
self.liftOptionsLabel.set_label(_('Lift Options'))
552
self.advancedOptionsLabel.set_label(_('Advanced Options'))
553
self.otherSettingsLabel.set_label(_('Other Settings'))
554
self.clientSettingsLabel.set_label(_('Client Settings'))
555
self.serverSettingsLabel.set_label(_('Server Settings'))
556
self.dateFormatLabel.set_label(_('Date Format'))
557
self.schedulerLabel.set_label(_('Scheduler'))
558
self.downloaderLabel.set_label(_('Downloader'))
559
self.libraryLabel.set_label(_('Library Location'))
560
self.bppLabel.set_label(_('Colour Depth (BPP)'))
561
self.socketTimeLabel.set_label(_('Socket Timeout (s)'))
562
self.checksumLabel.set_label(_('Checksum Downloaded Media'))
563
self.lowTextureLabel.set_label(_('Low Texture Memory'))
564
self.framesLabel.set_label(_('Frames per Second'))
565
self.vwidthLabel.set_label(_('Virtual Width'))
566
self.vheightLabel.set_label(_('Virtual Height'))
567
self.vrotationLabel.set_label(_('Rotation'))
569
self.onlineOpLabel.set_label(_("Online operation (syncronise with Xibo server)"))
570
# self.offlineOpLabel.set_label(_("Offline operation (synchronise with USB memory stick)"))
572
#Set the icon for the Window
573
self.window.set_icon_from_file("xibo.ico")
576
#Now set the labels of the buttons and window
578
self.clearButton.set_label(_("Clear Form"))
579
self.saveButton.set_label(_("Save Config"))
580
self.window.set_title(_("Xibo Client Configuration"))
583
#Set up the combo box
585
# manualUpdateListStore = gtk.ListStore(gobject.TYPE_STRING)
587
# for elem in self.manualUpdateOptions:
588
# manualUpdateListStore.append([elem])
590
# self.manualUpdateCombo.set_model(manualUpdateListStore)
591
# self.manualUpdateCombo.set_active(1)
593
# self.manualUpdateCombo.pack_start(cell, True)
594
# self.manualUpdateCombo.add_attribute(cell, "text", 0)
596
logFilePath = os.path.join(os.path.abspath(''),self.pyClientLogName)
598
self.logFileLinkButton.set_uri("file:%s%s%s"%(os.sep,os.sep,logFilePath))
600
# print "File path: ", logFilePath
602
#Set the tick box to online operation
603
self.offlineCheckButton.set_active(True)
604
self.offlineCheckButton.set_active(False)
611
#Check that the directory exists where the configuration file
614
if os.path.exists(self.pyclientConfPath):
615
if os.path.isfile(self.pyclientConfPath):
617
self.logger1.error("Python client path chosen is a file")
619
print "Location is a file."
620
self.errorDialog.set_markup(_("File path is a file. Cannot write to it"))
621
self.errorDialog.show()
622
print "Exiting gracefully"
624
elif os.path.isdir(self.pyclientConfPath):
625
self.logger1.info("Python client path chosen is available")
626
print "Location exists."
627
print "Carrying on..."
629
self.pyClientConfName = os.path.join(self.pyclientConfPath,self.pyClientConfName)
631
print "Configuration directory does not exist"
632
self.logger1.warning("Python client path chosen does not exist")
634
os.makedirs(self.pyclientConfPath)
635
print "Directory created"
636
self.logger1.info("Python client path chosen has been created")
637
self.pyClientConfName = os.path.join(self.pyclientConfPath,self.pyClientConfName)
639
self.logger1.error("Python client path chosen could not be created")
640
self.errorDialog.set_markup(_("File path could not be created"))
641
self.errorDialog.show()
644
#Check that a file can be written to this directory
646
file_written = open(os.path.join(self.pyclientConfPath,"tmp"),"w")
649
self.logger1.error("Could not write to testing file")
651
is_file = os.path.isfile(os.path.join(self.pyclientConfPath,"tmp"))
653
self.logger1.info("Testing file has been created in the chosen location")
655
#Check that the file can be written to
658
file_edit = open(os.path.join(self.pyclientConfPath,"tmp"),"w")
659
file_edit.write("tmp")
663
self.logger1.info("Testing file could not be written to")
669
data = open(os.path.join(self.pyclientConfPath,"tmp"),"r").read()
671
self.logger1.error("Cannot open testing file to read data")
674
self.logger1.info("Testing file could be written to")
676
self.logger1.info("Testing file could not be written to")
678
#Check that the file can be deleted
681
os.remove(os.path.join(self.pyclientConfPath,"tmp"))
683
self.logger1.error("Cannot delete testing file")
685
if os.path.isfile(os.path.join(self.pyclientConfPath,"tmp")) == False:
687
self.logger1.info("Testing file has been deleted successfully")
689
if is_deleted and is_data and is_file:
690
print "Location is acceptable for file writing"
691
self.logger1.info("Location is acceptable for file writing")
692
self.messageDialog.set_markup(_("File location is acceptable"))
693
self.messageDialog.show()
696
print "Cannot write to file"
697
self.logger1.error("Location selected is not acceptable for file writing")
698
print "Exiting gracefully"
699
self.errorDialog.show()
700
self.errorDialog.set_markup(_("Cannot write to file"))
705
print self.pyClientConfName
708
if is_deleted and is_data and is_file:
710
#Read the configuration information from the configuration file
713
#Check to see if the client ID field is blank.
714
#If so, then generate one
716
if self.clientIDText.get_text() == "":
717
uuid = self.genClientID()
718
self.clientIDText.set_text(str(uuid))
720
def messageDialogExit(self,widget):
723
def infoDialogOKSignal(self,widget):
724
self.messageDialog.hide()
726
def offlineOperationToggle(self,widget):
728
offlineOperation = widget.get_active()
730
self.logger8.info(_("Offline operation checkbox toggled"))
733
print "Offline operation selected"
734
# self.manualUpdateCombo.set_sensitive(True)
735
# self.xmdsLicenseKeyEntry.set_sensitive(True)
737
self.logger8.info(_("Offline operation selected"))
739
self.serverURLText.set_sensitive(False)
740
self.clientIDText.set_sensitive(False)
741
self.serverKeyText.set_sensitive(False)
742
self.clientNameText.set_sensitive(False)
745
print "Online operation selected"
746
self.logger8.info(_("Online operation selected"))
747
# self.manualUpdateCombo.set_sensitive(False)
748
# self.xmdsLicenseKeyEntry.set_sensitive(False)
750
self.serverURLText.set_sensitive(True)
751
self.clientIDText.set_sensitive(True)
752
self.serverKeyText.set_sensitive(True)
753
self.clientNameText.set_sensitive(True)
755
def on_advancedOptionsCheck(self,widget):
756
"""Function called when advanced options checkbox is toggled.
757
Used to hide / display the advanced notebook tab"""
759
advancedPage = self.notebook1.get_nth_page(3)
761
if self.advancedOptionsCheck.get_active() and self.advancedTabVisible == False:
763
self.advancedTabVisible = True
764
self.logger6.info(_("advancedTabEnabled"))
766
elif self.advancedOptionsCheck.get_active() == False and self.advancedTabVisible:
768
self.advancedTabVisible = False
769
self.logger6.info(_("advancedTabDisabled"))
771
def readConfigAppConf(self):
772
"""This reads the configuration file that is used by the configuration application"""
773
self.logger7.info(_("Configuration application configuration file being read in"))
776
config_file = open(self.clientConfFile,"r")
778
#Implement all the stuff to read the config file in
779
data = config_file.read()
781
self.logger7.info(_("Reading configuration file to make sure file is not empty"))
782
#If the file is not empty, then try and process it
785
config = ConfigParser.ConfigParser()
786
config.read(self.clientConfFile)
788
self.logger7.info(_("Reading configuration file"))
790
#Get the information from the configuration file
791
#and display into the GUI
793
#Xibo client configuration file location
794
xiboClientConf = None
797
xiboClientConf = config.get('Main','clientConfName')
799
xiboClientConf = "site.cfg"
801
self.logger7.info(_("Client configuration: %s"%xiboClientConf))
803
#Options pertaining to log type
804
logTypeOptions = config.get("Options","logType").split(",")
805
for i in range(len(logTypeOptions)):
806
logTypeOptions[i] = _(logTypeOptions[i])
810
#Options pertaining to log type (human readable form)
811
logTypeHumanOptions = config.get("Options","logTypeHuman").split(",")
813
for i in range(len(logTypeHumanOptions)):
814
logTypeHumanOptions[i] = _(logTypeHumanOptions[i])
816
self.logger7.info(_("logTypeOptions: %s"%logTypeOptions))
818
self.logger7.info(_("logTypeHumanOptions: %s"%logTypeHumanOptions))
820
#Options pertaining to scheduler
821
schedulerOptions = config.get("Options","scheduler").split(",")
822
for i in range(len(schedulerOptions)):
823
schedulerOptions[i] = _(schedulerOptions[i])
825
print schedulerOptions
827
self.logger7.info(_("schedulerOptions: %s"%schedulerOptions))
830
#Options pertaining to downloader
831
downloaderOptions = config.get("Options","downloader").split(",")
832
for i in range(len(downloaderOptions)):
833
downloaderOptions[i] = _(downloaderOptions[i])
835
print downloaderOptions
837
self.logger7.info(_("downloaderOptions: %s"%downloaderOptions))
839
#Options pertaining to colour depth (BPP)
840
colourDepthOptions = config.get("Options","colourDepth").split(",")
841
for i in range(len(colourDepthOptions)):
842
colourDepthOptions[i] = _(colourDepthOptions[i])
844
print colourDepthOptions
846
self.logger7.info(_("colourDepthOptions: %s"%colourDepthOptions))
851
clientConfLoc = config.get("Main","clientConfLoc")
853
clientConfLoc = os.path.expanduser('~/.xibo')
855
clientConfName = None
857
clientConfName = config.get("Main","clientConfName")
859
clientConfName = "site.cfg"
862
self.logger7.info(_("clientConfLocation: %s"%clientConfLoc))
863
self.logger7.info(_("clientConfName: %s"%clientConfName))
866
return {"xiboClientConf":xiboClientConf,"logTypeOptions":logTypeOptions,"logTypeHumanOptions":logTypeHumanOptions,"clientConfLoc":clientConfLoc,"clientConfName":clientConfName,"schedulerOptions":schedulerOptions,"downloaderOptions":downloaderOptions,"colourDepthOptions":colourDepthOptions}
869
self.logger7.error("Configuration file is empty. Cannot continue")
870
self.errorDialog.set_markup(_("The configuration application configuration file is empty. Cannot continue"))
871
self.errorDialog.show()
874
print "Could not open the configuration application configuration file"
876
self.logger7.error(_("Could not open configuration file. Cannot continue"))
878
self.errorDialog.set_markup(_("File path is a file. Cannot write to itCould not open the configuration application configuration file"))
879
self.errorDialog.show()
882
def clearFormSignal(self,widget,data=None):
884
self.serverURLText.set_text("")
885
self.clientIDText.set_text("")
886
self.serverKeyText.set_text("")
887
self.refreshText.set_text("")
888
self.serverConnBool.set_active(False)
889
self.fullScreenBool.set_active(False)
890
self.screenWidthText.set_text("")
891
self.screenHeightText.set_text("")
892
self.captureStatisticsBool.set_active(False)
893
self.queueSizeText.set_text("")
895
self.screenWidthText.set_value(0)
896
self.screenHeightText.set_value(0)
897
self.queueSizeText.set_value(0)
900
self.clearButton.set_tooltip_text(_("Clear input fields"))
901
self.saveButton.set_tooltip_text(_("Save data to file"))
903
self.logLevelSpin.set_value(0)
905
self.logTypeCombo.set_active(0)
906
self.liftEnableCombo.set_active(0)
907
self.schedulerCombo.set_active(0)
908
self.downloaderCombo.set_active(0)
909
self.colourDepthCombo.set_active(0)
910
self.manualUpdateCombo.set_active(0)
913
self.checksumCheckButton.set_active(False)
914
self.lowTextureCheckButton.set_active(False)
916
self.clientNameText.set_text("")
918
#Advanced options widgets
920
self.liftDefaultTagText.set_text("")
921
self.lift7TagText.set_text("")
922
self.lift6TagText.set_text("")
923
self.lift5TagText.set_text("")
924
self.lift4TagText.set_text("")
925
self.lift3TagText.set_text("")
926
self.lift2TagText.set_text("")
927
self.lift1TagText.set_text("")
928
self.lift0TagText.set_text("")
929
self.firstSerialText.set_text("")
930
self.secondSerialText.set_text("")
931
self.liftTriggerValue.set_value(0)
933
self.dateFormatEntry.set_text("")
934
self.libraryEntry.set_text("")
935
self.socketTimeSpin.set_value(0)
937
self.framesSpin.set_value(0)
938
self.vwidthSpin.set_value(0)
939
self.vheightSpin.set_value(0)
940
self.vrotateSpin.set_value(0)
942
self.xmdsLicenseKeyEntry.set_text("")
944
self.logger9.info("Clearing form elements")
946
def logTypeComboChanged(self,widget,data=None):
948
model = widget.get_model()
949
index = widget.get_active()
950
logTypeText = model[index][0].lower()
952
if logTypeText == "local file":
953
#Check to see if the file pointed to by the link exists
954
error_file = self.logFileLinkButton.get_uri().split(":%s%s"%(os.sep,os.sep))[1]
955
if os.path.isfile(error_file):
956
self.logFileLinkButton.show()
958
self.logFileLinkButton.hide()
960
val = widget.get_active()
963
def onDestroy(self,widget,data=None):
965
Close the program. Executes when the main
968
self.logger10.info("Exiting program")
972
def confValErr(self,err,logger):
973
#print "Error finding config. value in file: %s"%err
974
#self.logger2.warning("%s item not in config. file"%err)
975
logger.warning("%s item not in config. file"%err)
977
def readConfig(self):
978
"""Function used to read in the configuration file and
979
fill in the GUI text elements"""
981
#Firstly check if the configuration file exists. If it does then
982
#open it and extract the values. These can then be filled into the
985
#Try opening the configuration file, if it does not exists, then
990
config_file = open(self.pyClientConfName,"r")
992
self.logger2.info("Config. file opened successfully")
994
#Implement all the stuff to read the config file in
995
data = config_file.read()
997
#If the file is not empty, then try and process it
1000
self.logger2.info("Config. data read in successfully")
1003
self.readDataFromConfigFile(self.pyClientConfName,self.logger2)
1008
self.logger2.warning("Cannot open configuration file")
1009
#Read in the values from the site.cfg.default
1011
self.readDataFromConfigFile(self.pyClientConfDefaultsName,self.logger12,defaults=True)
1012
self.messageDialog.set_markup(_("Could not open configuration file. A new one will be created"))
1013
self.messageDialog.show()
1018
def readDataFromConfigFile(self,confFileName,logger,defaults=False):
1021
config = ConfigParser.ConfigParser()
1022
config.read(confFileName)
1024
#Get the information from the configuration file
1025
#and display into the GUI
1028
self.serverURLText.set_text(config.get('Main','xmdsUrl'))
1029
logger.info("serverURL: %s"%config.get('Main','xmdsUrl'))
1031
self.confValErr('xmdsUrl',logger)
1033
if defaults == False:
1035
self.clientIDText.set_text(config.get("Main","xmdsClientID"))
1036
logger.info("clientID: %s"%config.get('Main','xmdsClientID'))
1038
self.confValErr("xmdsClientID",logger)
1039
logger.warning("xmdClientID item not in config. file")
1042
self.serverKeyText.set_text(config.get('Main','xmdsKey'))
1043
logger.info("xmdsKey: %s"%config.get('Main','xmdsKey'))
1045
self.confValErr('xmdsKey',logger)
1048
self.refreshText.set_text(config.get('Main','xmdsUpdateInterval'))
1049
logger.info("xmdsUpdateInterval: %s"%config.get('Main','xmdsUpdateInterval'))
1051
self.confValErr('xmdsUpdateInterval',logger)
1054
self.clientNameText.set_text(config.get('Main','xmdsClientName'))
1055
logger.info("xmdsClientName: %s"%config.get('Main','xmdsClientName'))
1057
self.confValErr('xmdsClientName',logger)
1062
if config.get('Main','requireXmds') == "true":
1065
self.serverConnBool.set_active(requireXmds)
1066
logger.info("requireXMDS: %s"%requireXmds)
1069
self.confValErr("requireXmds",logger)
1073
if config.get('Main','fullscreen') == "true":
1075
self.fullScreenBool.set_active(fullScreen)
1076
logger.info("fullscreen: %s"%fullscreen)
1080
self.confValErr("fullscreen",logger)
1083
captureStats = False
1084
if config.get('Stats','collect') == "true":
1086
logger.info("captureStats: %s"%captureStats)
1088
self.captureStatisticsBool.set_active(captureStats)
1090
self.confValErr("Stats - Collect",logger)
1094
self.screenWidthText.set_value(int(config.get('Main','width')))
1095
logger.info("screenWidth: %s"%config.get('Main','width'))
1098
self.confValErr("width",logger)
1101
self.screenHeightText.set_value(int(config.get('Main','height')))
1102
logger.info("screenHeight: %s"%config.get('Main','height'))
1105
self.confValErr("height",logger)
1108
self.queueSizeText.set_value(int(config.get('Stats','queueSize')))
1109
logger.info("queueSize: %s"%config.get('Stats','queueSize'))
1112
self.confValErr("queueSize",logger)
1115
self.logLevelSpin.set_value(int(config.get('Logging','logLevel')))
1116
logger.info("Logging level: %s"%config.get('Logging','logLevel'))
1119
self.confValErr("logLevel",logger)
1122
logType = config.get('Logging','logWriter')
1126
for elem in self.logWriterTypes:
1127
if elem.lower() == logType.lower():
1128
print elem.lower(), logType.lower()
1131
print "*"*len(str(self.logWriterTypes))
1133
print self.logWriterTypes
1134
print " "*(len(str(self.logWriterTypes))/2),val
1135
print self.logWriterHumanTypes
1136
print "*"*len(str(self.logWriterTypes))
1138
logger.info("logWriter: %s"%self.logWriterTypes[val])
1139
logger.info("logWriterHuman: %s"%self.logWriterHumanTypes[val])
1140
self.logTypeCombo.set_active(val)
1142
self.confValErr("logWriter",logger)
1148
self.dateFormatEntry.set_text(config.get("TickerMedia","dateFormat"))
1149
logger.info("tickerMedia: %s"%config.get('TickerMedia','dateFormat'))
1152
self.confValErr("dateFormat",logger)
1155
self.libraryEntry.set_text(config.get("Main","libraryDir"))
1156
logger.info("libraryDir: %s"%config.get('Main','libraryDir'))
1159
self.confValErr("libraryDir",logger)
1162
self.socketTimeSpin.set_value(int(config.get("Main","socketTimeout")))
1163
logger.info("socketTimeout: %s"%config.get('Main','socketTimeout'))
1166
self.confValErr("socketTimeout",logger)
1169
self.framesSpin.set_value(int(config.get("Main","fps")))
1170
logger.info("FPS: %s"%config.get('Main','fps'))
1173
self.confValErr("fps",logger)
1176
self.vwidthSpin.set_value(int(config.get("Main","vwidth")))
1177
logger.info("VirtualWidth: %s"%config.get('Main','vwidth'))
1180
self.confValErr("vwidth",logger)
1183
self.vheightSpin.set_value(int(config.get("Main","vheight")))
1184
logger.info("VirtualHeight: %s"%config.get('Main','vheight'))
1187
self.confValErr("vheight",logger)
1190
self.vrotateSpin.set_value(int(config.get("Main","vrotation")))
1191
logger.info("VirtualRotation: %s"%config.get('Main','vrotation'))
1194
self.confValErr("vrotation",logger)
1198
self.xmdsLicenseKeyEntry.set_text(config.get("Main","xmdsLicenseKey"))
1199
logger.info("xmdsLicenseKey: %s"%config.get('Main','xmdsLicenseKey'))
1202
self.confValErr('xmdsLicenseKey',logger)
1205
#Sort out the combo boxes
1208
schedType = config.get("Main","Scheduler")
1211
for elem in self.schedulerOptions:
1212
if elem.lower() == schedType.lower():
1215
logger.info("scheduler: %s"%self.schedulerOptions[val])
1217
self.schedulerCombo.set_active(val)
1219
self.confValErr("scheduler",logger)
1222
dloadType = config.get("Main","Downloader")
1225
for elem in self.downloaderOptions:
1226
if elem.lower() == dloadType.lower():
1229
logger.info("downloader: %s"%self.downloaderOptions[val])
1231
self.downloaderCombo.set_active(val)
1233
self.confValErr("downloader",logger)
1236
bppType = config.get("Main","bpp")
1240
for elem in self.colourDepthOptions:
1241
if elem.lower() == bppType.lower():
1244
logger.info("BPP: %s"%self.colourDepthOptions[val])
1246
self.colourDepthCombo.set_active(val)
1248
self.confValErr("bpp",logger)
1252
manualUpdateType = config.get("Main","manualUpdate")
1253
logger.info("offlineUpdate: %s"%manualUpdateType)
1255
if manualUpdateType == "true":
1256
manualUpdateType = True
1257
elif manualUpdateType == "false":
1258
manualUpdateType = False
1260
if manualUpdateType == True or manualUpdateType == False:
1261
if manualUpdateType == True:
1263
self.offlineCheckButton.set_active(True)
1264
self.offlineOperationToggle(self,self.offlineCheckButton)
1267
self.confValErr('offlineUpdate',logger)
1268
print "Manual Update Failed"
1270
#Now the check boxes
1274
if config.get('Main','checksumPreviousDownloads') == "true":
1277
logger.info("checksumPreviousDownloads: %s"%checksum)
1280
self.confValErr("checksumPreviousDownloads",logger)
1286
if config.get('Main','lowTextureMemory') == "true":
1288
logger.info("lowTextureMemory: %s"%lowTexture)
1291
self.confValErr("lowTextureMemory",logger)
1294
self.checksumCheckButton.set_active(checksum)
1296
self.lowTextureCheckButton.set_active(lowTexture)
1299
#Now the lift options
1301
self.liftDefaultTagText.set_text(config.get("LiftTags","default"))
1302
logger.info("DefaultLiftTag: %s"%config.get('LiftTags','default'))
1305
self.confValErr("liftTags",logger)
1308
self.lift7TagText.set_text(config.get("LiftTags","lift7"))
1309
logger.info("Lift7Tag: %s"%config.get('LiftTags','lift7'))
1312
self.confValErr("lift7",logger)
1315
self.lift6TagText.set_text(config.get("LiftTags","lift6"))
1316
logger.info("Lift6Tag: %s"%config.get('LiftTags','lift6'))
1318
self.confValErr("lift6",logger)
1321
self.lift5TagText.set_text(config.get("LiftTags","lift5"))
1322
logger.info("Lift5Tag: %s"%config.get('LiftTags','lift5'))
1324
self.confValErr("lift5",logger)
1327
self.lift4TagText.set_text(config.get("LiftTags","lift4"))
1328
logger.info("Lift4Tag: %s"%config.get('LiftTags','lift4'))
1330
self.confValErr("lift4",logger)
1333
self.lift3TagText.set_text(config.get("LiftTags","lift3"))
1334
logger.info("Lift3Tag: %s"%config.get('LiftTags','lift3'))
1336
self.confValErr("lift3",logger)
1339
self.lift2TagText.set_text(config.get("LiftTags","lift2"))
1340
logger.info("Lift2Tag: %s"%config.get('LiftTags','lift2'))
1342
self.confValErr("lift2",logger)
1345
self.lift1TagText.set_text(config.get("LiftTags","lift1"))
1346
logger.info("Lift1Tag: %s"%config.get('LiftTags','lift1'))
1348
self.confValErr("lift1",logger)
1351
self.lift0TagText.set_text(config.get("LiftTags","lift0"))
1352
logger.info("Lift0Tag: %s"%config.get('LiftTags','lift0'))
1354
self.confValErr("lift0",logger)
1357
self.firstSerialText.set_text(config.get("Lift","serial0"))
1358
logger.info("FirstSerial: %s"%config.get('Lift','serial0'))
1360
self.confValErr("serial0",logger)
1363
self.secondSerialText.set_text(config.get("Lift","serial1"))
1364
logger.info("SecondSerial: %s"%config.get('Lift','serial1'))
1366
self.confValErr("serial1",logger)
1369
self.liftTriggerValue.set_value(int(config.get("Lift","trigger")))
1370
logger.info("LiftTrigger: %s"%config.get('Lift','trigger'))
1372
self.confValErr("trigger",logger)
1376
liftEnableType = config.get("Lift","enabled")
1377
logger.info("LiftEnabled: %s"%config.get('Lift','enabled'))
1381
for elem in self.liftEnableOptions:
1382
if elem.lower() == liftEnableType.lower():
1386
self.liftEnableCombo.set_active(val)
1388
self.confValErr("liftEnabled",logger)
1390
def saveConfigSignal(self,widget,data=None):
1391
a = self.getConfValues()
1392
self.logger11.info("Config Values to process: %s"%a)
1393
config = ConfigParser.RawConfigParser()
1395
config.optionxform = str
1397
configOptions = ["Main", "Logging", "Stats", "TickerMedia", "Lift", "LiftTags"]
1399
for configOption in configOptions:
1401
config.add_section(configOption)
1404
#print elem, a[elem][1], configOption
1405
if a[elem][0] == configOption:
1406
print elem, a[elem][1],configOption
1409
config.set(configOption, elem, str(a[elem][1]))
1410
self.logger11.info("Value: %s %s %s"%(configOption,elem,str(a[elem][1])))
1412
print "Error setting option:"
1413
print "Element:", elem
1414
print "Data:", a[elem]
1415
print "Error setting: %s, %s"%(elem,a[elem][1])
1417
print str(a[elem][1])
1418
self.logger11.error("Error setting value: %s %s %s"%(configOption,elem,str(a[elem][1])))
1420
#Write everything, barring the error item
1422
# with open(self.pyClientConfName, 'wb') as configfile:
1423
# config.write(configfile)
1426
configfile = open(self.pyClientConfName,"wb")
1427
config.write(configfile)
1428
self.logger11.info("Data successfully written")
1429
self.messageDialog.set_markup(_("Successfully written configuration file"))
1430
self.messageDialog.show()
1433
self.logger11.error("Data could not be written")
1434
self.errorDialog.set_markup(_("Could not open / write to configuration file. Cannot continue"))
1435
self.errorDialog.show()
1437
# #Read in the existing configuration file as a string
1438
# #we can then replace every instance of %s with one of the
1439
# #configuration items
1441
# #I have chosen this way because then we can keep the comments
1442
# #in place for manual usage
1444
# config_template_string = ""
1446
# f = open("site.cfg.default","r")
1447
# config_template_string = f.read()
1450
# print "Error reading default config file"
1452
#Now create the string to write to the new config. file
1454
# config_string = config_template_string%(a["serverURL"],a["clientID"],a["serverKey"],a["refresh"],a["serverConn"],a["screenWidth"],a["screenHeight"],a["fullScreen"],a["logType"],a["logVal"],a["captureStats"],a["queueSize"])
1456
# #Now write the configuration file
1459
# f = open(self.pyClientConfLoc,"w")
1460
# # f.write(config_string)
1463
# print "Could not write configuration file"
1465
def genClientID(self):
1466
"""Function used to generate a random client ID. Returns a generated UUID"""
1467
uuidStr = uuid.uuid4()
1468
self.logger4.info("UUID Generated: %s"%uuidStr)
1472
def set_tooltips(self):
1474
self.clearButton.set_tooltip_text(_("Clear input fields"))
1475
self.saveButton.set_tooltip_text(_("Save data to file"))
1477
self.serverURLText.set_tooltip_text(_("URL of your Xibo server"))
1478
self.clientIDText.set_tooltip_text(_("Client identifier (used to generate license key hash)"))
1479
self.serverKeyText.set_tooltip_text(_("Server key"))
1480
self.refreshText.set_tooltip_text(_("Collection interval"))
1481
self.serverConnBool.set_tooltip_text(_("Does the client have to connect to XMDS before playing cached content?"))
1482
self.fullScreenBool.set_tooltip_text(_("Should the client run fullscreen"))
1483
self.screenWidthText.set_tooltip_text(_("Width of the rendered output screen"))
1484
self.screenHeightText.set_tooltip_text(_("Height of the rendered output screen"))
1485
self.captureStatisticsBool.set_tooltip_text(_("States whether statistics are generated or not"))
1486
self.queueSizeText.set_tooltip_text(_("Statistics queue size"))
1487
self.logLevelSpin.set_tooltip_text(_("Amount of log data to write. The higher the number, the more is written"))
1488
self.logTypeCombo.set_tooltip_text(_("Where log data should be written to"))
1489
self.clientNameText.set_tooltip_text(_("Name as it will be displayed in the server app"))
1491
#Advanced options widgets
1493
self.liftDefaultTagText.set_tooltip_text(_("Tag associated with lift input"))
1494
self.lift7TagText.set_tooltip_text(_("Tag associated with lift input"))
1495
self.lift6TagText.set_tooltip_text(_("Tag associated with lift input"))
1496
self.lift5TagText.set_tooltip_text(_("Tag associated with lift input"))
1497
self.lift4TagText.set_tooltip_text(_("Tag associated with lift input"))
1498
self.lift3TagText.set_tooltip_text(_("Tag associated with lift input"))
1499
self.lift2TagText.set_tooltip_text(_("Tag associated with lift input"))
1500
self.lift1TagText.set_tooltip_text(_("Tag associated with lift input"))
1501
self.lift0TagText.set_tooltip_text(_("Tag associated with lift input"))
1502
self.firstSerialText.set_tooltip_text(_("First serial port to use for lift purposes"))
1503
self.secondSerialText.set_tooltip_text(_("First serial port to use for lift purposes"))
1504
self.liftTriggerValue.set_tooltip_text(_("Number of times lift is triggered before layout is changed"))
1505
self.liftEnableCombo.set_tooltip_text(_("Sets whether lift functionality is enabled or not"))
1506
self.dateFormatEntry.set_tooltip_text(_("Date format the client should render dates in when displaying RSS tickers"))
1507
self.libraryEntry.set_tooltip_text(_("Which folder to store content in. Can be relative or absolute path"))
1508
self.socketTimeSpin.set_tooltip_text(_("How long should we wait (in seconds) before timing out a hung socket"))
1509
self.checksumCheckButton.set_tooltip_text(_("Should the client checksum all downloaded content to ensure it's unchanged at startup"))
1510
self.lowTextureCheckButton.set_tooltip_text(_("Should the client attempt to minimise the amount of graphics texture memory it uses"))
1511
self.framesSpin.set_tooltip_text(_("How many fps to force the client to run"))
1512
self.vwidthSpin.set_tooltip_text(_("Width of the rendered virtual output screen (this will be a section within the overall window"))
1513
self.vheightSpin.set_tooltip_text(_("Height of the rendered virtual output screen (this will be a section within the overall window"))
1514
self.vrotateSpin.set_tooltip_text(_("Angle to rotate virtual window within the rendered output window"))
1515
self.schedulerCombo.set_tooltip_text(_("Which scheduler module to use"))
1516
self.downloaderCombo.set_tooltip_text(_("Which download manager module to use"))
1517
self.colourDepthCombo.set_tooltip_text(_("Colour depth of the rendered output"))
1519
self.xmdsLicenseKeyEntry.set_tooltip_text(_("Sets license key value to use when syncronising from memory stick"))
1520
# self.manualUpdateCombo.set_tooltip_text(_("Sets whether update from memory stick is enabled"))
1522
def getConfValues(self):
1524
model = self.logTypeCombo.get_model()
1525
index = self.logTypeCombo.get_active()
1526
# logTypeText = model[index][0]
1528
logTypeText = self.logWriterTypes[index]
1532
serverUrl = [configType,self.serverURLText.get_text()]
1533
clientId = [configType,self.clientIDText.get_text()]
1534
serverKey = [configType,self.serverKeyText.get_text()]
1535
refresh = [configType,int(self.refreshText.get_text())]
1536
serverConn = [configType,str(self.serverConnBool.get_active()).lower()]
1537
fullScreen = [configType,str(self.fullScreenBool.get_active()).lower()]
1538
screenWidth = [configType, self.screenWidthText.get_value_as_int()]
1539
screenHeight = [configType, self.screenHeightText.get_value_as_int()]
1540
captureStats = ["Stats",str(self.captureStatisticsBool.get_active()).lower()]
1541
queueSize = ["Stats",self.queueSizeText.get_value_as_int()]
1542
logType = ["Logging", logTypeText]
1543
logVal = ["Logging",self.logLevelSpin.get_value_as_int()]
1544
xmdsClientName = ["Main",self.clientNameText.get_text()]
1546
self.logger5.info("ServerURL: %s"%serverUrl)
1547
self.logger5.info("clientID: %s"%clientId)
1548
self.logger5.info("serverKey: %s"%serverKey)
1549
self.logger5.info("refresh: %s"%refresh)
1550
self.logger5.info("serverConn: %s"%serverConn)
1551
self.logger5.info("fullScreen: %s"%fullScreen)
1552
self.logger5.info("screenWidth: %s"%screenWidth)
1553
self.logger5.info("screenHeight: %s"%screenHeight)
1554
self.logger5.info("captureStats: %s"%captureStats)
1555
self.logger5.info("queueSize: %s"%queueSize)
1556
self.logger5.info("logType: %s"%logType)
1557
self.logger5.info("logVal: %s"%logVal)
1558
self.logger5.info("xmdsClientName: %s"%xmdsClientName)
1560
#Take the boolean values and make them lower case.
1562
configOptions = {"xmdsUrl": serverUrl, "xmdsClientID": clientId,"xmdsKey":serverKey,"xmdsUpdateInterval":refresh,"requireXMDS":serverConn,"fullScreen":fullScreen,"width":screenWidth,"height":screenHeight,"collect":captureStats,"queueSize":queueSize,"logWriter":logType,"logLevel":logVal,"xmdsClientName":xmdsClientName}
1564
#GET THE LIFT OPTIONS
1567
#ONLY DO THIS IF THE LIFT TAB IS SHOWING
1568
#THEN ADD THEM TO THE DICTIONARY
1570
# if self.liftTabVisible == True:
1572
#The above is deprecated. This is because we don't want the information to be
1573
#"deleted" from the configuration file if we choose not to show these options
1574
#on subsequent file loads
1578
configType1 = "LiftTags"
1580
model = self.liftEnableCombo.get_model()
1581
index = self.liftEnableCombo.get_active()
1582
liftEnableText = model[index][0].lower()
1584
liftDefaultTag = [configType1,self.liftDefaultTagText.get_text()]
1585
lift7Tag = [configType1, self.lift7TagText.get_text()]
1586
lift6Tag = [configType1, self.lift6TagText.get_text()]
1587
lift5Tag = [configType1, self.lift5TagText.get_text()]
1588
lift4Tag = [configType1, self.lift4TagText.get_text()]
1589
lift3Tag = [configType1, self.lift3TagText.get_text()]
1590
lift2Tag = [configType1, self.lift2TagText.get_text()]
1591
lift1Tag = [configType1, self.lift1TagText.get_text()]
1592
lift0Tag = [configType1, self.lift0TagText.get_text()]
1593
firstSerial = [configType, self.firstSerialText.get_text()]
1594
secondSerial = [configType, self.secondSerialText.get_text()]
1595
liftTrigger = [configType, self.liftTriggerValue.get_text()]
1596
liftEnable = [configType, liftEnableText]
1598
if liftDefaultTag[1] != "":
1599
configOptions["default"] = liftDefaultTag
1601
if lift7Tag[1] != "":
1602
configOptions["lift7"] =lift7Tag
1604
if lift6Tag[1] != "":
1605
configOptions["lift6"] =lift6Tag
1607
if lift5Tag[1] != "":
1608
configOptions["lift5"] =lift5Tag
1610
if lift4Tag[1] != "":
1611
configOptions["lift4"] =lift4Tag
1613
if lift3Tag[1] != "":
1614
configOptions["lift3"] =lift3Tag
1616
if lift2Tag[1] != "":
1617
configOptions["lift2"] =lift2Tag
1619
if lift1Tag[1] != "":
1620
configOptions["lift1"] =lift1Tag
1622
if lift0Tag[1] != "":
1623
configOptions["lift0"] =lift0Tag
1625
if firstSerial[1] != "":
1626
configOptions["serial0"] =firstSerial
1628
if secondSerial[1] != "":
1629
configOptions["serial1"] =secondSerial
1631
if liftEnable[1] != "false":
1632
configOptions["enabled"] =liftEnable
1634
if liftTrigger != "0":
1635
configOptions["trigger"] =liftTrigger
1637
# if self.advancedTabVisible == True:
1639
#The above is deprecated. This is because we don't want the information to be
1640
#"deleted" from the configuration file if we choose not to show these options
1641
#on subsequent file loads
1645
model = self.schedulerCombo.get_model()
1646
index = self.schedulerCombo.get_active()
1647
schedulerComboText = model[index][0]
1649
model = self.downloaderCombo.get_model()
1650
index = self.downloaderCombo.get_active()
1651
downloaderComboText = model[index][0]
1653
model = self.colourDepthCombo.get_model()
1654
index = self.colourDepthCombo.get_active()
1655
colourDepthComboText = model[index][0]
1657
xmdsLicenseKeyEntry = [configType,self.xmdsLicenseKeyEntry.get_text()]
1659
# model = self.manualUpdateCombo.get_model()
1660
# index = self.manualUpdateCombo.get_active()
1661
# manualUpdateText = model[index][0]
1663
manualUpdateText = str(self.offlineCheckButton.get_active()).lower()
1665
manualUpdate = [configType,manualUpdateText.lower()]
1667
dateFormatEntry = ["TickerMedia", self.dateFormatEntry.get_text()]
1669
libraryEntry = [configType, self.libraryEntry.get_text()]
1670
socketTimeSpin = [configType, self.socketTimeSpin.get_text()]
1671
checksum = [configType, str(self.checksumCheckButton.get_active()).lower()]
1672
lowTexture = [configType, str(self.lowTextureCheckButton.get_active()).lower()]
1675
frames = [configType, self.framesSpin.get_text()]
1676
vwidth = [configType, self.vwidthSpin.get_text()]
1677
vheight = [configType, self.vheightSpin.get_text()]
1678
vrotate = [configType, self.vrotateSpin.get_text()]
1679
scheduler = [configType, schedulerComboText]
1680
downloader = [configType, downloaderComboText]
1681
colourDepth = [configType, colourDepthComboText]
1683
if xmdsLicenseKeyEntry[1] != "":
1684
configOptions["xmdsLicenseKey"] = xmdsLicenseKeyEntry
1686
if manualUpdateText[1] != "":
1687
configOptions["manualUpdate"] = manualUpdate
1690
if dateFormatEntry[1] != "":
1691
configOptions["dateFormat"] = dateFormatEntry
1693
if libraryEntry[1] != "":
1694
configOptions["libraryDir"] = libraryEntry
1696
if socketTimeSpin[1] != "0":
1697
configOptions["socketTimeout"] = socketTimeSpin
1699
if checksum[1] == "true":
1700
configOptions["checksumPreviousDownloads"] = checksum
1702
if lowTexture[1] == "true":
1703
configOptions["lowTextureMemory"] = lowTexture
1705
if frames[1] != "0":
1706
configOptions["fps"] = frames
1708
if vwidth[1] != "0":
1709
configOptions["vwidth"] = vwidth
1711
if vheight[1] != "0":
1712
configOptions["vheight"] = vheight
1714
if vrotate[1] != "0":
1715
configOptions["vrotation"] = vrotate
1717
if scheduler[1] != "":
1718
configOptions["scheduler"] = scheduler
1720
if downloader[1] != "":
1721
configOptions["downloader"] = downloader
1723
if colourDepth[1] != "":
1724
configOptions["bpp"] = colourDepth
1726
return configOptions
1728
options = sys.argv[1:]
1730
#For each option in the array strip off any - characters and convert to lower case
1732
for i in range(len(options)):
1733
options[i] = options[i].strip("-").lower()
1737
if __name__ == "__main__":
1739
#Grab the command line options
1740
options = cmdOptions()
1742
#Find out of the lift option has been passed
1745
options.index("lift")
1748
print "Option not found"
1752
wine = xiboConfWindow("client.conf", lift = lift)