~dangarner/xibo/client-132

« back to all changes in this revision

Viewing changes to client/python/configure.py

  • Committer: Dan Garner
  • Date: 2011-02-28 16:02:19 UTC
  • mfrom: (194.13.6 server-717951)
  • Revision ID: dan@xibo.org.uk-20110228160219-cp2cwsgp25aol1e3
MergeĀ lp:~dangarner/xibo/server-717951

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
 
3
 
# -*- coding: utf-8 -*-
4
 
 
5
 
#
6
 
# Xibo - Digitial Signage - http://www.xibo.org.uk
7
 
# Copyright (C) 2011 Matt Holder
8
 
#
9
 
# This file is part of Xibo.
10
 
#
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
14
 
# any later version. 
15
 
#
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.
20
 
#
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/>.
23
 
#
24
 
 
25
 
gettextAvailable = None
26
 
 
27
 
try:
28
 
        import gettext
29
 
        gettextAvailable = True
30
 
except:
31
 
        print "Could not import gettext"
32
 
        print "Creating dummy function for _()"
33
 
        def _(string):
34
 
                return string
35
 
try:
36
 
        import sys
37
 
except:
38
 
        print "Could not import sys module"
39
 
        sys.exit()
40
 
 
41
 
try:
42
 
        import uuid
43
 
except:
44
 
        print "Could not import uuid module"
45
 
        sys.exit()
46
 
 
47
 
try:
48
 
        import ConfigParser
49
 
except:
50
 
        print "Could not import ConfigParser module"
51
 
        sys.exit()
52
 
 
53
 
try:
54
 
        import os
55
 
except:
56
 
        print "Could not import os module"
57
 
        sys.exit()
58
 
 
59
 
try:
60
 
        import logging
61
 
except:
62
 
        print "Could not import logging module"
63
 
        sys.exit()
64
 
 
65
 
try:
66
 
        import pygtk
67
 
        pygtk.require("2.0")
68
 
except:
69
 
        print "Could not import pygtk"
70
 
        sys.exit()
71
 
 
72
 
try:
73
 
        import gtk
74
 
except:
75
 
        print "Could not import gtk"
76
 
        sys.exit(1)
77
 
 
78
 
try:
79
 
        import gtk.glade
80
 
except:
81
 
        print "Could not import gtk.glade"
82
 
        sys.exit(1)
83
 
        
84
 
try:
85
 
        import gobject
86
 
except:
87
 
        print "Could not import gobject"
88
 
        sys.exit()
89
 
 
90
 
#Only run this if gettext is available
91
 
if gettextAvailable:
92
 
        gettext.install('ivcm', './locale', unicode=False)
93
 
 
94
 
 
95
 
class xiboConfWindow:
96
 
        """This is the PyWine application"""
97
 
 
98
 
 
99
 
        def __init__(self,clientConfFile,lift = False):
100
 
 
101
 
                #This is the location of the config. file for the client
102
 
                #itself. This comes from when the instance of the class
103
 
                #is created.
104
 
                self.clientConfFile = clientConfFile
105
 
 
106
 
                #Firstly, read in the values relating to log from the config. client config. file
107
 
                config = None
108
 
                try:
109
 
                        config = ConfigParser.ConfigParser()
110
 
                        config.read(self.clientConfFile)
111
 
                except:
112
 
                        print "Could not open %s"%self.clientConfFile
113
 
 
114
 
                #Xibo client configuration file name
115
 
                logFileName="error.log"
116
 
                try:
117
 
                        logFileName = config.get('Main','logFileName')
118
 
                except:
119
 
                        pass
120
 
 
121
 
                logWriter="xiboLogScreen"
122
 
                try:
123
 
                        logWriter = config.get('Main','logWriter')
124
 
                except:
125
 
                        pass
126
 
 
127
 
 
128
 
                logLevel="INFO"
129
 
                try:
130
 
                        logLevel = config.get('Main','logLevel')
131
 
                except:
132
 
                        pass
133
 
                a=logging
134
 
 
135
 
                loggingLevel = None
136
 
                if logLevel == "INFO":
137
 
                        loggingLevel = a.INFO
138
 
                elif logLevel == "WARNING":
139
 
                        loggingLevel = a.WARNING
140
 
                elif logLevel == "ERROR":
141
 
                        loggingLevel = a.ERROR
142
 
                
143
 
                if logWriter == "xiboLogScreen":
144
 
                        a.basicConfig(level=loggingLevel)
145
 
                elif logWriter == "xiboLogFile":
146
 
                        
147
 
                        a.basicConfig(level=loggingLevel,filename=logFileName,filemode="w")
148
 
 
149
 
#               #Set up the logger
150
 
#               logging.basicConfig(level=logging.INFO,filename="error.log",filemode="w")
151
 
#               #format='%(asctime)s %(levelname)s %(lineno)d %(message)s'
152
 
 
153
 
                
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")
167
 
 
168
 
                self.logger1.info('Config. client config. file: %s'%self.clientConfFile)
169
 
 
170
 
                self.logger1.info("logWriter: %s"%logWriter)
171
 
                self.logger1.info("logLevel: %s"%logLevel)
172
 
                self.logger.info("logFileName: %s"%logFileName)
173
 
                
174
 
                #Name of the default log file for the python client
175
 
                self.pyClientLogName = "run.log"                
176
 
 
177
 
 
178
 
                #Read out the values from the client configuration file
179
 
                configValues = self.readConfigAppConf()
180
 
 
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"]            
184
 
 
185
 
                self.logger1.info("logWriter: %s"%self.logWriterTypes)
186
 
 
187
 
                #Take the options for the human readable log type options
188
 
                self.logWriterHumanTypes = configValues["logTypeHumanOptions"]
189
 
 
190
 
                self.logger1.info("logWriteHumanOptions: %s"%self.logWriterHumanTypes)
191
 
 
192
 
                #Take the location of the configuration file and set the class
193
 
                #instance variable. This path is then used when the config.
194
 
                #file is written                
195
 
 
196
 
                self.pyClientConfName = configValues["xiboClientConf"]
197
 
                        
198
 
                        
199
 
                self.logger1.info("Xibo client config. file: %s"%self.pyClientConfName)
200
 
 
201
 
                self.pyClientConfDefaultsName = "defaults.cfg"
202
 
 
203
 
                #Grab the directory location and check this directory exists.
204
 
 
205
 
                self.pyclientConfPath = configValues["clientConfLoc"]
206
 
                
207
 
                self.logger1.info("Xibo client config. file path: %s"%self.pyclientConfPath)
208
 
                
209
 
                self.logger1.info("Config file combined path: %s"%os.path.join(self.pyclientConfPath,self.pyClientConfName))
210
 
                
211
 
                #Take the options for scheduler type and add them to a class
212
 
                #instance variable
213
 
 
214
 
                self.schedulerOptions = configValues["schedulerOptions"]
215
 
                
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,"")
219
 
 
220
 
                #Downloader options
221
 
                self.downloaderOptions = configValues["downloaderOptions"]
222
 
                self.downloaderOptions.insert(0,"")
