def __init__(self, conn, name='RepositoryBrowser'): self.menu = self.__make_mainmenu_() ListNoteBook.__init__(self, name=name) self._targets_ = [repos_target] self._dnd = self.drag_rows self.set_usize(300, 200) self.conn = conn self.current = None self.repos = RepositoryManager(self.conn) self.sources_menu = make_menu(['update release'], self.sources_command) self.reset_rows() self.dialogs = {}.fromkeys(['downloads'])
class ReposManagerServer(SimpleXMLRPCServer): def __init__(self, *args): SimpleXMLRPCServer.__init__(self, *args) self.conn = RepositoryConnection() self._repos = RepositoryManager(self.conn) def _dispatch(self, method, params): try: # We are forcing the 'export_' prefix on methods that are # callable through XML-RPC to prevent potential security # problems func = getattr(self, 'export_' + method) except AttributeError: raise Exception('method "%s" is not supported' % method) else: return func(*params) def export_add_source(self, name, source): self._repos.add_source(name, source) return '%s added' % name def export_update_source(self, name): self._repos.update_source(name) return '%s updated' % name def export_set(self, name): self._repos.set(name) return 'current source set to %s' % name def export_locate(self, section): return self._repos.locate(section) def export_check(self, section): return self._repos.check(section) def export_check_section(self, section, name): return self._repos.check_section(section, name) def export_current(self): return self._repos.current def export_remote(self): return self._repos.remote
class ReposManagerServer(SimpleXMLRPCServer): def __init__(self, *args): SimpleXMLRPCServer.__init__(self, *args) self.conn = RepositoryConnection() self._repos = RepositoryManager(self.conn) def _dispatch(self, method, params): try: # We are forcing the 'export_' prefix on methods that are # callable through XML-RPC to prevent potential security # problems func = getattr(self, "export_" + method) except AttributeError: raise Exception('method "%s" is not supported' % method) else: return func(*params) def export_add_source(self, name, source): self._repos.add_source(name, source) return "%s added" % name def export_update_source(self, name): self._repos.update_source(name) return "%s updated" % name def export_set(self, name): self._repos.set(name) return "current source set to %s" % name def export_locate(self, section): return self._repos.locate(section) def export_check(self, section): return self._repos.check(section) def export_check_section(self, section, name): return self._repos.check_section(section, name) def export_current(self): return self._repos.current def export_remote(self): return self._repos.remote
class RepositoryBrowser(ListNoteBook, HasDialogs): def __init__(self, conn, name='RepositoryBrowser'): self.menu = self.__make_mainmenu_() ListNoteBook.__init__(self, name=name) self._targets_ = [repos_target] self._dnd = self.drag_rows self.set_usize(300, 200) self.conn = conn self.current = None self.repos = RepositoryManager(self.conn) self.sources_menu = make_menu(['update release'], self.sources_command) self.reset_rows() self.dialogs = {}.fromkeys(['downloads']) def drag_rows(self, listbox, context, selection, targettype, time): row = listbox.get_selected_data()[0] selection.set(selection.target, 0, '^&^'.join([row.name, row.type])) def __make_mainmenu_(self): commands = ['update release'] return make_menu(commands, self.sources_command) def __set_pages(self): pages = dict(self.pages) nameclause = Eq('name', self.current.name) binclause = nameclause & Eq('type', 'deb') srcclause = nameclause & Eq('type', 'deb-src') def reset_rows(self): self.set_rows(self.repos.sources.select(fields=['name', 'type'])) self.set_row_select(self.repos_selected) def repos_selected(self, listbox, row, column, event): self.current = listbox.get_selected_data()[0] c = self.current remote = RemoteRepository(self.conn, c.name, c.type) pages = dict(self.pages) tab = self._page_tab_(c.name, c.type) if tab not in pages: self.append_page(SourceView(remote, self.dialogs, name=tab), tab) else: pages[tab].reset_rows() self.set_current_page(tab) def _page_tab_(self, name, type): return '%s %s' % (name, type) 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') 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
def __init__(self, *args): SimpleXMLRPCServer.__init__(self, *args) self.conn = RepositoryConnection() self._repos = RepositoryManager(self.conn)