• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.make_splunkhome_path函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中splunk.appserver.mrsparkle.lib.util.make_splunkhome_path函数的典型用法代码示例。如果您正苦于以下问题:Python make_splunkhome_path函数的具体用法?Python make_splunkhome_path怎么用?Python make_splunkhome_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了make_splunkhome_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_driver

    def get_driver(self):
        profile = self.get_firefox_profile()

        if profile is not None:
            driver = webdriver.Firefox(profile, log_path=make_splunkhome_path(['var', 'log', 'splunk', 'geckodriver.log']))
        else:
            driver = webdriver.Firefox(log_path=make_splunkhome_path(['var', 'log', 'splunk', 'geckodriver.log']))

        return driver
开发者ID:LukeMurphey,项目名称:splunk-web-input,代码行数:9,代码来源:web_driver_client.py


示例2: _readFilesFromFolder

 def _readFilesFromFolder(self,folderName, datatype):
     """"Read data structures from folder. 
     Type field is used for host vm perf view to read host and vm data
     
     """
     try:
         folderPath= make_splunkhome_path(['etc', 'apps', 'search_activity','local', 'data', folderName])
         structDict={}
         for file in os.listdir(folderPath):
             with contextlib.closing(bz2.BZ2File(folderPath+"/"+file, 'rb')) as f:
                 dataDict=json.load(f)
     
             for key,val in dataDict.iteritems():
                 structDict[key]=json.loads(val)
                 logger.debug('Key in %s', key)
                 if(key=='idFieldsHash'):
                     idFieldsHash=json.loads(val)
                     logger.debug('idFieldsHash %s', idFieldsHash)
                     structDict['hostHash']=idFieldsHash['hostHash']
                     structDict['moidHash']=idFieldsHash['moidHash'] 
         #logger.debug('Struct Dictionary %s', structDict['moidHash'])       
         if datatype=='host':
             self.hostDataDict=structDict
         elif datatype=='vm':
             self.vmDataDict= structDict
         else:
             self.datastructDict= structDict
         return True
     except Exception as e:
         logger.error('Could not read files from folder={0}, for datatype={1} due to {2}'.format(folderPath, datatype,e ))
         msg="[SOLNSelector_read_strcutures] Couldn't read files at " + folderPath
         raise SOLNSelectorError(status="404", message=msg)
开发者ID:dveuve,项目名称:search_activity,代码行数:32,代码来源:read_structures_service.py


示例3: get_temporary_lookup_file

def get_temporary_lookup_file(prefix=None, basedir=None):
    '''Create a temporary file and return the filehandle.
    Exceptions will be passed to caller.

    @param prefix: A prefix for the file (default is "lookup_gen_<date>_<time>_")
    @param basedir: The base directory for the file (default is $SPLUNK_HOME/var/run/splunk/lookup_tmp,
        the staging directory for use in creating new lookup table files).
    '''
    
    if prefix is None:
        prefix = 'lookup_gen_' + time.strftime('%Y%m%d_%H%M%S') + '_'
    
    if basedir is None:
        basedir = make_splunkhome_path(['var', 'run', 'splunk', 'lookup_tmp'])

    if not os.path.isdir(basedir):
        os.mkdir(basedir)

    if os.path.isdir(basedir):
        return tempfile.NamedTemporaryFile(prefix=prefix,
            suffix='.txt',
            dir=basedir,
            delete=False)
    else:
        return None
开发者ID:LukeMurphey,项目名称:lookup-editor,代码行数:25,代码来源:lookupfiles.py


示例4: create_lookup_table

def create_lookup_table(filename, lookup_file, namespace, owner, key):
    '''
    Create a new lookup file.

    @param filename: The full path to the replacement lookup table file.
    @param lookup_file: The lookup FILE name (NOT the stanza name)
    @param namespace: A Splunk namespace to limit the search to.
    @param owner: A Splunk user.
    @param key: A Splunk session key.
    
    @return: Boolean success status.
    
    WARNING: "owner" should be "nobody" to update
    a public lookup table file; otherwise the file will be replicated
    only for the admin user.
    '''
    
    # Create the temporary location path
    lookup_tmp = make_splunkhome_path(['var', 'run', 'splunk', 'lookup_tmp'])
    destination_lookup_full_path = os.path.join(lookup_tmp, lookup_file)

    # Copy the file to the temporary location
    shutil.move(filename, destination_lookup_full_path)

    # CReate the URL for the REST call
    url = '/servicesNS/%s/%s/data/lookup-table-files' % (owner, namespace)
    postargs = {
        'output_mode': 'json',
        'eai:data': str(destination_lookup_full_path),
        'name': lookup_file
    }

    # Perform the call
    rest.simpleRequest(
         url, postargs=postargs, sessionKey=key, raiseAllErrors=True)