223
 
 
224
 
                #Colour Depth options
225
 
                self.colourDepthOptions = configValues["colourDepthOptions"]
226
 
                self.colourDepthOptions.insert(0,"")
227
 
 
228
 
                #Lift enable options
229
 
                self.liftEnableOptions = ["True","False"]
230
 
 
231
 
                #Manual update options
232
 
                self.manualUpdateOptions = ["True","False"]
233
 
 
234
 
                #Set the Glade file
235
 
                self.builder = gtk.Builder()
236
 
                self.builder.add_from_file("gui.glade")
237
 
                self.builder.connect_signals(self)
238
 
 
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")
243
 
                
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")
257
 
 
258
 
                self.offlineCheckButton = self.builder.get_object("offlineCheckButton")
259
 
 
260
 
                #Advanced options widgets
261
 
 
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")
288
 
 
289
 
                self.errorDialog = self.builder.get_object("errorDialog")
290
 
                self.messageDialog = self.builder.get_object("infoDialog")
291
 
 
292
 
                self.statsCaptureLabel = self.builder.get_object("statsCaptureLabel")
293
 
                self.statsQueueSizeLabel = self.builder.get_object("statsQueueSizeLabel")
294
 
 
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()
298
 
 
299
 
                self.statsFrame = self.builder.get_object("frame2")
300
 
                
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.
304
 
 
305
 
                self.liftTabVisible = lift
306
 
                print self.liftTabVisible
307
 
 
308
 
                if lift == False:
309
 
                        liftPage = self.notebook1.get_nth_page(4)               
310
 
                        liftPage.hide()
311
 
                        self.logger1.info("Lift options hidden")
312
 
                        
313
 
                        #Hide the statistics options unless the lift
314
 
                        #tab is being shown
315
 
                        self.captureStatisticsBool.hide()
316
 
                        self.queueSizeText.hide()
317
 
                        self.statsCaptureLabel.hide()
318
 
                        self.statsQueueSizeLabel.hide()
319
 
                        self.statsFrame.hide()
320
 
 
321
 
                else:
322
 
                        self.logger1.info("Lift options available")
323
 
 
324
 
                #Set a class instance variable for whether the advanced tab is shown or not
325
 
                self.advancedTabVisible = False
326
 
 
327
 
                #Now hide the tab
328
 
                advancedPage = self.notebook1.get_nth_page(3)           
329
 
                advancedPage.hide()             
330
 
 
331
 
                #Fill in the comboboxes
332
 
 
333
 
                #log type combobox
334
 
 
335
 
                liststore = gtk.ListStore(gobject.TYPE_STRING)
336
 
                print "ABC: ",self.logWriterHumanTypes
337
 
                for elem in self.logWriterHumanTypes:
338
 
                        liststore.append([elem])
339
 
 
340
 
                self.logTypeCombo.set_model(liststore)
341
 
                self.logTypeCombo.set_active(0)
342
 
 
343
 
                cell = gtk.CellRendererText()
344
 
                self.logTypeCombo.pack_start(cell, True)
345
 
                self.logTypeCombo.add_attribute(cell, "text", 0)
346
 
                
347
 
                #scheduler combobox
348
 
                
349
 
                schedulerListStore = gtk.ListStore(gobject.TYPE_STRING)
350
 
 
351
 
                for elem in self.schedulerOptions:
352
 
                        schedulerListStore.append([elem])
353
 
 
354
 
                self.schedulerCombo.set_model(schedulerListStore)
355
 
                self.schedulerCombo.set_active(0)
356
 
 
357
 
                self.schedulerCombo.pack_start(cell, True)
358
 
                self.schedulerCombo.add_attribute(cell, "text", 0)
359
 
                
360
 
 
361
 
                #downloader combobox
362
 
                
363
 
                downloaderListStore = gtk.ListStore(gobject.TYPE_STRING)
364
 
 
365
 
                for elem in self.downloaderOptions:
366
 
                        downloaderListStore.append([elem])
367
 
 
368
 
                self.downloaderCombo.set_model(downloaderListStore)
369
 
                self.downloaderCombo.set_active(0)
370
 
 
371
 
                self.downloaderCombo.pack_start(cell, True)
372
 
                self.downloaderCombo.add_attribute(cell, "text", 0)
373
 
 
374
 
                #colour depth combobox
375
 
                
376
 
                colourDepthListStore = gtk.ListStore(gobject.TYPE_STRING)
377
 
 
378
 
                for elem in self.colourDepthOptions:
379
 
                        colourDepthListStore.append([elem])
380
 
 
381
 
                self.colourDepthCombo.set_model(colourDepthListStore)
382
 
                self.colourDepthCombo.set_active(0)
383
 
 
384
 
                self.colourDepthCombo.pack_start(cell, True)
385
 
                self.colourDepthCombo.add_attribute(cell, "text", 0)
386
 
 
387
 
 
388
 
 
389
 
                #lift enable combobox
390
 
                
391
 
                liftEnableListStore = gtk.ListStore(gobject.TYPE_STRING)
392
 
 
393
 
                liftEnableOptions = ["True","False"]
394
 
 
395
 
                for elem in liftEnableOptions:
396
 
                        liftEnableListStore.append([elem])
397
 
 
398
 
                self.liftEnableCombo.set_model(liftEnableListStore)
399
 
                self.liftEnableCombo.set_active(0)
400
 
 
401
 
                self.liftEnableCombo.pack_start(cell, True)
402
 
                self.liftEnableCombo.add_attribute(cell, "text", 0)
403
 
 
404
 
 
405
 
                #Set the range of values we accept for the spin controls
406
 
 
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)
412
 
                
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)
419
 
 
420
 
                self.screenWidthText.configure(width_adj, 0, 0)
421
 
                self.screenWidthText.set_wrap(True)
422
 
 
423
 
                self.screenHeightText.configure(height_adj, 0, 0)
424
 
                self.screenHeightText.set_wrap(True)
425
 
                
426
 
                self.queueSizeText.configure(queue_adj, 0, 0)
427
 
                self.queueSizeText.set_wrap(True)
428
 
 
429
 
                self.refreshText.configure(refresh_adj, 0, 0)
430
 
                self.refreshText.set_wrap(True)
431
 
 
432
 
                self.logLevelSpin.configure(logLevel_adj, 0, 0)
433
 
                self.logLevelSpin.set_wrap(True)
434
 
        
435
 
                self.socketTimeSpin.configure(socketTime_adj,0,0)
436
 
                self.socketTimeSpin.set_wrap(True)
437
 
 
438
 
                self.framesSpin.configure(frames_adj,0,0)
439
 
                self.framesSpin.set_wrap(True)
440
 
 
441
 
                self.vwidthSpin.configure(vwidth_adj,0,0)
442
 
                self.vwidthSpin.set_wrap(True)
443
 
 
444
 
                self.vheightSpin.configure(vheight_adj,0,0)
445
 
                self.vheightSpin.set_wrap(True)
446
 
 
447
 
                self.vrotateSpin.configure(vrotate_adj,0,0)
448
 
                self.vrotateSpin.set_wrap(True)
