コード例 #1
0
ファイル: gui.py プロジェクト: Futurile/snapfly
 def __init__(self,destroy,execute):
     """
     @param destroy: callback for destroy function (at this moment (@221) stops inotify)
     @param ExecuteAction: callback for launch_command function
     """
     self.window = None
     self.len = None
     self.menu = None
     self.nbook = None
     self.hide_me = False
     self.updating = False
     self.focus_check = False
     self.mode = None
     self.ExecuteAction = execute
     config = ConfigController()
     self.rounded = int(config.getValue('rounded'))
     self.menu_width = int(config.getValue('menu_width'))
     self.bg_color = config.getValue('bg_color')
     self.border_color = config.getValue('border_color')
     self.showFavorites = True if config.getValue('favorites') == 'true'  else False
     self.terminal = config.getValue('terminal')
     self.mouse_at_scroll = False
     self.tab_width = None
     self.destroy = destroy
     self.tray = None
     if config.getValue('category_click') == 'false':
         self.category_click = False
     else:
         self.category_click = True
     self.create_window()
     self.toggle_hide()
コード例 #2
0
ファイル: menu.py プロジェクト: Futurile/snapfly
    def __init__(self, notifier, INOTIFY_SUPPORT):
        self.menu = GtkMenu(self.destroy, self.ExecuteAction)
        self.notifier = notifier

        config = ConfigController()
        self.terminal = config.getValue("terminal")
        self.systray = config.getValue("systray")
        self.hideList = config.getValue("hide_list").split(",")
        self.showFavorites = config.getValue("favorites")

        self.makemenu = snapfly_core.MakeMenu(
            self.ExecuteAction, self.move_on_scroll_event, self.terminal, self.hideList, self.showFavorites
        )

        # self.menu.len = self.makemenu.make(self.menu.nbook)
        self.menu.set_menu(self.makemenu.get_menu())
        self.menu.create_menu(self.makemenu.get_favorites(), snapfly_core.cat_icon)

        self.INOTIFY_SUPPORT = INOTIFY_SUPPORT
        if self.systray == "true":
            self.tray = TrayIcon(self.menu.toggle_hide, self.doQuit)
            self.menu.set_tray_icon(self.tray)
コード例 #3
0
class TopController(BaseController):
    # set base endpoint controllers
    account = AccountController()
    # this change was for the URL structure. file is still admin.py
    manager = AdminController()
    api = APIController()
    app = ViewController()
    alerts = AlertsController()
    alertswizard = AlertsWizardController()
    alertswizardv2 = AlertsWizardV2Controller()
    config = ConfigController()
    appnav = AppNavController()
    dashboardshare = DashboardShareController()
    dashboardwizard = DashboardWizardController()
    debug = DebugController()
    embed = EmbedController()
    field = FieldController()
    lists = ListsController()
    messages = MessagesController()
    module = ModuleController()
    parser = ParserController()
    paneleditor = PanelEditorController()
    prototype = PrototypeController()
    search = SearchController()
    tags = TagsController()
    splunkd = ProxyController()
    util = UtilityController()
    savesearchwizard = SaveSearchWizardController()
    savedsearchredirect = SavedSearchRedirectController()
    scheduledigestwizard = ScheduleDigestWizardController()
    shelper = SearchHelperController()
    ifx = IFXController()
    etb = ETBController()
    viewmaster = ViewmasterController()
    report = ReportController()
    wall = WallController()
    tree = TreeController()
    custom = CustomController()
    scheduledview = ScheduledViewController()
    i18ncatalog = I18NCatalogController()

    @expose
    def admin(self):
        '''
        redirect to manager in case old admin url is hit.
        '''
        self.redirect_to_url('/manager')

    @expose_page()
    def index(self):
        '''
        Serves the root of the webserver
        '''
        # If the license is expired, redirect to the licensing endpoint.
        # Since we have no way of determining if the user has permissions to change
        # licenses, there is still the chance that a basic user could hit the root
        # endpoint and get redirected to licensing by hitting "/" with an expired license.
        if cherrypy.config['license_state'] == 'EXPIRED':
            return self.redirect_to_url(
                '/licensing', _qs={'return_to': cherrypy.request.relative_uri})

        return self.redirect_to_url(
            '/app/%s' % splunk.auth.getUserPrefs('default_namespace'))

    @expose
    def login(self):
        """Legacy 3.x login url"""
        return self.redirect_to_url('/account/login')

    @expose
    def info(self):
        """
        Provides table of contents for all locally hosted resources
        """

        # gather all of the XML schema files
        dir = util.make_splunkhome_path(
            ['share', 'splunk', 'search_mrsparkle', 'exposed', 'schema'])
        schemaFiles = [x[0:-4] for x in os.listdir(dir) if x.endswith('.rnc')]
        return self.render_template('top/info.html',
                                    {'schemaFiles': schemaFiles})

    @expose
    def licensing(self, return_to=None, **unused):
        return self.redirect_to_url('/manager/system/licensing/switch',
                                    _qs={'return_to': return_to})

    @expose
    def paths(self):
        """
        Generates an HTML page documenting accessible paths on this site
        and the methods responsible for generating them
        """
        mappings = util.urlmappings(self,
                                    cherrypy.request.script_name + '/',
                                    exclude=cherrypy.request.script_name +
                                    '/api')
        mappings.sort(lambda a, b: cmp(a['path'], b['path']))
        paths = [(i, data['path']) for (i, data) in enumerate(mappings)]
        return self.render_template('top/paths.html', {
            'pathnames': paths,
            'mappings': mappings
        })

    @expose_page(must_login=True)
    def modules(self, **kwargs):
        """
        Generates an HTML page documenting all registered modules
        """
        definitions = moduleMapper.getInstalledModules()
        names = definitions.keys()
        names.sort()

        # pull out additional meta info
        groupedNames = []
        for module in definitions:
            definitions[module]['isAbstract'] = True if module.find(
                'Abstract') > -1 else False
            definitions[module]['isPrototype'] = True if definitions[module][
                'path'].find('/prototypes') > -1 else False

            # get general classification from folder path
            group = 'Base'
            try:
                folders = definitions[module]['path'].split(os.sep)
                pivot = folders.index('search_mrsparkle')
                if pivot > -1 and folders[
                        pivot + 1] == 'modules' and len(folders) > (pivot + 2):
                    group = folders[pivot + 2]
            except Exception, e:
                logger.error(e)
            groupedNames.append((group, module))
        groupedNames.sort()

        show_wiki = True if 'show_wiki' in kwargs else False
        return self.render_template(
            'top/modules.html', {
                'modules': definitions,
                'names': names,
                'show_wiki': show_wiki,
                'groupedNames': groupedNames
            })