开发者ID:LukeMurphey,项目名称:lookup-editor,代码行数:35,代码来源:lookupfiles.py


示例5: setup_logging

def setup_logging(log_name, level_name="INFO"):
    level_name = level_name.upper() if level_name else "INFO"
    loglevel_map = {
        "DEBUG": logging.DEBUG,
        "INFO": logging.INFO,
        "WARN": logging.WARN,
        "ERROR": logging.ERROR,
    }

    if level_name in loglevel_map:
        loglevel = loglevel_map[level_name]
    else:
        loglevel = logging.INFO

    logfile = make_splunkhome_path(["var", "log", "splunk",
                                    "%s.log" % log_name])
    logger = logging.getLogger(log_name)
    logger.propagate = False
    logger.setLevel(loglevel)

    handler_exists = any([True for h in logger.handlers
                          if h.baseFilename == logfile])
    if not handler_exists:
        file_handler = logging.handlers.RotatingFileHandler(logfile, mode="a",
                                                            maxBytes=104857600,
                                                            backupCount=5)
        fmt_str = "%(asctime)s %(levelname)s %(thread)d - %(message)s"
        formatter = logging.Formatter(fmt_str)
        file_handler.setFormatter(formatter)
        logger.addHandler(file_handler)
    return logger
开发者ID:chenziliang,项目名称:src,代码行数:31,代码来源:configure.py


示例6: info

 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})
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:9,代码来源:top.py


示例7: make_lookup_filename

def make_lookup_filename(lookup_file, namespace="lookup_editor", owner=None):
    """
    Create the file name of a lookup file. That is, device a path for where the file should
    exist.
    """

    # Strip out invalid characters like ".." so that this cannot be used to conduct an
    # directory traversal
    lookup_file = os.path.basename(lookup_file)
    namespace = os.path.basename(namespace)

    if owner is not None:
        owner = os.path.basename(owner)

    # Get the user lookup
    if owner is not None and owner != 'nobody' and owner.strip() != '':
        return make_splunkhome_path(["etc", "users", owner, namespace, "lookups", lookup_file])

    # Get the non-user lookup
    else:
        return make_splunkhome_path(["etc", "apps", namespace, "lookups", lookup_file])

    def is_lookup_in_users_path(lookup_file_path):
        """
        Determine if the lookup is within the user's path as opposed to being within the apps path.
        """

        if "etc/users/" in lookup_file_path:
            return True
        else:
            return False

    def is_file_name_valid(self, lookup_file):
        """
        Indicate if the lookup file is valid (doesn't contain invalid characters such as "..").
        """

        allowed_path = re.compile("^[-A-Z0-9_ ]+([.][-A-Z0-9_ ]+)*$", re.IGNORECASE)

        if not allowed_path.match(lookup_file):
            return False
        else:
            return True
开发者ID:mandalerajesh,项目名称:lookup-editor,代码行数:43,代码来源:shortcuts.py


示例8: makeLookupFilename

 def makeLookupFilename(self, lookup_file, namespace="lookup_editor", owner=None):
     """
     Create the file name of a lookup file. That is, device a path for where the file should exist.
     """
     
     # Strip out invalid characters like ".." so that this cannot be used to conduct an directory traversal
     lookup_file = os.path.basename(lookup_file)
     namespace = os.path.basename(namespace)
     
     if owner is not None:
         owner = os.path.basename(owner)
     
     # Get the user lookup
     if owner is not None and owner != 'nobody' and owner.strip() != '':
         return make_splunkhome_path(["etc", "users", owner, namespace, "lookups", lookup_file])
     
     
     # Get the non-user lookup
     else:
         return make_splunkhome_path(["etc", "apps", namespace, "lookups", lookup_file])