449
 
 
450
 
                self.liftTriggerValue.configure(liftTrigger_adj,0,0)
451
 
                self.liftTriggerValue.set_wrap(True)
452
 
 
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")
468
 
 
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")
503
 
 
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")
508
 
 
509
 
                self.onlineOpLabel = self.builder.get_object("onlineOpLabel")
510
 
                self.offlineOpLabel  = self.builder.get_object("offlineOpLabel")
511
 
 
512
 
 
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
515
 
 
516
 
#               self.manualUpdateLabel.set_text(_("Manual Update"))
517
 
                self.xmdsLicenseKeyLabel.set_text(_("xmdsLicenseKey"))
518
 
 
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"))
533
 
 
534
 
                self.clientNameLabel.set_text(_("Client Name"))
535
 
 
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'))
568
 
 
569
 
                self.onlineOpLabel.set_label(_("Online operation (syncronise with Xibo server)"))
570
 
#               self.offlineOpLabel.set_label(_("Offline operation (synchronise with USB memory stick)"))
571
 
 
572
 
                #Set the icon for the Window
573
 
                self.window.set_icon_from_file("xibo.ico")
574
 
 
575
 
 
576
 
                #Now set the labels of the buttons and window
577
 
                
578
 
                self.clearButton.set_label(_("Clear Form"))
579
 
                self.saveButton.set_label(_("Save Config"))
580
 
                self.window.set_title(_("Xibo Client Configuration"))
581
 
 
582
 
 
583
 
                #Set up the combo box
584
 
 
585
 
#               manualUpdateListStore = gtk.ListStore(gobject.TYPE_STRING)
586
 
 
587
 
#               for elem in self.manualUpdateOptions:
588
 
#                       manualUpdateListStore.append([elem])
589
 
 
590
 
#               self.manualUpdateCombo.set_model(manualUpdateListStore)
591
 
#               self.manualUpdateCombo.set_active(1)
592
 
 
593
 
#               self.manualUpdateCombo.pack_start(cell, True)
594
 
#               self.manualUpdateCombo.add_attribute(cell, "text", 0)
595
 
 
596
 
                logFilePath = os.path.join(os.path.abspath(''),self.pyClientLogName)
597
 
 
598
 
                self.logFileLinkButton.set_uri("file:%s%s%s"%(os.sep,os.sep,logFilePath))
599
 
 
600
 
#               print "File path: ", logFilePath
601
 
 
602
 
                #Set the tick box to online operation
603
 
                self.offlineCheckButton.set_active(True)
604
 
                self.offlineCheckButton.set_active(False)
605
 
 
606
 
                #Set tooltips
607
 
                self.set_tooltips()
608
 
 
609
 
                self.window.show()
610
 
 
611
 
                #Check that the directory exists where the configuration file
612
 
                #is stored.
613
 
 
614
 
                if os.path.exists(self.pyclientConfPath):
615
 
                        if os.path.isfile(self.pyclientConfPath):
616
 
 
617
 
                                self.logger1.error("Python client path chosen is a file")
618
 
 
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"
623
 
#                               sys.exit()
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..."          
628
 
 
629
 
                                self.pyClientConfName = os.path.join(self.pyclientConfPath,self.pyClientConfName)                               
630
 
                else:
631
 
                        print "Configuration directory does not exist"
632
 
                        self.logger1.warning("Python client path chosen does not exist")
633
 
                        try:
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)
638
 
                        except OSError:
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()
642
 
 
643
 
 
644
 
                #Check that a file can be written to this directory
645
 
                try:
646
 
                        file_written = open(os.path.join(self.pyclientConfPath,"tmp"),"w")
647
 
                        file_written.close()
648
 
                except:
649
 
                        self.logger1.error("Could not write to testing file")                   
650
 
                
651
 
                is_file = os.path.isfile(os.path.join(self.pyclientConfPath,"tmp"))
652
 
                
653
 
                self.logger1.info("Testing file has been created in the chosen location")
654
 
                
655
 
                #Check that the file can be written to
656
 
 
657
 
                try:
658
 
                        file_edit = open(os.path.join(self.pyclientConfPath,"tmp"),"w")
659
 
                        file_edit.write("tmp")
660
 
                        file_edit.close()
661
 
                        print "boo"
662
 
                except:
663
 
                        self.logger1.info("Testing file could not be written to")
664
 
                        
665
 
                is_data = False
666
 
                data = None
667
 
 
668
 
                try:
669
 
                        data = open(os.path.join(self.pyclientConfPath,"tmp"),"r").read()
670
 
                except:
671
 
                        self.logger1.error("Cannot open testing file to read data")
672
 
                if data == "tmp":
673
 
                        is_data = True
674
 
                        self.logger1.info("Testing file could be written to")
675
 
                else:
676
 
                        self.logger1.info("Testing file could not be written to")
677
 
 
678
 
                #Check that the file can be deleted
679
 
                is_deleted = False
680
 
                try:
681
 
                        os.remove(os.path.join(self.pyclientConfPath,"tmp"))
682
 
                except:
683
 
                        self.logger1.error("Cannot delete testing file")
684
 
 
685
 
                if os.path.isfile(os.path.join(self.pyclientConfPath,"tmp")) == False:
686
 
                        is_deleted = True
687
 
                        self.logger1.info("Testing file has been deleted successfully")
688
 
 
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()
694
 
 
695
 
                else:
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"))
701
 
#                       sys.exit()
702
 
 
703
 
 
704
 
 
705
 
                print self.pyClientConfName
706
 
 
707
 
 
708
 
                if is_deleted and is_data and is_file:
709
 
 
710
 
                        #Read the configuration information from the configuration file
711
 
                        self.readConfig()
712
 
 
713
 
                #Check to see if the client ID field is blank. 
714
 
                #If so, then generate one
715
 
 
716
 
                if self.clientIDText.get_text() == "":
717
 
                        uuid = self.genClientID()
718
 
                        self.clientIDText.set_text(str(uuid))           
719
 
 
720
 
        def messageDialogExit(self,widget):
721
 
                sys.exit()
722
 
 
723
 
        def infoDialogOKSignal(self,widget):
724
 
                self.messageDialog.hide()
725
 
 
726
 
        def offlineOperationToggle(self,widget):
727
 
                
728
 
                offlineOperation = widget.get_active()
729
 
 
730
 
                self.logger8.info(_("Offline operation checkbox toggled"))
731
 
 
732
 
                if offlineOperation:
733
 
                        print "Offline operation selected"
734
 
#                       self.manualUpdateCombo.set_sensitive(True)
735
 
                #       self.xmdsLicenseKeyEntry.set_sensitive(True)
736
 
 
737
 
                        self.logger8.info(_("Offline operation selected"))
738
 
 
739
 
                        self.serverURLText.set_sensitive(False)
740
 
                        self.clientIDText.set_sensitive(False)
741
 
                        self.serverKeyText.set_sensitive(False)
742
 
                        self.clientNameText.set_sensitive(False)
743
 
                        
744
 
                else:
745
 
                        print "Online operation selected"
