Esempio n. 1
0
 def database_command(self, menuitem, name):
     if name == 'connect':
         if self.conn is None and not self.dialogs['dbname']:
             msg = 'connect to which database?'
             dbname = self.dblist.get_selected_data()[0].datname
             self.dialogs['dbname'] = dialogs.Entry(msg, name='dbname')
             entry = self.dialogs['dbname']
             entry.set_ok(self.ok_dialog)
             entry.set_cancel(self.destroy_dialog)
             entry.set(dbname)
         else:
             dialogs.Message('no multiple connections yet')
     elif name == 'disconnect':
         if self.conn is not None:
             self.main.close()
             self.conn.close()
             self.conn = None
             self.dbname = None
         else:
             dialogs.Message('no connection to leave')
     elif name in ['backup', 'restore']:
         filesel = FileSelection(title='%s database' % name)
         filesel.cancel_button.connect('clicked',
                                       lambda x: filesel.destroy())
         filesel.show()
         bkup_path = self.cfg['import_path']
         filesel.set_filename(self._filepath_(bkup_path))
         filesel.ok_button.connect('clicked', self.ok_file, filesel)
         filesel.set_data('action', name)
     else:
         dialogs.Message('%s unimplemented' % name)
Esempio n. 2
0
 def env_command(self, menuitem, command):
     if command == 'update':
         dialogs.Message('updating %s' % self.current_trait)
         self.update_environment()
     elif command == 'create':
         self.ask_new_entry()
     else:
         dialogs.Message('ack')
Esempio n. 3
0
 def _extract_packages(self):
     dialogs.Message('deprecated(for now)')
     if False:
         if self.extracted is None:
             packages = [p.package for p in self.traitpackage.packages()]
             path = self.trait_temp_path()
             self.set_extracted(True)
             packs = ',\n'.join(packages)
             message = 'extracted packages:\n %s into:\n%s' % (packs, path)
             dialogs.Message(message)
         else:
             dialogs.Message('already extracted')
Esempio n. 4
0
 def run_tbar(self, button=None, data=None):
     if data == 'profiles':
         self.workspace[data] = ProfileGenWin(self.conn, self.dbname)
     elif data == 'machines':
         self.workspace[data] = MainMachineWin(self.conn)
     elif data == 'traits':
         self.workspace[data] = TraitManagerWin(self.conn)
     elif data == 'families':
         self.workspace[data] = FamilyWin(self.conn)
     elif data == 'tdiff':
         self.workspace[data] = DifferWin(self.conn, 'template')
     elif data == 'sdiff':
         self.workspace[data] = DifferWin(self.conn, 'script')
     elif data == 'fdiff':
         self.workspace[data] = DifferWin(self.conn, 'family')
     elif data == 'default_environment':
         self.workspace[data] = DefEnvEditor(self.conn)
     elif data == 'clients':
         self.workspace[data] = ClientManager(self.conn)
     elif data == 'browser':
         self.workspace[data] = 'working'
         print data
         os.spawnlpe(os.P_NOWAIT,
                     '/home/umeboshi/bin/paella-kde-management',
                     '--display :0', os.environ)
         print data, 'running'
     else:
         dialogs.Message('bad command %s' % data)
Esempio n. 5
0
 def template_command(self, meuitem, command):
     if command in ['new']:
         path = self.trait_temp_path(filesel=True)
         select_a_file('new', path, self.fileselect_ok)
     elif command == 'diff':
         path = self.suite_template_path(filesel=True)
         select_a_file('load', path, self.fileselect_ok)
     elif command == 'save':
         self.save_template()
     elif command == 'load':
         path = self.suite_template_path(filesel=True)
         select_a_file('load', path, self.fileselect_ok)
     elif command == 'done':
         try:
             template = self.get_selected_data()[0].template
             self.remove_page(template)
         except IndexError:
             pass
     elif command == 'drop':
         print 'need to drop template'
         rows = self.get_selected_data()
         if len(rows):
             row = rows[0]
             self.traittemplate.drop_template(row.package, row.template)
             self.remove_page(row.template)
             self.reset_rows()
         else:
             dialogs.Message('a template must be selected')
     elif command == 'root':
         if self.dialogs['rootsel'] is None:
             path = self.tarball_path + '/'
             select_a_file('root', path, self.tarball_selected)
     elif command == 'edit':
         self.edit_template()