开发者ID:oerd,项目名称:lookup-editor,代码行数:20,代码来源:lookup_edit.py


示例9: resolve_lookup_filename

    def resolve_lookup_filename(self, lookup_file, namespace="lookup_editor", owner=None,
                                get_default_csv=True, version=None, throw_not_found=True):
        """
        Resolve the lookup filename. This function will handle things such as:
         * Returning the default lookup file if requested
         * Returning the path to a particular version of a file

        Note that the lookup file must have an existing lookup file entry for this to return
        correctly; this shouldn't be used for determining the path of a new file.
        """

        # Strip out invalid characters like ".." so that this cannot be used to conduct an
        # directory traversal
        lookup_file = os.path.basename(lookup_file)
        namespace = os.path.basename(namespace)

        if owner is not None:
            owner = os.path.basename(owner)

        # Determine the lookup path by asking Splunk
        try:
            resolved_lookup_path = lookupfiles.SplunkLookupTableFile.get(lookupfiles.SplunkLookupTableFile.build_id(lookup_file, namespace, owner)).path
        except ResourceNotFound:
            if throw_not_found:
                raise
            else:
                return None

        # Get the backup file for one without an owner
        if version is not None and owner is not None:
            lookup_path = make_splunkhome_path([self.getBackupDirectory(lookup_file, namespace, owner, resolved_lookup_path=resolved_lookup_path), version])
            lookup_path_default = make_splunkhome_path(["etc", "users", owner, namespace,
                                                        "lookups", lookup_file + ".default"])

        # Get the backup file for one with an owner
        elif version is not None:
            lookup_path = make_splunkhome_path([self.getBackupDirectory(lookup_file, namespace, owner, resolved_lookup_path=resolved_lookup_path), version])
            lookup_path_default = make_splunkhome_path(["etc", "apps", namespace, "lookups",
                                                        lookup_file + ".default"])

        # Get the user lookup
        elif owner is not None and owner != 'nobody':
            # e.g. $SPLUNK_HOME/etc/users/luke/SA-NetworkProtection/lookups/test.csv
            lookup_path = resolved_lookup_path
            lookup_path_default = make_splunkhome_path(["etc", "users", owner, namespace,
                                                        "lookups", lookup_file + ".default"])

        # Get the non-user lookup
        else:
            lookup_path = resolved_lookup_path
            lookup_path_default = make_splunkhome_path(["etc", "apps", namespace, "lookups",
                                                        lookup_file + ".default"])

        logger.info('Resolved lookup file, path=%s', lookup_path)

        # Get the file path
        if get_default_csv and not os.path.exists(lookup_path) and os.path.exists(lookup_path_default):
            return lookup_path_default
        else:
            return lookup_path
开发者ID:mandalerajesh,项目名称:lookup-editor,代码行数:60,代码来源:lookup_edit.py


示例10: setup_logger

def setup_logger():
    logger = logging.getLogger(HANDLER_NAME)
    logger.propagate = False  # Prevent the log messages from being duplicated in the python.log file
    logger.setLevel(logging.DEBUG)

    file_handler = logging.handlers.RotatingFileHandler(make_splunkhome_path(['var', 'log',
      'splunk', LOG_FILE_NAME]), maxBytes=5000000, backupCount=1)
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    file_handler.setFormatter(formatter)

    logger.addHandler(file_handler)

    return logger
开发者ID:parth88,项目名称:GitHub,代码行数:13,代码来源:rest_unix_configured_handler.py