746
 
                        self.logger8.info(_("Online operation selected"))
747
 
#                       self.manualUpdateCombo.set_sensitive(False)
748
 
                #       self.xmdsLicenseKeyEntry.set_sensitive(False)
749
 
                        
750
 
                        self.serverURLText.set_sensitive(True)
751
 
                        self.clientIDText.set_sensitive(True)
752
 
                        self.serverKeyText.set_sensitive(True)
753
 
                        self.clientNameText.set_sensitive(True)                 
754
 
                        
755
 
        def on_advancedOptionsCheck(self,widget):
756
 
                """Function called when advanced options checkbox is toggled.
757
 
                Used to hide / display the advanced notebook tab"""
758
 
 
759
 
                advancedPage = self.notebook1.get_nth_page(3)           
760
 
 
761
 
                if self.advancedOptionsCheck.get_active() and self.advancedTabVisible == False:
762
 
                        advancedPage.show()
763
 
                        self.advancedTabVisible = True
764
 
                        self.logger6.info(_("advancedTabEnabled"))
765
 
                
766
 
                elif self.advancedOptionsCheck.get_active() == False and self.advancedTabVisible:
767
 
                        advancedPage.hide()
768
 
                        self.advancedTabVisible = False
769
 
                        self.logger6.info(_("advancedTabDisabled"))
770
 
 
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"))
774
 
                config_file = ""
775
 
                try:
776
 
                        config_file = open(self.clientConfFile,"r")
777
 
 
778
 
                        #Implement all the stuff to read the config file in
779
 
                        data = config_file.read()
780
 
                        config_file.close()
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
783
 
 
784
 
                        if len(data) != 0:
785
 
                                config = ConfigParser.ConfigParser()
786
 
                                config.read(self.clientConfFile)
787
 
 
788
 
                                self.logger7.info(_("Reading configuration file"))
789
 
 
790
 
                                #Get the information from the configuration file
791
 
                                #and display into the GUI
792
 
                                
793
 
                                #Xibo client configuration file location
794
 
                                xiboClientConf = None
795
 
 
796
 
                                try:
797
 
                                        xiboClientConf = config.get('Main','clientConfName')
798
 
                                except:
799
 
                                        xiboClientConf = "site.cfg"
800
 
                                        
801
 
                                self.logger7.info(_("Client configuration: %s"%xiboClientConf))                         
802
 
 
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])
807
 
 
808
 
                                print logTypeOptions
809
 
 
810
 
                                #Options pertaining to log type (human readable form)
811
 
                                logTypeHumanOptions = config.get("Options","logTypeHuman").split(",")
812
 
 
813
 
                                for i in range(len(logTypeHumanOptions)):
814
 
                                        logTypeHumanOptions[i] = _(logTypeHumanOptions[i])
815
 
 
816
 
                                self.logger7.info(_("logTypeOptions: %s"%logTypeOptions))
817
 
 
818
 
                                self.logger7.info(_("logTypeHumanOptions: %s"%logTypeHumanOptions))
819
 
 
820
 
                                #Options pertaining to scheduler
821
 
                                schedulerOptions = config.get("Options","scheduler").split(",")
822
 
                                for i in range(len(schedulerOptions)):
823
 
                                        schedulerOptions[i] = _(schedulerOptions[i])
824
 
 
825
 
                                print schedulerOptions
826
 
 
827
 
                                self.logger7.info(_("schedulerOptions: %s"%schedulerOptions))
828
 
                                
829
 
 
830
 
                                #Options pertaining to downloader
831
 
                                downloaderOptions = config.get("Options","downloader").split(",")
832
 
                                for i in range(len(downloaderOptions)):
833
 
                                        downloaderOptions[i] = _(downloaderOptions[i])
834
 
 
835
 
                                print downloaderOptions
836
 
 
837
 
                                self.logger7.info(_("downloaderOptions: %s"%downloaderOptions))
838
 
 
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])
843
 
 
844
 
                                print colourDepthOptions
845
 
 
846
 
                                self.logger7.info(_("colourDepthOptions: %s"%colourDepthOptions))
847
 
 
848
 
                                clientConfLoc = None
849
 
                                
850
 
                                try:
851
 
                                        clientConfLoc = config.get("Main","clientConfLoc")
852
 
                                except:
853
 
                                        clientConfLoc = os.path.expanduser('~/.xibo')
854
 
                                        
855
 
                                clientConfName = None
856
 
                                try:
857
 
                                        clientConfName = config.get("Main","clientConfName")
858
 
                                except:
859
 
                                        clientConfName = "site.cfg"
860
 
                                        
861
 
                                        
862
 
                                self.logger7.info(_("clientConfLocation: %s"%clientConfLoc))
863
 
                                self.logger7.info(_("clientConfName: %s"%clientConfName))
864
 
 
865
 
 
866
 
                                return {"xiboClientConf":xiboClientConf,"logTypeOptions":logTypeOptions,"logTypeHumanOptions":logTypeHumanOptions,"clientConfLoc":clientConfLoc,"clientConfName":clientConfName,"schedulerOptions":schedulerOptions,"downloaderOptions":downloaderOptions,"colourDepthOptions":colourDepthOptions}
867
 
 
868
 
                        else:
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()
872
 
 
873
 
                except:
874
 
                        print "Could not open the configuration application configuration file"
875
 
 
876
 
                        self.logger7.error(_("Could not open configuration file. Cannot continue"))
877
 
 
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()
880
 
                        return -1
881
 
 
882
 
        def clearFormSignal(self,widget,data=None):
883
 
                
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("")
894
 
 
895
 
                self.screenWidthText.set_value(0)
896
 
                self.screenHeightText.set_value(0)
897
 
                self.queueSizeText.set_value(0)
898
 
 
899
 
 
900
 
                self.clearButton.set_tooltip_text(_("Clear input fields"))
901
 
                self.saveButton.set_tooltip_text(_("Save data to file")) 
902
 
 
903
 
                self.logLevelSpin.set_value(0)
904
 
                
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)
911
 
 
912
 
                
913
 
                self.checksumCheckButton.set_active(False) 
914
 
                self.lowTextureCheckButton.set_active(False)
915
 
        
916
 
                self.clientNameText.set_text("") 
917
 
 
918
 
                #Advanced options widgets
919
 
 
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) 
932
 
 
933
 
                self.dateFormatEntry.set_text("") 
934
 
                self.libraryEntry.set_text("")
935
 
                self.socketTimeSpin.set_value(0)
936
 
 
937
 
                self.framesSpin.set_value(0) 
938
 
                self.vwidthSpin.set_value(0)
939
 
                self.vheightSpin.set_value(0)
940
 
                self.vrotateSpin.set_value(0)
941
 
 
942
 
                self.xmdsLicenseKeyEntry.set_text("")
943
 
                
944
 
                self.logger9.info("Clearing form elements")
945
 
 
946
 
        def logTypeComboChanged(self,widget,data=None):
947
 
 
948
 
                model = widget.get_model()
949
 
                index = widget.get_active()
950
 
                logTypeText = model[index][0].lower()
951
 
 
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()
957
 
                else:
