def setSource(self, url): action, context, ident = split_url(url) if action == 'edit': if context == 'variables': config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(ident) elif context == 'parents': dialog = FamilyParentAssigner(self, ident) dialog.connect(dialog, SIGNAL('okClicked()'), self.resetView) dialog.show() else: KMessageBox.error(self, 'unable to edit %s for family' % context) elif action == 'delete': if context == 'family': #KMessageBox.information(self, 'delete family %s is unimplemented' % ident) msg = "Really delete family %s" % ident answer = KMessageBox.questionYesNo(self, msg) if answer == KMessageBox.Yes: self.family.delete_family(ident) msg = "family %s deleted" % ident KMessageBox.information(self, msg) self.parent().parent().refreshListView() self.setText('') else: KMessageBox.error(self, 'unable to delete %s for family' % context) else: KMessageBox.error(self, 'action %s unimpletmented' % url)
def slotSuiteSelected(self): win = self._dialog suite = str(win.suite.currentText()) KMessageBox.information(self, 'change to suite %s' % suite) if suite != self.profile.current.suite: self.profile.set_suite(suite) self.mainView.resetView()
def selectionChanged(self): current = self.listView.currentItem() win = None if hasattr(current, 'suite'): print 'suite is', current.suite if not self._suites: KMessageBox.information(self, "No suites are present.") else: win = TraitMainWindow(self, current.suite) elif hasattr(current, 'profiles'): win = ProfileMainWindow(self) elif hasattr(current, 'families'): self.slotManageFamilies() elif hasattr(current, 'machines'): win = MachineMainWindow(self) elif hasattr(current, 'dtype'): print 'differ', current.dtype win = DifferWindow(self, current.dtype) elif hasattr(current, 'etype'): win = EnvironmentWindow(self, current.etype) elif hasattr(current, 'installer'): #win = InstallerMainWin(self) KMessageBox.information(self, 'Not Implemented') elif hasattr(current, 'clients'): win = ClientsMainWindow(self) elif hasattr(current, 'folder'): # nothing important selected, do nothing pass else: KMessageBox.error(self, 'something bad happened in the list selection') if win is not None: win.show() self._all_my_children.append(win)
def setSource(self, url): action, context, ident = split_url(url) if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() elif context == 'variables': self.doc.profile.edit_variables() self.resetView() elif context == 'families': win = FamilyAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() else: KMessageBox.error(self, 'bad edit action %s' % url) elif action == 'change': if context == 'suite': self.emit(PYSIGNAL('changeSuite'), (ident,)) print 'changeSuite emitted' else: KMessageBox.error(self, 'bad change action %s' % url) else: KMessageBox.information(self, 'called %s' % url)
def setSource(self, url): action, context, id = str(url).split('.') if action == 'show': if context == 'parent': win = TraitMainWindow(self.app, self.parent(), self.doc.suite) win.view.set_trait(id) elif context == 'template': fid = id.replace(',', '.') package, template = fid.split('...') win = ViewWindow(self.app, self.parent(), SimpleEdit, 'TemplateView') templatefile = self.doc.trait._templates.templatedata( package, template) win.view.setText(templatefile) win.resize(600, 800) elif context == 'script': scriptfile = self.doc.trait._scripts.scriptdata(id) win = ViewWindow(self.app, self.parent(), SimpleEdit, 'ScriptView') win.view.setText(scriptfile) win.resize(600, 800) elif action == 'edit': #KMessageBox.information(self, 'edit the family %s ' % id) config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(id) else: KMessageBox.information(self, 'called %s' % url)
def setSource(self, url): action, context, id = str(url).split('.') if action == 'show': if context == 'parent': win = TraitMainWindow(self.app, self.parent(), self.doc.suite) win.view.set_trait(id) elif context == 'template': fid = id.replace(',', '.') package, template = fid.split('...') win = ViewWindow(self.app, self.parent(), SimpleEdit, 'TemplateView') templatefile = self.doc.trait._templates.templatedata(package, template) win.view.setText(templatefile) win.resize(600, 800) elif context == 'script': scriptfile = self.doc.trait._scripts.scriptdata(id) win = ViewWindow(self.app, self.parent(), SimpleEdit, 'ScriptView') win.view.setText(scriptfile) win.resize(600, 800) elif action == 'edit': #KMessageBox.information(self, 'edit the family %s ' % id) config = self.family.getVariablesConfig(self.family.current) newconfig = config.edit() config.update(newconfig) self.set_family(id) else: KMessageBox.information(self, 'called %s' % url)
def slotSuiteSelected(self): win = self._dialog suite = str(win.suite.currentText()) KMessageBox.information(self, "change to suite %s" % suite) if suite != self.profile.current.suite: self.profile.set_suite(suite) self.mainView.resetView()
def update_gamedata(self): gamedata = self.get_gamedata_from_entries() self.handler.update_game_data(gamedata) KMessageBox.information(self, 'Data updated for %s' % gamedata['fullname']) # we emit a GameDataUpdated signal passing the name of the game # as a parameter so the infobrowser will update the display self.emit(PYSIGNAL('GameDataUpdated'), (gamedata['name'], ))
def dropEvent(self, event): qlist = self._handle_drop_event(event) if qlist is not None: if len(qlist) == 1: url = str(qlist[0]) try: self.app.urlhandler.handle(url) except self.app.urlhandler.UnknownProtocolError: KMessageBox.information(self, "Can't handle '%s' protocol")
def url_handled(self): urls = self.app.urlhandler.completed_urls() for url in urls: if url.host.endswith('youtube.com'): download = False main = dict() data = self.app.urlhandler.retrieve_data(url) if data.has_key('entityid') and data['entityid'] is None: entity = self.app.db.Entity() entity.name = data['title'] entity.type = 'youtube-video' entity.desc = 'Youtube video' # I don't seem to be able to add the relations to the object # without flushing the session to get the new entityid self.app.db.session.flush() entityid = entity.entityid EntityExtraField = self.app.db.EntityExtraField entity.extfieldlist.append(EntityExtraField(entityid, 'youtubeid',data['youtubeid'])) # default to not there entity.extfieldlist.append(EntityExtraField(entityid, 'local-copy', False)) # normalize title similar to youtube-dl filename = self._make_youtube_dl_filename(data['youtubeid'], data['title']) # add filename to extras entity.extfieldlist.append(EntityExtraField(entityid, 'local-filename', filename)) # create entity self.app.db.session.save(entity) # do we need to flush()? #self.app.db.session.flush() download = True else: entityid = data['entityid'] db = self.app.db eef = db.EntityExtraField query = db.session.query(eef) eef_filter = query.filter(eef.entityid == entityid) query = eef_filter.filter(eef.fieldname == 'local-copy') lc = bool(int(query.one().value)) print "in mainwin, lc is", lc, type(lc) if not lc: download = True query = eef_filter.filter(eef.fieldname == 'local-filename') filename = query.one().value if download: # download youtube video flv_url = data['flv_url'] print "download True", filename, flv_url self.app.filehandler.download(data['flv_url'], filename) msg = "handled url %s" % ',\n '.join(list(urls)) KMessageBox.information(self, msg)
def update_gamedata(self): gamedata = self.get_gamedata_from_entries() self.handler.update_game_data(gamedata) KMessageBox.information(self, 'Data updated for %s' % gamedata['fullname']) # this dialog is currently only called from the InfoBrowser parent = self.parent() if parent.name() == 'InfoBrowser': # this refreshes the document in the InfoBrowser parent.set_game_info(gamedata['name'])
def insertNewFamily(self): dialog = self._dialog data = dialog.getRecordData() family = data['family'] if family not in self.family.all_families(): self.family.create_family(family) else: KMessageBox.information(self, '%s already exists.' % family) self.refreshListView()
def slotSave(self): text = str(self.mainView.text()) oldtext = self.trait.get_template_contents(self.current_template) if oldtext != text: self.trait.update_template(self.current_template, contents=text) self._update_status('Saved') else: KMessageBox.information(self, 'Nothing has changed') self._update_status()
def slotNewObject(self): if self._managing is None: KMessageBox.information(self, 'Select something to manage first.') elif self._managing == 'machine': self.mainView.mainView.setSource('new.machine.foo') elif self._managing == 'diskconfig': self.mainView.mainView.setSource('new.diskconfig.foo') else: KMessageBox.information(self, '%s not supported yet' % self._managing)
def insertNewProfile(self): dialog = self._dialog data = dialog.getRecordData() if data['profile'] not in self.profile.get_profile_list(): #self.profile.insert(data=data) self.profile.copy_profile('skeleton', data['profile']) else: KMessageBox.information(self, 'profile %s already exists.' % data['profile']) #KMessageBox.information(self, 'Make new profile %s' % data['profile']) self.refreshListView()
def _perform_edit_action(self, context, ident): if context == 'Variables': self.doc.mtype.edit_variables() elif context == 'Scripts': self.doc.mtype.edit_script(ident) elif context == 'machine_type': KMessageBox.information(self, 'Editing of machine types is unimplemented') else: msg = 'edit context %s id %s is unsupported' % (context, ident) KMessageBox.error(self, msg)
def _perform_edit_action(self, context, ident): if context == "Variables": self.doc.mtype.edit_variables() elif context == "Scripts": self.doc.mtype.edit_script(ident) elif context == "machine_type": KMessageBox.information(self, "Editing of machine types is unimplemented") else: msg = "edit context %s id %s is unsupported" % (context, ident) KMessageBox.error(self, msg)
def slotSave(self): profile = self.current_profile msg = 'Save profile %s?' % profile ans = KMessageBox.questionYesNo(self, msg, 'Save Profile') if ans == KMessageBox.Yes: self.mainView.save_profile(profile) elif ans == KMessageBox.No: print KMessageBox.information(self, 'Declined to save profile %s' % profile) else: print ans
def insertNewProfile(self): dialog = self._dialog data = dialog.getRecordData() if data['profile'] not in self.profile.get_profile_list(): #self.profile.insert(data=data) self.profile.copy_profile('skeleton', data['profile']) else: KMessageBox.information( self, 'profile %s already exists.' % data['profile']) #KMessageBox.information(self, 'Make new profile %s' % data['profile']) self.refreshListView()
def slotSave(self): text = str(self.mainView.text()) oldtext = self.trait.get_description() if oldtext is None: oldtext = '' if oldtext != text: self.trait.set_description(text) self._update_status('Saved') else: KMessageBox.information(self, 'Nothing has changed') self._update_status()
def setSource(self, url): action, context, ident = split_url(url) print "in setSource, url is", url print "in setSource, context is", context if context in self._context_methods: self._context_methods[context](action, ident) elif context.startswith('attribute||'): attribute = pipesplit(context)[1] self._attribute_context(attribute, action, ident) else: KMessageBox.information(self, "unable to handle %s context" % context) return
def setSource(self, url): url = str(url) action, context, ident = pipesplit(url) #KMessageBox.information(self, '%s %s %s' % (action, context, ident)) if action == 'delete': self.kernels.delete_kernel(ident) self.refresh_view() elif action == 'new': dlg = self.makeGenericDialog(NewKernelDialog, (self.kernels,)) dlg.connect(dlg, SIGNAL('okClicked()'), self.new_kernel_selected) else: KMessageBox.information(self, 'unknown action %s' % action)
def setSource(self, url): action, context, id = str(url).split('.') if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.app, self.parent(), id) else: self._url_error(url) else: KMessageBox.information(self, 'called %s' % url)
def _import_export_directory_selected(self): win = self._import_export_dirsel_dialog if win is None: raise RuntimeError , "There is no import/export dialog" url = win.url() fullpath = str(url.path()) action = win.db_action if action == 'import': KMessageBox.information(self, "%s trait not implemented yet" % action) elif action == 'export': KMessageBox.information(self, "%s trait not implemented yet" % action) else: KMessageBox.error(self, "action %s is not supported" % action)
def slotNewObject(self): if self._managing is None: KMessageBox.information(self, 'Select something to manage first.') elif self._managing == 'machine': self.mainView.mainView.setSource('new.machine.foo') elif self._managing == 'diskconfig': self.mainView.mainView.setSource('new.diskconfig.foo') elif self._managing == 'kernel': # kernel url's use '||' since the package names # have "."'s in them self.mainView.setSource('new||kernel||foo') else: KMessageBox.information(self, '%s not supported yet' % self._managing)
def slotSave(self): try: text = str(self.mainView.text()) except UnicodeEncodeError: text = unicode(self.mainView.text()) #text = text.encode() text = text.encode('utf') oldtext = self.trait.get_template_contents(self.current_template) if oldtext != text: self.trait.update_template(self.current_template, contents=text) self._update_status('Saved') else: KMessageBox.information(self, 'Nothing has changed') self._update_status()
def slotSave(self): newdata = self.tveditor.get_data() oldata = dict(self.tveditor.traitenv.items()) removed = [k for k in oldata if k not in newdata] added = [k for k in newdata if k not in oldata] changed = [k for k in newdata if newdata[k] != oldata[k]] report = self._changed_report(removed, added, changed) from kdeui import KMessageBox KMessageBox.information(self, report) env = self.tveditor.traitenv for key in removed: del env[key] for key in added + changed: env[key] = newdata[key]
def insertNewRecord(self): dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == 'Disks': self.doc.mtype.add_disk(data['diskname'], data['device']) elif context == 'Families': self.doc.mtype.append_family(data['family']) elif context == 'Variables': self.doc.mtype.append_variable(data['trait'], data['name'], data['value']) else: KMessageBox.information(self, 'called something') self.resetView()
def slotOkClicked(self): mtype, profile, kernel, filesystem = self._get_common_data() if self.dbaction == 'insert': machine = str(self.machnameEntry.text()) self.handler.make_a_machine(machine, mtype, profile, kernel, filesystem) performed = 'inserted' elif self.dbaction == 'update': machine = self.machine self.handler.update_a_machine(machine, mtype, profile, kernel, filesystem) performed = 'updated' else: raise RuntimeError, 'bad dbaction %s' % self.dbaction KMessageBox.information(self, '%s %s' % (machine, performed))
def _import_export_directory_selected(self): win = self._import_export_dirsel_dialog if win is None: raise RuntimeError, "There is no import/export dialog" url = win.url() fullpath = str(url.path()) action = win.db_action if action == 'import': KMessageBox.information(self, "%s trait not implemented yet" % action) elif action == 'export': KMessageBox.information(self, "%s trait not implemented yet" % action) else: KMessageBox.error(self, "action %s is not supported" % action)
def create_trouble(self): dlg = self.dialogs['new-trouble'] title = str(dlg.titleEdit.text()) data = str(dlg.dataEdit.text()) if data and title: self.manager.create_ticket(title, data) self.refreshlistView() elif title: KMessageBox.error(self, "just a title won't do.") self.slotNew(title=title) elif data: KMessageBox.error(self, "You also need a title.") self.slotNew(data=data) else: KMessageBox.information(self, 'Nothing Done.')
def setSource(self, url): action, context, ident = split_url(url) if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() elif context == 'variables': self.doc.profile.edit_variables() self.resetView() elif context == 'families': win = FamilyAssigner(self.parent(), ident) self.connect(win, SIGNAL('okClicked()'), self.resetView) win.show() else: KMessageBox.error(self, 'bad edit action %s' % url) elif action == 'change': if context == 'suite': self.emit(PYSIGNAL('changeSuite'), (ident, )) print 'changeSuite emitted' else: KMessageBox.error(self, 'bad change action %s' % url) elif action == 'delete': if context == 'profile': msg = "Really delete profile %s" % ident answer = KMessageBox.questionYesNo(self, msg) if answer == KMessageBox.Yes: #msg = "we're supposed to delete this profile, but can't yet" self.doc.profile.delete_profile(ident) msg = "profile %s deleted" % ident KMessageBox.information(self, msg) mainwin = self.parent().parent() mainwin.refreshListView() mainwin.resetProfileObject() self.setText('') else: KMessageBox.error(self, "Don't know how to delete %s" % context) else: KMessageBox.information(self, 'called %s' % url)
def insertNewRecord(self): handler = self.doc.machine dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == 'family': family = data['family'].strip() handler.relation.family.append_family(family) elif context == 'variable': trait = data['trait'].strip() name = data['name'].strip() value = data['value'].strip() handler.relation.environment.append_variable(trait, name, value) else: msg = 'unhandled insertNewRecord, context is %s' % context KMessageBox.information(self, msg) self._destroy_dialog() self.resetView() print "in insertNewRecord, context is", context
def _perform_delete_action(self, context, ident): if context == "Families": self.doc.mtype.delete_family(ident) self.resetView() elif context == "Variables": self.doc.mtype.edit_variables() elif context == "Scripts": ans = KMessageBox.questionYesNo(self, "really delete this script?") if ans == KMessageBox.Yes: self.doc.mtype.delete_script(ident) elif context == "Modules": msg = "Deleting modules is not supported." KMessageBox.information(self, msg) elif context == "machine_type": msg = "Can't delete machine types yet." KMessageBox.information(self, msg) else: msg = "Problem with delete - context %s id %s" % (context, ident) KMessageBox.error(self, msg)
def setSource(self, url): action, context, ident = split_url(url) if action == "show": print "unimpletmented" elif action == "edit": if context == "traits": win = TraitAssigner(self.parent(), ident) self.connect(win, SIGNAL("okClicked()"), self.resetView) win.show() elif context == "variables": self.doc.profile.edit_variables() self.resetView() elif context == "families": win = FamilyAssigner(self.parent(), ident) self.connect(win, SIGNAL("okClicked()"), self.resetView) win.show() else: KMessageBox.error(self, "bad edit action %s" % url) elif action == "change": if context == "suite": self.emit(PYSIGNAL("changeSuite"), (ident,)) print "changeSuite emitted" else: KMessageBox.error(self, "bad change action %s" % url) elif action == "delete": if context == "profile": msg = "Really delete profile %s" % ident answer = KMessageBox.questionYesNo(self, msg) if answer == KMessageBox.Yes: # msg = "we're supposed to delete this profile, but can't yet" self.doc.profile.delete_profile(ident) msg = "profile %s deleted" % ident KMessageBox.information(self, msg) mainwin = self.parent().parent() mainwin.refreshListView() mainwin.resetProfileObject() self.setText("") else: KMessageBox.error(self, "Don't know how to delete %s" % context) else: KMessageBox.information(self, "called %s" % url)
def insertNewRecord(self): handler = self.doc.machine dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == "family": family = data["family"] handler.relation.family.append_family(family) elif context == "variable": trait = data["trait"] name = data["name"] value = data["value"] handler.relation.environment.append_variable(trait, name, value) else: msg = "unhandled insertNewRecord, context is %s" % context KMessageBox.information(self, msg) self._destroy_dialog() self.resetView() print "in insertNewRecord, context is", context
def setSource(self, url): action, context, id = split_url(url) if action == 'show': print 'unimpletmented' elif action == 'edit': if context == 'traits': win = TraitAssigner(self.app, self.parent(), id) self.connect(win, SIGNAL('okClicked()'), self.resetView) elif context == 'variables': self.doc.profile.edit_variables() self.resetView() elif context == 'families': win = FamilyAssigner(self.app, self.parent(), id) self.connect(win, SIGNAL('okClicked()'), self.resetView) else: self._url_error(url) else: KMessageBox.information(self, 'called %s' % url)
def _perform_delete_action(self, context, ident): if context == 'Families': self.doc.mtype.delete_family(ident) self.resetView() elif context == 'Variables': self.doc.mtype.edit_variables() elif context == 'Scripts': ans = KMessageBox.questionYesNo(self, "really delete this script?") if ans == KMessageBox.Yes: self.doc.mtype.delete_script(ident) elif context == 'Modules': msg = 'Deleting modules is not supported.' KMessageBox.information(self, msg) elif context == 'machine_type': msg = "Can't delete machine types yet." KMessageBox.information(self, msg) else: msg = 'Problem with delete - context %s id %s' % (context, ident) KMessageBox.error(self, msg)
def insertNewRecord(self): handler = self.doc.machine dialog = self._dialog context = dialog.context data = dialog.getRecordData() if context == 'family': family = data['family'] handler.relation.family.append_family(family) elif context == 'variable': trait = data['trait'] name = data['name'] value = data['value'] handler.relation.environment.append_variable(trait, name, value) else: msg = 'unhandled insertNewRecord, context is %s' % context KMessageBox.information(self, msg) self._destroy_dialog() self.resetView() print "in insertNewRecord, context is", context
def setSource(self, url): action, context, id_ = split_url(url) fields = [] if context == 'Disks': fields = ['diskname', 'device'] elif context == 'Families': fields = ['family'] elif context == 'Variables': fields = ['trait', 'name', 'value'] if action == 'new': if context == 'Scripts': dialog = NewMTScriptDialog(self) dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewScript) self._dialog = dialog elif fields: dialog = SimpleRecordDialog(self, fields) dialog.context = context dialog.connect(dialog, SIGNAL('okClicked()'), self.insertNewRecord) self._dialog = dialog else: self._info('problem with %s' % url) elif action == 'edit': if context == 'Variables': self.doc.mtype.edit_variables() elif context == 'Scripts': self.doc.mtype.edit_script(id_) else: self._info('need to edit %s, %s' % (context, id_)) elif action == 'delete': if context == 'Families': self.doc.mtype.delete_family(id_) elif context == 'Variables': self._info('use edit to delete variables') elif context == 'Scripts': self.doc.mtype.delete_script(id_) elif context == 'Modules': self._info('Deleting modules not supported') else: self._info('need to delete something in context %s, %s' % (context, id_)) else: KMessageBox.information(self, 'called %s' % url) self.resetView()
def insertNewProfile(self): win = self._dialog profile = win.getRecordData()['name'] profile_list = self.profile.get_profile_list() if profile not in profile_list: skeleton = self.cfg.get('management_gui', 'template_profile') if skeleton in profile_list: self.profile.copy_profile(skeleton, profile) self.refreshListView() else: dlg = BaseRecordDialog(win, ['suite']) dlg.frame.text_label.setText('Select a suite for this profile') dlg.connect(dlg, SIGNAL('okClicked()'), self.insertNewProfilewithSuite) dlg.show() dlg.profile = profile win.suite_dialog = dlg KMessageBox.information(self, 'need to select suite here') # need to determine if skeleton exists KMessageBox.information(self, 'make profile %s' % profile) else: KMessageBox.error(self, 'Profile %s already exists.' % profile)
def setSource(self, url): KMessageBox.information(self, 'called %s' % url)
def _unhandled_action(self, action, context): msg = 'unable to handle %s action for %s' % (action, context) KMessageBox.information(self, msg)
def slotExportFamily(self): KMessageBox.information(self, 'Export unimplemented')
def selectionChanged(self): KMessageBox.information('selectionChanged Needs to be Overridden')