Esempio n. 6
0
 def export_trait(self, trait, path=None):
     if path is None:
         path = self.tarball_path
     tt = TraitTemplate(self.conn, self.suite)
     tt.set_trait(trait)
     backup_trait(self.conn, self.suite, trait, path)
     dialogs.Message('%s exported to %s' % (trait, path))
Esempio n. 7
0
 def remove_item(self, *args):
     d = self.dialogs['remove']
     name = d.get_selected_data()[0].name
     environ = TraitEnvironment(self.conn, self.suite, self.current_trait)
     del environ[name]
     dialogs.Message('%s deleted' % name)
     self.destroy_dialog(d)
Esempio n. 8
0
 def delete_row(self, button, data):
     rows = self.dcbox.get_selected_data()
     if len(rows) != 1:
         dialogs.Message('need to select something')
     else:
         r = rows[0]
         self.dc.delete(r.name, r.trait)
Esempio n. 9
0
 def template_command(self, menuitem, command):
     if self.browser.extracted is None and command in [
             'new', 'diff', 'load'
     ]:
         dialogs.Message('packages not yet extracted')
     else:
         self.browser.template_command(command)
Esempio n. 10
0
 def dbconnect(self, dbname):
     self.cfg.change('database')
     dsn = self.cfg.get_dsn()
     dsn['dbname'] = dbname
     self.conn = PaellaConnection(dsn)
     self.main = StatementCursor(self.conn, 'mainManager')
     self.dbname = dbname
     dialogs.Message('connected to database %s' % dbname)
Esempio n. 11
0
 def pkey_command(self, menuitem, command):
     if command == 'insert':
         if self.dialogs['insert'] is None:
             dialog = dialogs.Entry('insert a %s' % self.pkey,
                                    name='insert')
             dialog.set_ok(self.pkey_insert_ok)
             dialog.set_cancel(self.destroy_dialog)
             self.dialogs['insert'] = dialog
     elif command == 'update':
         dialogs.Message('need to set update to cascade in db')
     elif command == 'done':
         value = None
         try:
             value = self.listbox.get_selected_data()[0][0]
         except IndexError:
             dialogs.Message('need to select %s first' % self.pkey)
         if value is not None:
             dialogs.Message('ok, i am done.')
Esempio n. 12
0
 def sources_command(self, menuitem, action):
     pages = dict(self.pages)
     if action == 'update release':
         c = self.current
         remote = RemoteRepository(self.conn, c.name, c.type)
         remote.update_release()
         pages[self._page_tab_(c.name, c.type)].reset_rows()
     else:
         dialogs.Message('nothing done')
Esempio n. 13
0
 def _get_debconf(self, data=True):
     rows = self.get_selected_data()
     if not len(rows):
         raise dialogs.Message('need to select something')
     name = rows[0].name
     if data:
         return self._get_debconf_data(name)
     else:
         return name
Esempio n. 14
0
 def new_script(self, name):
     if self.script.get(name) is not None:
         dialogs.Message('script exists')
         raise Error, 'script exists'
     tmp = strfile()
     self.script.insert_script(name, tmp)
     self.append_script(name)
     tmp.close()
     self.edit_script(None, name, None)
Esempio n. 15
0
 def _toggle_type_(self, button):
     dialog = self.dialogs['add-repos']
     if dialog['type'] == 'deb':
         dialog['type'] = 'deb-src'
     elif dialog['type'] == 'deb-src':
         dialog['type'] = 'deb'
     else:
         badtype = dialog['type']
         dialog['type'] = 'deb'
         dialogs.Message('bad type %s' % badtype)