958
 
                        self.logFileLinkButton.hide()
959
 
 
960
 
                val = widget.get_active()
961
 
 
962
 
 
963
 
        def onDestroy(self,widget,data=None):
964
 
                """
965
 
                Close the program. Executes when the main
966
 
                window is destroyed
967
 
                """
968
 
                self.logger10.info("Exiting program")
969
 
                gtk.main_quit()
970
 
 
971
 
 
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)
976
 
                
977
 
        def readConfig(self):
978
 
                """Function used to read in the configuration file and
979
 
                fill in the GUI text elements"""
980
 
 
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
983
 
                #fields on the GUI
984
 
 
985
 
                #Try opening the configuration file, if it does not exists, then
986
 
                #create it
987
 
 
988
 
                config_file = ""
989
 
                try:
990
 
                        config_file = open(self.pyClientConfName,"r")
991
 
 
992
 
                        self.logger2.info("Config. file opened successfully")
993
 
 
994
 
                        #Implement all the stuff to read the config file in
995
 
                        data = config_file.read()
996
 
                        config_file.close()
997
 
                        #If the file is not empty, then try and process it
998
 
 
999
 
                        if len(data) != 0:
1000
 
                                self.logger2.info("Config. data read in successfully")
1001
 
 
1002
 
 
1003
 
                                self.readDataFromConfigFile(self.pyClientConfName,self.logger2)
1004
 
 
1005
 
                                
1006
 
                except IOError:
1007
 
                        print "Cannot open"
1008
 
                        self.logger2.warning("Cannot open configuration file")
1009
 
                        #Read in the values from the site.cfg.default
1010
 
 
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()
1014
 
 
1015
 
                        
1016
 
                        
1017
 
 
1018
 
        def readDataFromConfigFile(self,confFileName,logger,defaults=False):
1019
 
 
1020
 
 
1021
 
                config = ConfigParser.ConfigParser()
1022
 
                config.read(confFileName)
1023
 
 
1024
 
                #Get the information from the configuration file
1025
 
                #and display into the GUI
1026
 
 
1027
 
                try:
1028
 
                        self.serverURLText.set_text(config.get('Main','xmdsUrl'))
1029
 
                        logger.info("serverURL: %s"%config.get('Main','xmdsUrl'))
1030
 
                except:
1031
 
                        self.confValErr('xmdsUrl',logger)
1032
 
 
1033
 
                if defaults == False:
1034
 
                        try:
1035
 
                                self.clientIDText.set_text(config.get("Main","xmdsClientID"))
1036
 
                                logger.info("clientID: %s"%config.get('Main','xmdsClientID'))
1037
 
                        except:
1038
 
                                self.confValErr("xmdsClientID",logger)
1039
 
                                logger.warning("xmdClientID item not in config. file")
1040
 
 
1041
 
                try:
1042
 
                        self.serverKeyText.set_text(config.get('Main','xmdsKey'))
1043
 
                        logger.info("xmdsKey: %s"%config.get('Main','xmdsKey'))
1044
 
                except:
1045
 
                        self.confValErr('xmdsKey',logger)
1046
 
 
1047
 
                try: 
1048
 
                        self.refreshText.set_text(config.get('Main','xmdsUpdateInterval'))
1049
 
                        logger.info("xmdsUpdateInterval: %s"%config.get('Main','xmdsUpdateInterval'))
1050
 
                except:
1051
 
                        self.confValErr('xmdsUpdateInterval',logger)
1052
 
 
1053
 
                try:
1054
 
                        self.clientNameText.set_text(config.get('Main','xmdsClientName'))
1055
 
                        logger.info("xmdsClientName: %s"%config.get('Main','xmdsClientName'))
1056
 
                except:
1057
 
                        self.confValErr('xmdsClientName',logger)                        
1058
 
 
1059
 
 
1060
 
                try:
1061
 
                        requireXmds = False
1062
 
                        if config.get('Main','requireXmds') == "true":
1063
 
                                requireXmds = True
1064
 
 
1065
 
                        self.serverConnBool.set_active(requireXmds)
1066
 
                        logger.info("requireXMDS: %s"%requireXmds)
1067
 
 
1068
 
                except:
1069
 
                        self.confValErr("requireXmds",logger)
1070
 
 
1071
 
                try:
1072
 
                        fullScreen = False
1073
 
                        if config.get('Main','fullscreen') == "true":
1074
 
                                fullScreen = True
1075
 
                        self.fullScreenBool.set_active(fullScreen)
1076
 
                        logger.info("fullscreen: %s"%fullscreen)
1077
 
                
1078
 
 
1079
 
                except:
1080
 
                        self.confValErr("fullscreen",logger)                                    
1081
 
 
1082
 
                try:
1083
 
                        captureStats = False
1084
 
                        if config.get('Stats','collect') == "true":
1085
 
                                captureStats = True
1086
 
                        logger.info("captureStats: %s"%captureStats)
1087
 
 
1088
 
                        self.captureStatisticsBool.set_active(captureStats)
1089
 
                except:
1090
 
                        self.confValErr("Stats - Collect",logger)
1091
 
 
1092
 
 
1093
 
                try:
1094
 
                        self.screenWidthText.set_value(int(config.get('Main','width')))
1095
 
                        logger.info("screenWidth: %s"%config.get('Main','width'))
1096
 
 
1097
 
                except:
1098
 
                        self.confValErr("width",logger)
1099
 
 
1100
 
                try:
1101
 
                        self.screenHeightText.set_value(int(config.get('Main','height')))
1102
 
                        logger.info("screenHeight: %s"%config.get('Main','height'))
1103
 
 
1104
 
                except:
1105
 
                        self.confValErr("height",logger)
1106
 
 
1107
 
                try:
1108
 
                        self.queueSizeText.set_value(int(config.get('Stats','queueSize')))
1109
 
                        logger.info("queueSize: %s"%config.get('Stats','queueSize'))
1110
 
 
1111
 
                except:
1112
 
                        self.confValErr("queueSize",logger)
1113
 
 
1114
 
                try:
1115
 
                        self.logLevelSpin.set_value(int(config.get('Logging','logLevel')))
1116
 
                        logger.info("Logging level: %s"%config.get('Logging','logLevel'))
1117
 
                
1118
 
                except:
1119
 
                        self.confValErr("logLevel",logger)
1120
 
 
1121
 
                try:                            
1122
 
                        logType = config.get('Logging','logWriter')
1123
 
 
1124
 
                        val = 0
1125
 
 
1126
 
                        for elem in self.logWriterTypes:
1127
 
                                if elem.lower() == logType.lower():
1128
 
                                        print elem.lower(), logType.lower()
1129
 
                                        break
1130
 
                                val += 1
1131
 
                        print "*"*len(str(self.logWriterTypes))
1132
 
                        print logType
1133
 
                        print self.logWriterTypes
1134
 
                        print " "*(len(str(self.logWriterTypes))/2),val
1135
 
                        print self.logWriterHumanTypes
1136
 
                        print "*"*len(str(self.logWriterTypes))