示例11: backupLookupFile

    def backupLookupFile(self, lookup_file, namespace, owner=None, resolved_file_path=None):
        """
        Make a backup if the lookup file
        """

        try:

            # If we don't already know the path of the file, then load it
            if resolved_file_path is None:
                resolved_file_path = self.resolve_lookup_filename(lookup_file, namespace, owner,
                                                                  throw_not_found=False)

            # If the file doesn't appear to exist yet. Then skip the backup.
            if resolved_file_path is None:
                logger.info("The file dosen't exist yet; the backup will not be made")
                return None

            # Get the backup directory
            backup_directory = self.getBackupDirectory(lookup_file, namespace, owner,
                                                       resolved_lookup_path=resolved_file_path)

            # Get the modification time of the existing file so that we put the date as an epoch
            # in the name
            try:
                file_time = os.path.getmtime(resolved_file_path)
            except:
                logger.warning('Unable to get the file modification time for the existing lookup file="%s"', resolved_file_path)
                file_time = None

            # If we couldn't get the time, then just use the current time (the time we are making
            # a backup)
            if file_time is None:
                file_time = time.time()

            # Make the full paths for the backup to be stored
            dst = make_splunkhome_path([backup_directory, str(file_time)])

            # Make the backup
            shutil.copyfile(resolved_file_path, dst)

            # Copy the permissions and timestamps
            shutil.copystat(resolved_file_path, dst)

            logger.info('A backup of the lookup file was created, namespace=%s, lookup_file="%s", backup_file="%s"', namespace, lookup_file, dst)

            # Return the path of the backup in case the caller wants to do something with it
            return dst
        except:
            logger.exception("Error when attempting to make a backup; the backup will not be made")

            return None
开发者ID:mandalerajesh,项目名称:lookup-editor,代码行数:51,代码来源:lookup_edit.py


示例12: setup_logger

def setup_logger():
    logger = logging.getLogger('configure_oauth')
    logger.propagate = False
    logger.setLevel(logging.DEBUG)

    file_handler = logging.handlers.RotatingFileHandler(
                    make_splunkhome_path(['var', 'log', 'splunk', 
                                          'configure_oauth.log']),
                                        maxBytes=25000000, backupCount=5)

    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    file_handler.setFormatter(formatter)

    logger.addHandler(file_handler)
    return logger
开发者ID:splunkdevabhi,项目名称:splunk-add-on-google-drive,代码行数:15,代码来源:configure_oauth.py


示例13: setup_logger

def setup_logger(level):
    """
    Setup a logger for the REST handler.
    """

    logger = logging.getLogger('splunk.appserver.lookup_editor.controllers.LookupEditor')
    logger.propagate = False # Prevent the log messages from being duplicated in the python.log file
    logger.setLevel(level)

    file_handler = logging.handlers.RotatingFileHandler(make_splunkhome_path(['var', 'log', 'splunk', 'lookup_editor_controller.log']), maxBytes=25000000, backupCount=5)

    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    return logger
开发者ID:oerd,项目名称:lookup-editor,代码行数:15,代码来源:lookup_edit.py


示例14: setup_logger

def setup_logger():
    """
    Setup a logger.
    """
    
    logger = logging.getLogger('web_availability_modular_input')
    logger.propagate = False # Prevent the log messages from being duplicated in the python.log file
    logger.setLevel(logging.INFO)
    
    file_handler = handlers.RotatingFileHandler(make_splunkhome_path(['var', 'log', 'splunk', 'cache_size_modular_input.log']), maxBytes=25000000, backupCount=5)
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    file_handler.setFormatter(formatter)
    
    logger.addHandler(file_handler)
    
    return logger
开发者ID:LukeMurphey,项目名称:django-splunk,代码行数:16,代码来源:django_cache_size.py


示例15: addUploadAssets

def addUploadAssets(appName):
    appPath = _getAppPath(appName, True)
    if not appPath:
        raise admin.ArgValidationException(_("App '%s' does not exist") % appName)

    tempPath = make_splunkhome_path(['var', 'run', 'splunk', 'apptemp'])
    # if does not exist then it means no assets exist for moving
    if not os.path.exists(tempPath):
        return

    dstPath = os.path.join(appPath, 'appserver', 'static')
    bundle_paths.maybe_makedirs(dstPath)
    comm.mergeDirs(tempPath, dstPath)

    # clean up
    bundle_paths.safe_remove(tempPath)
开发者ID:MobileWebApps,项目名称:splunk-search-tools-app,代码行数:16,代码来源:appbuilder.py


