当前位置: 首页>>代码示例>>Python>>正文


Python Util.mkdir_p方法代码示例

本文整理汇总了Python中util.Util.mkdir_p方法的典型用法代码示例。如果您正苦于以下问题:Python Util.mkdir_p方法的具体用法?Python Util.mkdir_p怎么用?Python Util.mkdir_p使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在util.Util的用法示例。


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

示例1: recalc

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import mkdir_p [as 别名]
    def recalc(self):
        """Recalculates the ensime environment variables and return True if
        if successfull else raises an exception.
        Calls dotensime.load for loading .ensime config which might
        raise error if config is not found or cannot be parsed.
        It also :
            Creates the cache-dir if it doesn't already exist.
            Create the logger.
            Resets the client.
        """
        # plugin-wide stuff (immutable)
        self.settings = sublime.load_settings("Ensime.sublime-settings")
        debug = self.settings.get("debug", False)

        # for better experience
        s = sublime.load_settings("Preferences.sublime-settings")
        self.previous_auto_complete = s.get("auto_complete", True)
        s.set("auto_complete", False)
        self.previous_show_definitions = s.get("show_definitons", True)
        s.set("show_definitions", False)
        sublime.save_settings("Preferences.sublime-settings")

        # initialize parameters ()
        self.config = dotensime.load(self.window)
        self.valid = self.config is not None
        self.project_root = self.config['root-dir']
        self.notes_storage = NotesStorage()
        self.cache_dir = self.config['cache-dir']
        self.editor = Editor(self.window, self.settings, self.notes_storage)
        self.client = None
        # ensure the cache_dir exists otherwise log initialisation will fail
        Util.mkdir_p(self.cache_dir)
        self.log_file = os.path.join(self.cache_dir, "ensime.log")
        if self.logger is None:
            self.logger = self.create_logger(debug, self.log_file)

        return True
开发者ID:ensime,项目名称:ensime-sublime,代码行数:39,代码来源:env.py

示例2: _start_process

# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import mkdir_p [as 别名]
    def _start_process(self, classpath):
        """Given a classpath prepared for running ENSIME, spawns a server process
        in a way that is otherwise agnostic to how the strategy installs ENSIME.

        Args:
            classpath (list of str): list of paths to jars or directories
            (Within this function the list is joined with a system dependent
            path separator to create a single string argument to suitable to 
            pass to ``java -cp`` as a classpath)

        Returns:
            EnsimeProcess: A process handle for the launched server.
        """
        cache_dir = self.config['cache-dir']
        java_flags = self.config['java-flags']

        Util.mkdir_p(cache_dir)
        log_path = os.path.join(cache_dir, "server.log")
        with open(log_path, "w") as f:
            now = datetime.datetime.now()
            tm = now.strftime("%Y-%m-%d %H:%M:%S.%f")
            f.write("{}: {}\n".format(tm, "Initializing ensime process"))
        log = open(log_path, "w")        
        null = open(os.devnull, "r")
        java = os.path.join(self.config['java-home'], 'bin', 'java' if os.name != 'nt' else 'java.exe')

        if not os.path.exists(java):
            raise InvalidJavaPathError(errno.ENOENT, 'No such file or directory', java)
        elif not os.access(java, os.X_OK):
            raise InvalidJavaPathError(errno.EACCES, 'Permission denied', java)

        args = (
            [java, "-cp", (':' if os.name != 'nt' else ';').join(classpath)] +
            [a for a in java_flags if a] +
            ["-Densime.config={}".format(os.path.join(self.config['root-dir'], '.ensime')),
             "org.ensime.server.Server"])
        process = None
        if os.name == "nt":
            startupinfo = subprocess.STARTUPINFO()
            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
            startupinfo.wShowWindow |= 1  # SW_SHOWNORMAL
            creationflags = 0x08000000  # CREATE_NO_WINDOW
            process = subprocess.Popen(
                args,
                stdin=null,
                stdout=log,
                stderr=subprocess.STDOUT,
                startupinfo=startupinfo,
                creationflags=creationflags)
        else:
            process = subprocess.Popen(
                args,
                stdin=null,
                stdout=log,
                stderr=subprocess.STDOUT)
        pid_path = os.path.join(cache_dir, "server.pid")
        Util.write_file(pid_path, str(process.pid))
        http_path = os.path.join(cache_dir, "http")
        port_path = os.path.join(cache_dir, "port")

        def on_stop():
            log.close()
            null.close()
            for path in [pid_path, http_path, port_path]:
                with catch(Exception):
                    os.remove(path)

        return EnsimeProcess(cache_dir, process, on_stop)
开发者ID:ensime,项目名称:ensime-sublime,代码行数:70,代码来源:launcher.py


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