Esempio n. 16
0
 def add_repository(self, button):
     action = button.get_name()
     if action == 'add-repos':
         name = self.dialogs[action]['name']
         if not good_word.match(name):
             dialogs.Message('bad name')
         else:
             d = self.dialogs['add-repos']
             line = ' '.join([d['type'], d['local'], d['suite']] +
                             d['sections'].split())
             rline = ' '.join([d['type'], d['remote'], d['suite']] +
                              d['sections'].split())
             #dialogs.Message('Source: %s, %s' %(d['name'], line))
             try:
                 self.browser.repos.add_source(d['name'], line)
                 self.browser.repos.add_source(d['name'], rline)
             except ExistsError:
                 dialogs.Message('%s already exists' % line)
             self.browser.reset_rows()
Esempio n. 17
0
 def load_template(self, path):
     template, package = get_file_path(path, self.suite_template_path())
     if template[-9:] == '.template':
         template = template[:-9]
         if template not in self.templates:
             try:
                 orig = self.find_original(template)
                 self.insert_new_template(package, template, path)
             except NoExistError:
                 dialogs.Message('%s not in extracted packages' % template)
Esempio n. 18
0
 def create_family(self, button):
     name = button.get_name()
     if name == 'create':
         family = self.dialogs[name].get()
         try:
             self.browser.family.create_family(family)
         except ExistsError:
             dialogs.Message('family %s already exists' % family)
         self.destroy_dialog(self.dialogs['create'])
         self.browser.reset_rows()
Esempio n. 19
0
 def menu_command(self, menuitem, name):
     client = self.client_view.get_selected_data()[0][0]
     if name == 'export':
         self.export_client(client)
     elif name == 'import':
         self.import_client(client)
     elif name == 'remove':
         self.remove_client(client)
     else:
         dialogs.Message('%s %s' % (name, client))
Esempio n. 20
0
 def create_trait(self, button):
     name = button.get_name()
     debug(name)
     if name == 'create':
         trait = self.dialogs[name].get()
         try:
             self.browser.trait.create_trait(trait)
         except ExistsError:
             dialogs.Message('trait %s already exists' % trait)
         self.destroy_dialog(self.dialogs['create'])
         self.browser.reset_rows()
Esempio n. 21
0
 def insert_new_template(self, package, template, path):
     newfile = readfile(path)
     filename = self.template_filename(package, template)
     makepaths(dirname(filename))
     writefile(filename, newfile)
     try:
         self.traittemplate.insert_template(
             dict(package=package, template=template), file(path))
     except OperationalError:
         dialogs.Message('template already exists')
     self.set_template(package, template)
     self.reset_rows()
Esempio n. 22
0
    def release_command(self, menuitem, action):
        if action == 'add binary repos':
            type = 'deb'
        if action == 'update':
            dialogs.Message('need to update release')

        if action == 'drop':
            if self.current:
                self.repos.drop_source(self.current.name, self.current.type)
            self.reset_rows()
        else:
            print action
Esempio n. 23
0
 def pkey_insert_ok(self, *args):
     dialog = self.dialogs['insert']
     value = dialog.get()
     print value
     try:
         self.main.insert(data={self.pkey: value})
         inserted = True
     except OperationalError:
         dialogs.Message('bad query\n%s is not allowed' % value)
     if inserted:
         self.destroy_dialog(dialog)
         self.reset_rows()
Esempio n. 24
0
 def modify_trait(self, menuitem, action):
     try:
         trait = self.listbox.get_selected_data()[0].trait
     except IndexError:
         dialogs.Message('no trait selected')
         raise IndexError
     if action == 'getconfig':
         self.select_configdat(action='getconfig')
     elif action == 'getfromtar':
         self.select_configdat(action='getfromtar')
     elif action == 'update':
         print 'update'
     elif action == 'delete':
         print 'delete'
Esempio n. 25
0
    def modify_trait(self, menuitem, action):
        if action == 'hello':
            dialogs.Message('hello')
        elif action in ['import', 'update']:
            filesel = select_a_file(action, self.tarball_path + '/',
                                    self.select_trait_tarball)
        elif action in ['updatedir', 'exportdir', 'importdir']:
            filesel = select_a_file(action, self.tarball_path + '/',
                                    self.select_traitdir)
        elif action == 'export':
            try:
                trait = self.listbox.get_selected_data()[0].trait
                #self.pages[trait].extract_packages()
                self.select_export_path(trait)
            except IndexError:
                dialogs.Message('no trait selected')

        elif action == 'extract':
            try:
                trait = self.listbox.get_selected_data()[0].trait
                self.pages[trait].extract_packages()
            except IndexError:
                dialogs.Message('no trait selected')