示例16: backup_lookup_file

    def backup_lookup_file(self, session_key, lookup_file, namespace, resolved_file_path, owner=None, file_save_time=None):
        """
        Make a backup if the lookup file.
        """

        try:

            # Get the backup directory
            backup_directory = self.get_backup_directory(session_key, lookup_file, namespace, 
                                                         owner, resolved_file_path)

            # Get the modification time of the existing file so that we put the date as an epoch
            # in the name
            try:
                file_time = os.path.getmtime(resolved_file_path)
            except:
                self.logger.warning('Unable to get the file modification time for the existing lookup file="%s"', resolved_file_path)
                file_time = None

            # If we got the time for backup file, then use that time
            # This is important because the times ought to be consistent between search heads in a
            # cluster
            if file_save_time is not None:
                file_time = file_save_time
            
            # If we couldn't get the time, then just use the current time (the time we are making
            # a backup)
            if file_time is None:
                file_time = time.time()

            # Make the full paths for the backup to be stored
            dst = make_splunkhome_path([backup_directory, str(file_time)])

            # Make the backup
            shutil.copyfile(resolved_file_path, dst)

            # Copy the permissions and timestamps
            shutil.copystat(resolved_file_path, dst)

            self.logger.info('A backup of the lookup file was created, namespace=%s, lookup_file="%s", backup_file="%s"', namespace, lookup_file, dst)

            # Return the path of the backup in case the caller wants to do something with it
            return dst
        except:
            self.logger.exception("Error when attempting to make a backup; the backup will not be made")

            return None
开发者ID:LukeMurphey,项目名称:lookup-editor,代码行数:47,代码来源:lookup_backups.py


示例17: setup_logger

def setup_logger():
    """
    sets up logger for shutdown command
    """
    logger = logging.getLogger('ta-akamai')
    # Prevent the log messgaes from being duplicated in the python.log
    #    AuthorizationFailed
    logger.propagate = False
    logger.setLevel(logging.DEBUG)

    file_handler = logging.handlers.RotatingFileHandler(
                    make_splunkhome_path(['var', 'log', 'splunk', 'ta-akamai.log']),
                                        maxBytes=25000000, backupCount=5)
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    return logger
开发者ID:divious1,项目名称:TA-Akamai,代码行数:17,代码来源:ta-akamai.py


示例18: setup_logger

def setup_logger():
    """
    Setup a logger.
    """

    logger = logging.getLogger("python_modular_input")
    logger.propagate = False  # Prevent the log messages from being duplicated in the python.log file
    logger.setLevel(logging.DEBUG)

    file_handler = handlers.RotatingFileHandler(
        make_splunkhome_path(["var", "log", "splunk", "python_modular_input.log"]), maxBytes=25000000, backupCount=5
    )
    formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
    file_handler.setFormatter(formatter)

    logger.addHandler(file_handler)

    return logger
开发者ID:J-C-B,项目名称:splunk-web-input,代码行数:18,代码来源:modular_input.py


示例19: logger

 def logger(self):
     
     # Make a logger unless it already exists
     if self._logger is not None:
         return self._logger
     
     logger = logging.getLogger(self.logger_name)
     logger.propagate = False # Prevent the log messages from being duplicated in the python.log file
     logger.setLevel(logging.INFO)
     
     file_handler = handlers.RotatingFileHandler(make_splunkhome_path(['var', 'log', 'splunk', self.logger_name + '.log']), maxBytes=25000000, backupCount=5)
     formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
     file_handler.setFormatter(formatter)
     
     logger.addHandler(file_handler)
     
     self._logger = logger
     return self._logger
开发者ID:dakiri,项目名称:splunk-syndication-input,代码行数:18,代码来源:modular_input.py


示例20: setup_logger

def setup_logger(level):
    """
    Setup a logger for the REST handler.
    """

    logger = logging.getLogger("splunk.appserver.alert_manager.controllers.IncidentWorkflow")
    logger.propagate = False  # Prevent the log messages from being duplicated in the python.log file
    logger.setLevel(level)

    file_handler = logging.handlers.RotatingFileHandler(
        make_splunkhome_path(["var", "log", "splunk", "alert_manager_settings_controller.log"]),
        maxBytes=25000000,
        backupCount=5,
    )

    formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s")
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)
    return logger
开发者ID:lkm,项目名称:alert_manager,代码行数:19,代码来源:incident_workflow.py



注:本文中的splunk.appserver.mrsparkle.lib.util.make_splunkhome_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python entity.getEntities函数代码示例发布时间:2022-05-27
下一篇:
Python splunk.Intersplunk类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap