/usr/lib/python2.7/dist-packages/testdrivegtk/PreferencesTestdrivegtkDialog.py is in testdrive-gtk 3.27-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
### BEGIN LICENSE
# Copyright (C) 2010 Canonical Ltd.
#
# Authors:
# Andres Rodriguez <andreserl@ubuntu.com>
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 3, as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranties of
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
# PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
### END LICENSE
#from desktopcouch.records.server import CouchDatabase
#from desktopcouch.records.record import Record
import gtk
import ConfigParser
import os
import commands
from testdrive import testdrive
from testdrivegtk.helpers import get_builder
import gettext
from gettext import gettext as _
gettext.textdomain('testdrive')
ISO_REPOSITORY = ['cdimage', 'releases']
MEM_SIZE_TAB = ['256', '384', '512', '1024', '2048',_('Other...')]
DISK_SIZE_TAB = ['4', '6', '8', '10', '16',_('Other...')]
class PreferencesTestdrivegtkDialog(gtk.Dialog):
__gtype_name__ = "PreferencesTestdrivegtkDialog"
preferences = {}
def __new__(cls):
"""Special static method that's automatically called by Python when
constructing a new instance of this class.
Returns a fully instantiated PreferencesTestdrivegtkDialog object.
"""
import logging
logging.basicConfig(level=logging.DEBUG)
logger1 = logging.getLogger('gtkpreferences')
logger1.debug('__new__')
builder = get_builder('PreferencesTestdrivegtkDialog')
new_object = builder.get_object("preferences_testdrivegtk_dialog")
new_object.finish_initializing(builder, logger1)
return new_object
def finish_initializing(self, builder, logger1):
"""Called while initializing this instance in __new__
finish_initalizing should be called after parsing the ui definition
and creating a PreferencesTestdrivegtkDialog object with it in order to
finish initializing the start of the new PerferencesTestdrivegtkDialog
instance.
Put your initialization code in here and leave __init__ undefined.
"""
# Get a reference to the builder and set up the signals.
self.builder = builder
self.builder.connect_signals(self)
self.set_title(_("TestDrive Preferences"))
self.logger = logger1
##################################################################
###### Starting code of instancing TestDrive in Prefereces #######
##################################################################
# Instancing a testdrive object.
self.td = testdrive.Testdrive('testdrive-gtk')
# Initializing local variables, loading config files, setting defaults.
self.initialize_variables()
self.initialize_config_files()
self.td.set_defaults()
# Grab the selected repo and store it temporarly.
# Then, use the hardcoded repos to update the cache.
# Finally, default the initially selected repo.
selected_repo = self.td.p
for repo in ISO_REPOSITORY:
self.td.p = repo
self.update_iso_cache()
self.td.p = selected_repo
# Initialize widgets and its values
self.initialize_widgets()
self.initialize_widgets_values()
self.logger.debug(_('finish_initialization()'))
self.builder.get_object("txt_gral_cache")
def initialize_variables(self):
self.virt_method = None
self.mem = None
self.disk_size = None
self.flavors = ""
self.arch = []
self.repo = None
self.r = None
def initialize_widgets(self):
##################################################################
########### Initializing all the widgets in variables ############
##################################################################
# Initialize Data Paths
self.txt_gral_cache = self.builder.get_object("txt_gral_cache")
self.txt_img_cache = self.builder.get_object("txt_img_cache")
self.txt_iso_cache = self.builder.get_object("txt_iso_cache")
self.txt_iso_list_cache = self.builder.get_object("txt_iso_list_cache")
# Clean Ups
self.btn_iso_clean = self.builder.get_object("btn_iso_clean")
self.btn_iso_clean.connect("clicked", self.on_cache_cleanup_clicked, self.td.CACHE_ISO)
self.btn_img_clean = self.builder.get_object("btn_img_clean")
self.btn_img_clean.connect("clicked", self.on_cache_cleanup_clicked, self.td.CACHE_IMG)
self.btn_update_iso_list_cache = self.builder.get_object("btn_update_iso_list_cache")
self.btn_update_iso_list_cache.connect("clicked", self.on_force_iso_list_update)
# Ubuntu Releases
self.chk_arch_i386 = self.builder.get_object("chk_arch_i386")
self.chk_arch_i386.connect("clicked", self.on_select_arch, "i386")
self.chk_arch_amd64 = self.builder.get_object("chk_arch_amd64")
self.chk_arch_amd64.connect("clicked", self.on_select_arch, "amd64")
# Ubuntu Repositories Combo Box
self.tb_general_prefs = self.builder.get_object("tb_general_prefs")
self.cb_ubuntu_repo = gtk.combo_box_new_text()
self.cb_ubuntu_repo.set_size_request(260, -1)
self.cb_ubuntu_repo.append_text(_('Select Repository:'))
for repo in ISO_REPOSITORY:
self.cb_ubuntu_repo.append_text(repo)
self.cb_ubuntu_repo.connect('changed', self.on_select_iso_image_repo)
self.cb_ubuntu_repo.set_active(0)
self.cb_ubuntu_repo.show()
self.tb_general_prefs.attach(self.cb_ubuntu_repo, 1,2,7,8)
# Ubuntu Releases Combo Box
self.cb_ubuntu_release = gtk.combo_box_new_text()
self.cb_ubuntu_release.set_size_request(260, -1)
self.cb_ubuntu_release.connect('changed', self.on_select_ubuntu_release)
self.cb_ubuntu_release.append_text(_('Select Release:'))
self.cb_ubuntu_release.set_active(0)
self.cb_ubuntu_release.show()
self.tb_general_prefs.attach(self.cb_ubuntu_release, 1,2,8,9)
# Initialize Virtualization Method Options
self.opt_virt_kvm = self.builder.get_object("opt_virt_kvm")
self.opt_virt_kvm.connect("toggled", self.on_select_virt_method, "kvm")
self.opt_virt_vbox = self.builder.get_object("opt_virt_vbox")
self.opt_virt_vbox.connect("toggled", self.on_select_virt_method, "virtualbox")
self.opt_virt_parallels = self.builder.get_object("opt_virt_parallels")
self.opt_virt_parallels.connect("toggled", self.on_select_virt_method, "parallels")
# Initialize Memory Options
self.cbe_mem_size = self.builder.get_object("cbe_mem_size")
self.cbe_mem_size.remove_text(0)
for mem in MEM_SIZE_TAB:
self.cbe_mem_size.append_text(mem)
self.cbe_mem_size.connect('changed', self.on_select_mem)
# Initialize Disk Size Options
self.cbe_disk_size = self.builder.get_object("cbe_disk_size")
self.cbe_disk_size.remove_text(0)
for disk in DISK_SIZE_TAB:
self.cbe_disk_size.append_text(disk)
self.cbe_disk_size.connect('changed', self.on_select_disk_size)
# KVM Args
self.txt_kvm_args = self.builder.get_object("txt_kvm_args")
self.lb_kvm_args = self.builder.get_object("lb_kvm_args")
# SMP
self.lb_smp_nbr = self.builder.get_object("lb_smp_nbr")
self.txt_smp_nbr = self.builder.get_object("txt_smp_nbr")
self.lb_smp_available = self.builder.get_object("lb_smp_available")
# Flavors
self.chk_flavor_ubuntu = self.builder.get_object("chk_flavor_ubuntu")
self.chk_flavor_ubuntu.connect("clicked", self.on_select_flavors)
self.chk_flavor_kubuntu = self.builder.get_object("chk_flavor_kubuntu")
self.chk_flavor_kubuntu.connect("clicked", self.on_select_flavors)
self.chk_flavor_xubuntu = self.builder.get_object("chk_flavor_xubuntu")
self.chk_flavor_xubuntu.connect("clicked", self.on_select_flavors)
self.chk_flavor_edubuntu = self.builder.get_object("chk_flavor_edubuntu")
self.chk_flavor_edubuntu.connect("clicked", self.on_select_flavors)
self.chk_flavor_mythbuntu = self.builder.get_object("chk_flavor_mythbuntu")
self.chk_flavor_mythbuntu.connect("clicked", self.on_select_flavors)
self.chk_flavor_ubuntustudio = self.builder.get_object("chk_flavor_ubuntustudio")
self.chk_flavor_ubuntustudio.connect("clicked", self.on_select_flavors)
self.chk_flavor_lubuntu = self.builder.get_object("chk_flavor_lubuntu")
self.chk_flavor_lubuntu.connect("clicked", self.on_select_flavors)
self.chk_flavor_ubuntukylin = self.builder.get_object("chk_flavor_ubuntukylin")
self.chk_flavor_ubuntukylin.connect("clicked", self.on_select_flavors)
self.chk_flavor_ubuntugnome = self.builder.get_object("chk_flavor_ubuntugnome")
self.chk_flavor_ubuntugnome.connect("clicked", self.on_select_flavors)
self.chk_flavor_ubuntumate = self.builder.get_object("chk_flavor_ubuntumate")
self.chk_flavor_ubuntumate.connect("clicked", self.on_select_flavors)
self.chk_flavor_ubuntudesktopnext = self.builder.get_object("chk_flavor_ubuntudesktopnext")
self.chk_flavor_ubuntudesktopnext.connect("clicked", self.on_select_flavors)
self.chk_flavor_other = self.builder.get_object("chk_flavor_other")
self.chk_flavor_other.connect("clicked", self.on_select_flavors)
def initialize_config_files(self):
##################################################################
########### Read the configuration file for settings #############
##################################################################
config_files = ["/etc/%s" % self.td.PKGRC, "%s/.%s" % (self.td.HOME, self.td.PKGRC), "%s/.config/%s/%s" % (self.td.HOME, self.td.PKG, self.td.PKGRC) ]
for file in config_files:
if os.path.exists(file):
try:
# Load config files for class
self.td.load_config_file(file)
# Load config files for local variables
#self.load_config_files(file)
self.logger.debug(_("Reading config file: [%s]") % file)
except:
self.logger.debug(_("Unable to load config file [%s]") % file)
# return False
#return True
def initialize_widgets_values(self):
##################################################################
###### Initialize the widget values - Displayes information ######
##################################################################
# CACHE Variables
self.txt_gral_cache.set_text(self.td.CACHE)
self.txt_img_cache.set_text(self.td.CACHE_IMG)
self.txt_iso_cache.set_text(self.td.CACHE_ISO)
# Determine the selected repository
if self.td.p == 'cdimage':
self.cb_ubuntu_repo.set_active(1)
elif self.td.p == 'releases':
self.cb_ubuntu_repo.set_active(2)
# VIRT Methods
if self.td.VIRT == 'kvm':
self.opt_virt_kvm.set_active(True)
elif self.td.VIRT == 'virtualbox':
self.opt_virt_vbox.set_active(True)
elif self.td.VIRT == 'parallels':
self.opt_virt_parallels.set_active(True)
# Memory
if self.td.MEM == '256':
self.cbe_mem_size.set_active(0)
elif self.td.MEM == '384':
self.cbe_mem_size.set_active(1)
elif self.td.MEM == '512':
self.cbe_mem_size.set_active(2)
elif self.td.MEM == '1024':
self.cbe_mem_size.set_active(3)
elif self.td.MEM == '2048':
self.cbe_mem_size.set_active(4)
else:
self.cbe_mem_size.append_text(self.td.MEM)
self.cbe_mem_size.set_active(6)
# Disk Size
if self.td.DISK_SIZE == '4G':
self.cbe_disk_size.set_active(0)
elif self.td.DISK_SIZE == '6G':
self.cbe_disk_size.set_active(1)
elif self.td.DISK_SIZE == '8G':
self.cbe_disk_size.set_active(2)
elif self.td.DISK_SIZE == '10G':
self.cbe_disk_size.set_active(3)
elif self.td.DISK_SIZE == '16G':
self.cbe_disk_size.set_active(4)
else:
self.cbe_disk_size.append_text(self.td.DISK_SIZE.replace("G", ""))
self.cbe_disk_size.set_active(6)
# KVM Args
self.txt_kvm_args.set_text(self.td.KVM_ARGS)
# SMP
if self.td.SMP:
self.txt_smp_nbr.set_text(self.td.SMP)
self.lb_smp_available.set_text(_(" of %s available.") % commands.getoutput("grep -c ^processor /proc/cpuinfo"))
# Flavors
i = 0
while(i != -1):
try:
flavor = self.td.f.split()[i].replace(',', '')
if flavor == 'ubuntu':
self.chk_flavor_ubuntu.set_active(True)
elif flavor == 'kubuntu':
self.chk_flavor_kubuntu.set_active(True)
elif flavor == 'xubuntu':
self.chk_flavor_xubuntu.set_active(True)
elif flavor == 'edubuntu':
self.chk_flavor_edubuntu.set_active(True)
elif flavor == 'mythbuntu':
self.chk_flavor_mythbuntu.set_active(True)
elif flavor == 'ubuntustudio':
self.chk_flavor_ubuntustudio.set_active(True)
elif flavor == 'lubuntu':
self.chk_flavor_lubuntu.set_active(True)
elif flavor == 'ubuntukylin':
self.chk_flavor_ubuntukylin.set_active(True)
elif flavor == 'ubuntugnome':
self.chk_flavor_ubuntugnome.set_active(True)
elif flavor == 'ubuntu-mate':
self.chk_flavor_ubuntumate.set_active(True)
elif flavor == 'ubuntu-desktop-next':
self.chk_flavor_ubuntudesktopnext.set_active(True)
elif flavor == 'other':
self.chk_flavor_other.set_active(True)
else:
break
except:
i = -1
break
i = i + 1
# Architectures
for arch in self.td.m:
if arch == 'i386':
self.chk_arch_i386.set_active(True)
if arch == 'amd64':
self.chk_arch_amd64.set_active(True)
def update_iso_cache(self, force_update = False):
##################################################################
###### Code to update the ISO list from the repository Cache #####
##################################################################
update_cache = None
cdimage = False
""" Verify if the ISO list is cached, if not, set variable to update/create it. """
if force_update is True:
update_cache = 1
pass
elif self.td.is_iso_list_cached() is False:
update_cache = 1
# If ISO list is cached, verify if it is expired. If it is, set variable to update it.
elif self.td.is_iso_list_cache_expired() is True:
update_cache = 1
""" If variable set to update, obtain the ISO list from the Ubuntu CD Image repository. """
if update_cache == 1:
self.logger.info(_("Obtaining Ubuntu ISO list from %s...") % self.td.u)
try:
cdimage = self.td.obtain_ubuntu_iso_list_from_repo()
except:
self.logger.error(_("Could not obtain the Ubuntu ISO list from %s...") % self.td.u)
""" If the ISO List was obtained, update the cache file"""
if cdimage:
self.logger.info(_("Updating the Ubuntu ISO list cache..."))
try:
self.td.update_ubuntu_iso_list_cache(cdimage)
except:
self.logger.error(_("Unable to update the Ubuntu ISO list cache..."))
def get_preferences(self):
"""Returns preferences for testdrivegtk."""
self.logger.debug(_("get_preferences()"))
return self.td
def _load_preferences(self):
# TODO: add preferences to the self._preferences dict default
# preferences that will be overwritten if some are saved
pass
def _save_preferences(self):
##################################################################
########### Saving the preferences to the config file ############
##################################################################
if self.preferences:
config = ConfigParser.RawConfigParser()
config.add_section(self.td.PKG_SECTION)
for prefs in self.preferences:
config.set(self.td.PKG_SECTION, prefs[0], prefs[1])
# Writing our configuration file
path = "%s/.%s" % (self.td.HOME, self.td.PKGRC)
with open(path, 'wb') as configfile:
config.write(configfile)
def ok(self, widget, data=None):
"""The user has elected to save the changes.
Called before the dialog returns gtk.RESONSE_OK from run().
"""
# Make any updates to self._preferences here. e.g.
self.update_preferences()
self._save_preferences()
def cancel(self, widget, data=None):
"""The user has elected cancel changes.
Called before the dialog returns gtk.RESPONSE_CANCEL for run()
"""
# Restore any changes to self._preferences here.
pass
def on_error_dlg(self, data=None):
errorbox = gtk.MessageDialog(self,
gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR,
gtk.BUTTONS_CLOSE, data)
response = errorbox.run()
errorbox.destroy()
def on_select_virt_method(self, widget, virt=None):
# On selecting the viratualization method
self.virt_method = virt
# If Virtualization method is KVM, display related options.
if virt == 'kvm':
self.txt_kvm_args.set_sensitive(True)
self.txt_smp_nbr.set_sensitive(True)
else:
self.txt_kvm_args.set_sensitive(False)
self.txt_smp_nbr.set_sensitive(False)
def on_select_mem(self, entry):
# On selecting RAM memory.
if entry.child.get_text() == MEM_SIZE_TAB[4]:
entry.child.set_editable(True)
self.mem = 'other'
elif entry.get_active() >= 0:
entry.child.set_editable(False)
self.mem = entry.child.get_text()
def on_select_disk_size(self, entry):
# On selecting disk size
if entry.child.get_text() == DISK_SIZE_TAB[3]:
entry.child.set_editable(True)
self.disk_size = 'other'
elif entry.get_active() >= 0:
entry.child.set_editable(False)
self.disk_size = entry.child.get_text()
def on_select_flavors(self, widget):
# On selecting Ubuntu Flavors
self.flavors = ""
if self.chk_flavor_ubuntu.get_active():
self.flavors = self.flavors + "ubuntu, "
if self.chk_flavor_kubuntu.get_active():
self.flavors = self.flavors + "kubuntu, "
if self.chk_flavor_xubuntu.get_active():
self.flavors = self.flavors + "xubuntu, "
if self.chk_flavor_edubuntu.get_active():
self.flavors = self.flavors + "edubuntu, "
if self.chk_flavor_mythbuntu.get_active():
self.flavors = self.flavors + "mythbuntu, "
if self.chk_flavor_ubuntustudio.get_active():
self.flavors = self.flavors + "ubuntustudio, "
if self.chk_flavor_lubuntu.get_active():
self.flavors = self.flavors + "lubuntu, "
if self.chk_flavor_ubuntukylin.get_active():
self.flavors = self.flavors + "ubuntukylin, "
if self.chk_flavor_ubuntugnome.get_active():
self.flavors = self.flavors + "ubuntugnome, "
if self.chk_flavor_ubuntumate.get_active():
self.flavors = self.flavors + "ubuntu-mate, "
if self.chk_flavor_ubuntudesktopnext.get_active():
self.flavors = self.flavors + "ubuntu-desktop-next, "
if self.chk_flavor_other.get_active():
self.flavors = self.flavors + "other, "
def on_select_arch(self, widget, arch):
# On selecting the architecture
if widget.get_active() == True:
self.arch.append(arch)
if widget.get_active() == False:
self.arch.remove(arch)
def on_txt_gral_cache_focus_out_event(self, widget, data=None):
# When the CACHE text is changed, update related cache paths.
txt_cache = self.txt_gral_cache.get_text()
self.txt_iso_cache.set_text("%s/iso" % txt_cache)
self.txt_img_cache.set_text("%s/img" % txt_cache)
def on_cache_cleanup_clicked(self, widget, cache_path):
# Method to cleanup cache
filelist = os.listdir(cache_path)
if not filelist:
return
try:
for file in filelist:
path = "%s/%s" % (cache_path, file)
os.unlink(path)
except:
self.on_error_dlg(_("Unable to clean up files from [%s]") % cache_path)
def on_select_iso_image_repo(self, widget):
##################################################################
#### Select image repo, populate Release combobox accordingly ####
##################################################################
model = widget.get_model()
index = widget.get_active()
if index:
old_repo = self.td.p
self.repo = model[index][0]
self.td.p = self.repo
self.txt_iso_list_cache.set_text("%s/%s.isos" % (self.td.CACHE, self.td.p))
# Update cache commented given the hack to sync every repo on initialization
#self.update_iso_cache()
# Populate the releases combobox
self.cb_ubuntu_release.get_model().clear()
self.cb_ubuntu_release.append_text(_('Select Release:'))
self.cb_ubuntu_release.set_active(0)
isos = self.td.get_ubuntu_iso_list()
codenames = []
for iso in isos:
codenames.append(iso.split()[1])
codenames = list(set(codenames))
codenames.sort()
codenames.reverse()
c = i = 0
for release in codenames:
self.cb_ubuntu_release.append_text(release)
c += 1
if release == self.td.r and self.td.p == old_repo:
i = c
if self.td.r is None:
self.cb_ubuntu_release.set_active(1)
if i != 0:
self.cb_ubuntu_release.set_active(i)
else:
self.repo = None
def on_select_ubuntu_release(self, widget):
model = widget.get_model()
index = widget.get_active()
if index > 0:
self.r = model[index][0]
else:
self.r = None
def on_force_iso_list_update(self, widget):
selected_repo = self.td.p
for repo in ISO_REPOSITORY:
self.td.p = repo
self.update_iso_cache(True)
self.td.p = selected_repo
def update_preferences(self):
##################################################################
###### Prepare the preferences to be saved in the config fiel ####
##################################################################
self.preferences = []
# CACHE Variables
if self.txt_gral_cache.get_text() != None:
self.td.CACHE = self.txt_gral_cache.get_text()
self.preferences.append(['cache', self.td.CACHE])
if self.txt_img_cache.get_text() != None:
self.td.CACHE_IMG = self.txt_img_cache.get_text()
self.preferences.append(['cache_img', self.td.CACHE_IMG])
if self.txt_iso_cache.get_text() != None:
self.td.CACHE_ISO = self.txt_iso_cache.get_text()
self.preferences.append(['cache_iso', self.td.CACHE_ISO])
# Repo selection
if self.repo != None:
self.preferences.append(['p', self.td.p])
if self.r != None:
self.td.r = self.r
self.preferences.append(['r', self.td.r])
# KVM Args
if self.txt_kvm_args.get_text() != None:
self.td.KVM_ARGS = self.txt_kvm_args.get_text()
self.preferences.append(['kvm_args', self.td.KVM_ARGS])
if self.txt_smp_nbr.get_text() != None:
self.td.SMP = self.txt_smp_nbr.get_text()
self.preferences.append(['smp', self.td.SMP])
#ARCHs
if 'amd64' in self.arch and 'i386' in self.arch:
self.td.m = self.arch
self.td.m.sort()
self.preferences.append(['m', ' '.join(self.td.m)])
elif 'amd64' in self.arch or 'i386' in self.arch:
self.td.m = self.arch
self.preferences.append(['m', self.td.m[0]])
# VIRT Methods
if self.virt_method != None:
self.td.VIRT = self.virt_method
self.preferences.append(['virt', self.td.VIRT])
# Memory - TODO: Add validation of text
if self.mem == 'other':
self.mem = self.cbe_mem_size.child.get_text()
if self.mem != None or self.mem not in MEM_SIZE_TAB:
self.td.MEM = self.mem
self.preferences.append(['mem', self.td.MEM])
# Disk Size - TODO: Add validation of text
if self.disk_size == 'other':
self.disk_size = self.cbe_disk_size.child.get_text()
if self.disk_size != None or self.disk_size not in DISK_SIZE_TAB:
self.td.DISK_SIZE = "%sG" % self.disk_size
self.preferences.append(['disk_size', self.td.DISK_SIZE])
# Flavors
self.td.f = self.flavors[:-2]
self.preferences.append(['f', self.td.f])
if __name__ == "__main__":
dialog = PreferencesTestdrivegtkDialog()
dialog.show()
gtk.main()
|