1137
 
 
1138
 
                        logger.info("logWriter: %s"%self.logWriterTypes[val])
1139
 
                        logger.info("logWriterHuman: %s"%self.logWriterHumanTypes[val])
1140
 
                        self.logTypeCombo.set_active(val)                               
1141
 
                except:
1142
 
                        self.confValErr("logWriter",logger)
1143
 
        
1144
 
 
1145
 
                #Advanced options
1146
 
 
1147
 
                try:
1148
 
                        self.dateFormatEntry.set_text(config.get("TickerMedia","dateFormat"))
1149
 
                        logger.info("tickerMedia: %s"%config.get('TickerMedia','dateFormat'))
1150
 
 
1151
 
                except:
1152
 
                        self.confValErr("dateFormat",logger)
1153
 
 
1154
 
                try:
1155
 
                        self.libraryEntry.set_text(config.get("Main","libraryDir"))
1156
 
                        logger.info("libraryDir: %s"%config.get('Main','libraryDir'))
1157
 
 
1158
 
                except:
1159
 
                        self.confValErr("libraryDir",logger)
1160
 
 
1161
 
                try:
1162
 
                        self.socketTimeSpin.set_value(int(config.get("Main","socketTimeout")))
1163
 
                        logger.info("socketTimeout: %s"%config.get('Main','socketTimeout'))
1164
 
 
1165
 
                except:
1166
 
                        self.confValErr("socketTimeout",logger)
1167
 
 
1168
 
                try:
1169
 
                        self.framesSpin.set_value(int(config.get("Main","fps")))
1170
 
                        logger.info("FPS: %s"%config.get('Main','fps'))
1171
 
                
1172
 
                except:
1173
 
                        self.confValErr("fps",logger)                                   
1174
 
 
1175
 
                try:
1176
 
                        self.vwidthSpin.set_value(int(config.get("Main","vwidth")))
1177
 
                        logger.info("VirtualWidth: %s"%config.get('Main','vwidth'))
1178
 
 
1179
 
                except:
1180
 
                        self.confValErr("vwidth",logger)
1181
 
 
1182
 
                try:
1183
 
                        self.vheightSpin.set_value(int(config.get("Main","vheight")))
1184
 
                        logger.info("VirtualHeight: %s"%config.get('Main','vheight'))
1185
 
 
1186
 
                except:
1187
 
                        self.confValErr("vheight",logger)
1188
 
 
1189
 
                try:
1190
 
                        self.vrotateSpin.set_value(int(config.get("Main","vrotation")))
1191
 
                        logger.info("VirtualRotation: %s"%config.get('Main','vrotation'))
1192
 
 
1193
 
                except:
1194
 
                        self.confValErr("vrotation",logger)
1195
 
 
1196
 
 
1197
 
                try:
1198
 
                        self.xmdsLicenseKeyEntry.set_text(config.get("Main","xmdsLicenseKey"))
1199
 
                        logger.info("xmdsLicenseKey: %s"%config.get('Main','xmdsLicenseKey'))
1200
 
 
1201
 
                except:
1202
 
                        self.confValErr('xmdsLicenseKey',logger)
1203
 
 
1204
 
 
1205
 
                #Sort out the combo boxes
1206
 
 
1207
 
                try:
1208
 
                        schedType = config.get("Main","Scheduler")
1209
 
 
1210
 
                        val = 0
1211
 
                        for elem in self.schedulerOptions:
1212
 
                                if elem.lower() == schedType.lower():
1213
 
                                        break
1214
 
                                val += 1
1215
 
                        logger.info("scheduler: %s"%self.schedulerOptions[val])
1216
 
 
1217
 
                        self.schedulerCombo.set_active(val)
1218
 
                except:
1219
 
                        self.confValErr("scheduler",logger)
1220
 
        
1221
 
                try:
1222
 
                        dloadType = config.get("Main","Downloader")
1223
 
 
1224
 
                        val = 0
1225
 
                        for elem in self.downloaderOptions:
1226
 
                                if elem.lower() == dloadType.lower():
1227
 
                                        break
1228
 
                                val += 1
1229
 
                        logger.info("downloader: %s"%self.downloaderOptions[val])
1230
 
 
1231
 
                        self.downloaderCombo.set_active(val)
1232
 
                except:
1233
 
                        self.confValErr("downloader",logger)
1234
 
        
1235
 
                try:
1236
 
                        bppType = config.get("Main","bpp")
1237
 
 
1238
 
                        val = 0
1239
 
 
1240
 
                        for elem in self.colourDepthOptions:
1241
 
                                if elem.lower() == bppType.lower():
1242
 
                                        break
1243
 
                                val += 1
1244
 
                        logger.info("BPP: %s"%self.colourDepthOptions[val])
1245
 
 
1246
 
                        self.colourDepthCombo.set_active(val)
1247
 
                except:
1248
 
                        self.confValErr("bpp",logger)
1249
 
 
1250
 
                #USB update section
1251
 
                try:
1252
 
                        manualUpdateType = config.get("Main","manualUpdate")
1253
 
                        logger.info("offlineUpdate: %s"%manualUpdateType)
1254
 
 
1255
 
                        if manualUpdateType == "true":
1256
 
                                manualUpdateType = True
1257
 
                        elif manualUpdateType == "false":
1258
 
                                manualUpdateType = False
1259
 
 
1260
 
                        if manualUpdateType == True or manualUpdateType == False:
1261
 
                                if manualUpdateType == True:
1262
 
                                        print "Stuff done"
1263
 
                                        self.offlineCheckButton.set_active(True)
1264
 
                                        self.offlineOperationToggle(self,self.offlineCheckButton)
1265
 
 
1266
 
                except:
1267
 
                        self.confValErr('offlineUpdate',logger)
1268
 
                        print "Manual Update Failed"
1269
 
                
1270
 
                #Now the check boxes
1271
 
 
1272
 
                checksum = False
1273
 
                try:
1274
 
                        if config.get('Main','checksumPreviousDownloads') == "true":
1275
 
                                checksum = True
1276
 
                        
1277
 
                        logger.info("checksumPreviousDownloads: %s"%checksum)
1278
 
 
1279
 
                except:
1280
 
                        self.confValErr("checksumPreviousDownloads",logger)
1281
 
 
1282
 
 
1283
 
                lowTexture = False
1284
 
 
1285
 
                try:
1286
 
                        if config.get('Main','lowTextureMemory') == "true":
1287
 
                                lowTexture = True
1288
 
                        logger.info("lowTextureMemory: %s"%lowTexture)
1289
 
 
1290
 
                except:
1291
 
                        self.confValErr("lowTextureMemory",logger)      
1292
 
 
1293
 
 
1294
 
                self.checksumCheckButton.set_active(checksum)
1295
 
 
1296
 
                self.lowTextureCheckButton.set_active(lowTexture)
1297
 
 
1298
 
 
1299
 
                #Now the lift options
1300
 
                try:
1301
 
                        self.liftDefaultTagText.set_text(config.get("LiftTags","default"))
1302
 
                        logger.info("DefaultLiftTag: %s"%config.get('LiftTags','default'))