Esempio n. 26
0
 def fileselect_ok(self, button, filesel):
     path = filesel.get_filename()
     action = filesel.get_data('action')
     filesel.destroy()
     if action == 'new':
         template, package = get_file_path(path, self.trait_temp_path())
         if template not in self.templates:
             self.insert_new_template(package, template, path)
         else:
             dialogs.Message('template already exists')
     elif action == 'diff':
         pass
     elif action == 'load':
         self.load_template(path)
Esempio n. 27
0
 def template_command(self, meuitem, command):
     if command in ['new']:
         path = self.trait_temp_path(filesel=True)
         select_a_file('new', path, self.fileselect_ok)
     elif command == 'diff':
         path = self.suite_template_path(filesel=True)
         select_a_file('load', path, self.fileselect_ok)
     elif command == 'save':
         self.save_template()
     elif command == 'load':
         path = self.suite_template_path(filesel=True)
         select_a_file('load', path, self.fileselect_ok)
     elif command == 'done':
         try:
             template = self.get_selected_data()[0].template
             self.remove_page(template)
         except IndexError:
             pass
     elif command in ['drop', 'real_templates', 'other_templates']:
         rows = self.get_selected_data()
         row = None
         print row, rows, len(rows)
         if len(rows):
             row = rows[0]
         else:
             dialogs.Message('a template must be selected')
             print row, rows
         if row:
             package, template = row.package, row.template
             print row, 'ifrow'
             if command == 'drop':
                 self.traittemplate.drop_template(package, template)
                 self.remove_page(template)
             elif command == 'real_templates':
                 self.traittemplate.prefix_template(package,
                                                    template,
                                                    type_='real')
                 print 'make it real_templates'
             elif command == 'other_templates':
                 self.traittemplate.prefix_template(package,
                                                    template,
                                                    type_='other')
                 print 'make it other_templates'
             self.reset_rows()
     elif command == 'root':
         if self.dialogs['rootsel'] is None:
             path = self.tarball_path + '/'
             select_a_file('root', path, self.tarball_selected)
     elif command == 'edit':
         self.edit_template()
Esempio n. 28
0
 def edit_command(self, menuitem, name):
     if self.conn is None:
         dialogs.Message('Not Connected')
     else:
         if name == 'profiles':
             self.workspace['profiles'] = ProfileGenWin(self.conn, self.dbname)
         elif name in ['suitemanager']:
             if not self.dialogs[name]:
                 msg = 'select a suite'
                 self.dialogs[name] = dialogs.CList(msg, name=name)
                 lbox = self.dialogs[name]
                 lbox.set_rows(self.main.select(table='suites'))
                 lbox.set_ok(self.suite_selected)
                 lbox.set_cancel(self.destroy_dialog)
         else: self.run_tbar(None, name)
Esempio n. 29
0
 def _connect(self, dbname):
     if self.connections.has_key(dbname):
         dialogs.Message('connection already exists for %s' % dbname)
     else:
         conn = BaseConnection(user=self._dbuser,
                               host=self._dbhost,
                               dbname=dbname,
                               passwd=self._dbpasswd)
         self.connections[dbname] = conn
         cursor = StatementCursor(self.connections[dbname])
         rows = cursor.tables()
         tables = ScrollCList(rcmenu=self.table_edit_menu)
         tables.set_rows(rows, columns=['table'])
         self.append_page(tables, dbname)
         self.set_current_page(dbname)
Esempio n. 30
0
 def toolbar_button_pressed(self, button, data):
     if data == 'machines':
         MachinesWin(self.conn)
     elif data == 'filesystems':
         FsWin(self.conn)
     elif data == 'machine types':
         #dialogs.Message('not ready yet')
         MachineTypesWin(self.conn)
     elif data == 'disks':
         DiskWin(self.conn)
     elif data == 'mounts':
         MountsWin(self.conn)
     elif data == 'kernels':
         KernelsWin(self.conn)
     else:
         dialogs.Message('unhandled command %s' % data)