1303
 
 
1304
 
                except:
1305
 
                        self.confValErr("liftTags",logger)
1306
 
 
1307
 
                try:
1308
 
                        self.lift7TagText.set_text(config.get("LiftTags","lift7"))
1309
 
                        logger.info("Lift7Tag: %s"%config.get('LiftTags','lift7'))
1310
 
 
1311
 
                except:
1312
 
                        self.confValErr("lift7",logger)
1313
 
 
1314
 
                try:
1315
 
                        self.lift6TagText.set_text(config.get("LiftTags","lift6"))
1316
 
                        logger.info("Lift6Tag: %s"%config.get('LiftTags','lift6'))
1317
 
                except:
1318
 
                        self.confValErr("lift6",logger)
1319
 
 
1320
 
                try:
1321
 
                        self.lift5TagText.set_text(config.get("LiftTags","lift5"))
1322
 
                        logger.info("Lift5Tag: %s"%config.get('LiftTags','lift5'))
1323
 
                except:
1324
 
                        self.confValErr("lift5",logger)
1325
 
 
1326
 
                try:
1327
 
                        self.lift4TagText.set_text(config.get("LiftTags","lift4"))
1328
 
                        logger.info("Lift4Tag: %s"%config.get('LiftTags','lift4'))
1329
 
                except:
1330
 
                        self.confValErr("lift4",logger)
1331
 
 
1332
 
                try:
1333
 
                        self.lift3TagText.set_text(config.get("LiftTags","lift3"))
1334
 
                        logger.info("Lift3Tag: %s"%config.get('LiftTags','lift3'))
1335
 
                except:
1336
 
                        self.confValErr("lift3",logger)
1337
 
 
1338
 
                try:
1339
 
                        self.lift2TagText.set_text(config.get("LiftTags","lift2"))
1340
 
                        logger.info("Lift2Tag: %s"%config.get('LiftTags','lift2'))
1341
 
                except:
1342
 
                        self.confValErr("lift2",logger)
1343
 
 
1344
 
                try:
1345
 
                        self.lift1TagText.set_text(config.get("LiftTags","lift1"))
1346
 
                        logger.info("Lift1Tag: %s"%config.get('LiftTags','lift1'))
1347
 
                except:
1348
 
                        self.confValErr("lift1",logger)
1349
 
 
1350
 
                try:
1351
 
                        self.lift0TagText.set_text(config.get("LiftTags","lift0"))
1352
 
                        logger.info("Lift0Tag: %s"%config.get('LiftTags','lift0'))
1353
 
                except:
1354
 
                        self.confValErr("lift0",logger)
1355
 
 
1356
 
                try:
1357
 
                        self.firstSerialText.set_text(config.get("Lift","serial0"))
1358
 
                        logger.info("FirstSerial: %s"%config.get('Lift','serial0'))
1359
 
                except:
1360
 
                        self.confValErr("serial0",logger)
1361
 
 
1362
 
                try:
1363
 
                        self.secondSerialText.set_text(config.get("Lift","serial1"))
1364
 
                        logger.info("SecondSerial: %s"%config.get('Lift','serial1'))
1365
 
                except:
1366
 
                        self.confValErr("serial1",logger)
1367
 
 
1368
 
                try:
1369
 
                        self.liftTriggerValue.set_value(int(config.get("Lift","trigger")))
1370
 
                        logger.info("LiftTrigger: %s"%config.get('Lift','trigger'))
1371
 
                except:
1372
 
                        self.confValErr("trigger",logger)                               
1373
 
 
1374
 
                try:
1375
 
 
1376
 
                        liftEnableType = config.get("Lift","enabled")
1377
 
                        logger.info("LiftEnabled: %s"%config.get('Lift','enabled'))
1378
 
 
1379
 
                        val = 0
1380
 
 
1381
 
                        for elem in self.liftEnableOptions:
1382
 
                                if elem.lower() == liftEnableType.lower():
1383
 
                                        break
1384
 
                                val += 1
1385
 
 
1386
 
                        self.liftEnableCombo.set_active(val)
1387
 
                except:
1388
 
                        self.confValErr("liftEnabled",logger)
1389
 
 
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()
1394
 
 
1395
 
                config.optionxform = str
1396
 
 
1397
 
                configOptions = ["Main", "Logging", "Stats", "TickerMedia", "Lift", "LiftTags"]
1398
 
 
1399
 
                for configOption in configOptions:
1400
 
                        #print configOption
1401
 
                        config.add_section(configOption)
1402
 
 
1403
 
                        for elem in a:
1404
 
                                #print elem, a[elem][1], configOption
1405
 
                                if a[elem][0] == configOption:
1406
 
                                        print elem, a[elem][1],configOption
1407
 
                                        try:
1408
 
 
1409
 
                                                config.set(configOption, elem, str(a[elem][1]))
1410
 
                                                self.logger11.info("Value: %s %s %s"%(configOption,elem,str(a[elem][1])))               
1411
 
                                        except:
1412
 
                                                print "Error setting option:"
1413
 
                                                print "Element:", elem
1414
 
                                                print "Data:", a[elem]
1415
 
                                                print "Error setting: %s, %s"%(elem,a[elem][1])
1416
 
                                                print 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])))
1419
 
                                        finally:
1420
 
                                                #Write everything, barring the error item
1421
 
 
1422
 
                                        #       with open(self.pyClientConfName, 'wb') as configfile:
1423
 
                                        #               config.write(configfile)
1424
 
 
1425
 
                                                try:
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()
1431
 
 
1432
 
                                                except:
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()
1436
 
 
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
1440
 
 
1441
 
#               #I have chosen this way because then we can keep the comments
1442
 
#               #in place for manual usage
1443
 
        
1444
 
#               config_template_string = ""
1445
 
#               try:
1446
 
#                       f = open("site.cfg.default","r")
1447
 
#                       config_template_string = f.read()
1448
 
#                       f.close()
1449
 
#               except:
1450
 
#                       print "Error reading default config file"
1451
 
 
1452
 
                #Now create the string to write to the new config. file
1453
 
 
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"])
1455
 
 
1456
 
#               #Now write the configuration file
1457
 
 
1458
 
#               try:
1459
 
#                       f = open(self.pyClientConfLoc,"w")
1460
 
#               #       f.write(config_string)
1461
 
#                       f.close()
1462
 
#               except:
1463
 
#                       print "Could not write configuration file"
1464
 
 
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)
1469
 
                return uuidStr
1470
 
 
1471
 
 
1472
 
        def set_tooltips(self):
1473
 
 
1474
 
                self.clearButton.set_tooltip_text(_("Clear input fields"))
1475
 
                self.saveButton.set_tooltip_text(_("Save data to file")) 
1476
 
 
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")) 
1490
 
 
1491
 
                #Advanced options widgets
1492
 
 
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")) 
1518
 
 
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"))
1521
 
 
1522
 
        def getConfValues(self):
1523
 
 
1524
 
                model = self.logTypeCombo.get_model()
1525
 
                index = self.logTypeCombo.get_active()
1526
 
#               logTypeText = model[index][0]
1527
 
 
1528
 
                logTypeText = self.logWriterTypes[index]
1529
 
                
1530
 
                configType = "Main"
1531
 
 
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()]
1545
 
 
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)
1559
 
                
1560
 
                #Take the boolean values and make them lower case.
1561
 
 
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}
1563
 
 
1564
 
                #GET THE LIFT OPTIONS
1565
 
                
1566
 
 
1567
 
                #ONLY DO THIS IF THE LIFT TAB IS SHOWING
1568
 
                #THEN ADD THEM TO THE DICTIONARY
1569
 
 
1570
 
#               if self.liftTabVisible == True:
1571
 
 
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
1575
 
                if 1:
1576
 
 
1577
 
                        configType = "Lift"
1578
 
                        configType1 = "LiftTags"
1579
 
 
1580
 
                        model = self.liftEnableCombo.get_model()
1581
 
                        index = self.liftEnableCombo.get_active()
1582
 
                        liftEnableText = model[index][0].lower()
1583
 
 
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]
1597
 
                
1598
 
                        if liftDefaultTag[1] != "":
1599
 
                                configOptions["default"] = liftDefaultTag
1600
 
 
1601
 
                        if lift7Tag[1] != "":
1602
 
                                configOptions["lift7"] =lift7Tag
1603
 
 
1604
 
                        if lift6Tag[1] != "":
1605
 
                                configOptions["lift6"] =lift6Tag
1606
 
 
1607
 
                        if lift5Tag[1] != "":
1608
 
                                configOptions["lift5"] =lift5Tag
1609
 
 
1610
 
                        if lift4Tag[1] != "":
1611
 
                                configOptions["lift4"] =lift4Tag
1612
 
 
1613
 
                        if lift3Tag[1] != "":
1614
 
                                configOptions["lift3"] =lift3Tag
1615
 
 
1616
 
                        if lift2Tag[1] != "":
1617
 
                                configOptions["lift2"] =lift2Tag
1618
 
 
1619
 
                        if lift1Tag[1] != "":
1620
 
                                configOptions["lift1"] =lift1Tag
1621
 
                
1622
 
                        if lift0Tag[1] != "":
1623
 
                                configOptions["lift0"] =lift0Tag
1624
 
 
1625
 
                        if firstSerial[1] != "":
1626
 
                                configOptions["serial0"] =firstSerial
1627
 
 
1628
 
                        if secondSerial[1] != "":
1629
 
                                configOptions["serial1"] =secondSerial
1630
 
 
1631
 
                        if liftEnable[1] != "false":
1632
 
                                configOptions["enabled"] =liftEnable
1633
 
 
1634
 
                        if liftTrigger != "0":
1635
 
                                configOptions["trigger"] =liftTrigger
1636
 
 
1637
 
#               if self.advancedTabVisible == True:
1638
 
 
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
1642
 
                if 1:
1643
 
                        configType = "Main"
1644
 
 
1645
 
                        model = self.schedulerCombo.get_model()
1646
 
                        index = self.schedulerCombo.get_active()
1647
 
                        schedulerComboText = model[index][0]
1648
 
 
1649
 
                        model = self.downloaderCombo.get_model()
1650
 
                        index = self.downloaderCombo.get_active()
1651
 
                        downloaderComboText = model[index][0]
1652
 
 
1653
 
                        model = self.colourDepthCombo.get_model()
1654
 
                        index = self.colourDepthCombo.get_active()
1655
 
                        colourDepthComboText = model[index][0]
1656
 
 
1657
 
                        xmdsLicenseKeyEntry = [configType,self.xmdsLicenseKeyEntry.get_text()]
1658
 
 
1659
 
#                       model = self.manualUpdateCombo.get_model()
1660
 
#                       index = self.manualUpdateCombo.get_active()
1661
 
#                       manualUpdateText = model[index][0]
1662
 
 
1663
 
                        manualUpdateText = str(self.offlineCheckButton.get_active()).lower()
1664
 
 
1665
 
                        manualUpdate = [configType,manualUpdateText.lower()]
1666
 
 
1667
 
                        dateFormatEntry = ["TickerMedia", self.dateFormatEntry.get_text()]
1668
 
                
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()]
1673
 
 
1674
 
 
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]
1682
 
                        
1683
 
                        if xmdsLicenseKeyEntry[1] != "":
1684
 
                                configOptions["xmdsLicenseKey"] = xmdsLicenseKeyEntry
1685
 
 
1686
 
                        if manualUpdateText[1] != "":
1687
 
                                configOptions["manualUpdate"] = manualUpdate
1688
 
 
1689
 
 
1690
 
                        if dateFormatEntry[1] != "":    
1691
 
                                configOptions["dateFormat"] = dateFormatEntry
1692
 
        
1693
 
                        if libraryEntry[1] != "":
1694
 
                                configOptions["libraryDir"] = libraryEntry
1695
 
        
1696
 
                        if socketTimeSpin[1] != "0":
1697
 
                                configOptions["socketTimeout"] = socketTimeSpin
1698
 
 
1699
 
                        if checksum[1] == "true":
1700
 
                                configOptions["checksumPreviousDownloads"] = checksum
1701
 
 
1702
 
                        if lowTexture[1] == "true":
1703
 
                                configOptions["lowTextureMemory"] = lowTexture
1704
 
 
1705
 
                        if frames[1] != "0":
1706
 
                                configOptions["fps"] = frames
1707
 
        
1708
 
                        if vwidth[1] != "0":
1709
 
                                configOptions["vwidth"] = vwidth
1710
 
 
1711
 
                        if vheight[1] != "0":
1712
 
                                configOptions["vheight"] = vheight
1713
 
 
1714
 
                        if vrotate[1] != "0":
1715
 
                                configOptions["vrotation"] = vrotate
1716
 
 
1717
 
                        if scheduler[1] != "":
1718
 
                                configOptions["scheduler"] = scheduler
1719
 
 
1720
 
                        if downloader[1] != "":
1721
 
                                configOptions["downloader"] = downloader
1722
 
 
1723
 
                        if colourDepth[1] != "":
1724
 
                                configOptions["bpp"] = colourDepth 
1725
 
 
1726
 
                return configOptions
1727
 
def cmdOptions():
1728
 
        options = sys.argv[1:]
1729
 
        
1730
 
        #For each option in the array strip off any - characters and convert to lower case
1731
 
        
1732
 
        for i in range(len(options)):
1733
 
                options[i] = options[i].strip("-").lower()
1734
 
 
1735
 
        return options
1736
 
 
1737
 
if __name__ == "__main__":
1738
 
 
1739
 
        #Grab the command line options
1740
 
        options = cmdOptions()
1741
 
        
1742
 
        #Find out of the lift option has been passed
1743
 
        lift = False
1744
 
        try:
1745
 
                options.index("lift")
1746
 
                lift = True
1747
 
        except ValueError:
1748
 
                print "Option not found"
1749
 
                lift = False
1750
 
 
1751
 
 
1752
 
        wine = xiboConfWindow("client.conf", lift = lift)
1753
 
        gtk.main()