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


Python Paths.getTempPath方法代码示例

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


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

示例1: saveCodeInFile

# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getTempPath [as 别名]
    def saveCodeInFile(self, view):
        """
        If the sketch in the current view has been not saved, it generate
        a random name and stores in a temp folder.

        Arguments: view {ST Object} -- Object with multiples options of ST
        """
        ext = '.ino'

        tmp_path = Paths.getTempPath()
        file_name = str(time.time()).split('.')[0]
        file_path = os.path.join(tmp_path, file_name)
        file_path = os.path.join(file_path, 'src')
        os.makedirs(file_path)

        full_path = file_name + ext
        full_path = os.path.join(file_path, full_path)

        region = sublime.Region(0, view.size())
        text = view.substr(region)
        file = JSONFile(full_path)
        file.writeFile(text)

        view.set_scratch(True)
        window = view.window()
        window.run_command('close')
        view = window.open_file(full_path)

        return (True, view)
开发者ID:BadgerAAV,项目名称:Deviot,代码行数:31,代码来源:PlatformioCLI.py

示例2: on_close

# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getTempPath [as 别名]
    def on_close(self, view):
        """
        When a sketch is closed, temp files are deleted

        Arguments: view {ST object} -- Sublime Text Object
        """
        # Serial Monitor
        monitor_module = Serial
        if Messages.isMonitorView(view):
            name = view.name()
            serial_port = name.split('-')[1].strip()
            if serial_port in monitor_module.serials_in_use:
                cur_serial_monitor = monitor_module.serial_monitor_dict.get(
                    serial_port, None)
                if cur_serial_monitor:
                    cur_serial_monitor.stop()
                monitor_module.serials_in_use.remove(serial_port)

        # Remove cache
        keep_cache = Preferences().get('keep_cache', True)
        if(keep_cache):
            return

        file_path = Tools.getPathFromView(view)
        if(not file_path):
            return
        file_name = Tools.getFileNameFromPath(file_path, ext=False)
        tmp_path = Paths.getTempPath()
        tmp_all = os.path.join(tmp_path, '*')
        tmp_all = glob.glob(tmp_all)

        for content in tmp_all:
            if file_name in content:
                tmp_path = os.path.join(tmp_path, content)
                rmtree(tmp_path, ignore_errors=False)
                Preferences().set('builded_sketch', False)

        # Empty enviroment menu
        Menu().createEnvironmentMenu(empty=True)
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:41,代码来源:DeviotStarter.py

示例3: __init__

# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getTempPath [as 别名]
    def __init__(self, view=False, console=False, install=False, command=True):
        '''
        Initialize the command and preferences classes, to check
        if the current work file is an IoT type it received the view
        parameter (ST parameter). This parameter is necessary only in
        the options like build or upload.

        Keyword Arguments:
        view {st object} -- stores many info related with ST (default: False)
        '''
        self.Preferences = Preferences()
        self.Menu = Menu()

        # user console
        if(console):
            current_time = time.strftime('%H:%M:%S')
            self.message_queue = MessageQueue(console)
            self.message_queue.startPrint()

        # For installing purposes
        if(install):
            self.Commands = CommandsPy(console=console)
            return

        self.view = view
        self.execute = True
        self.is_native = False
        self.is_iot = False

        if(view):
            # avoid to do anything with a monitor view
            view_name = view.name()
            sketch_size = view.size()
            file_path = Tools.getPathFromView(view)

            if(not file_path and 'monitor' in view_name.lower()):
                try:
                    current_time = time.strftime('%H:%M:%S')
                    self.message_queue.put('invalid_file_{0}', current_time)
                except:
                    pass
                self.execute = False
                return

            # unsaved file
            if(command and not file_path and sketch_size > 0):
                saved_file = self.saveCodeInFile(view)
                view = saved_file[1]
                file_path = Tools.getPathFromView(view)

            if(command and not sketch_size):
                self.message_queue.put('not_empty_sketch_{0}', current_time)

            # current file / view
            current_path = Paths.getCurrentFilePath(view)
            if(not current_path):
                return
            self.is_iot = Tools.isIOTFile(view)
            current_dir = Paths.getCWD(current_path)
            parent_dir = Paths.getParentCWD(current_path)
            file_name = Tools.getFileNameFromPath(file_path)
            temp_name = Tools.getFileNameFromPath(current_path, ext=False)

            if(not self.is_iot):
                self.execute = False

            # check IoT type file
            if(console and not self.is_iot and not self.execute):
                current_time = time.strftime('%H:%M:%S')
                msg = 'not_iot_{0}{1}'
                if(not file_name):
                    msg = 'not_empty_sketch_{0}'
                self.message_queue.put(msg, current_time, file_name)
                self.execute = False
                return

            if(not command and not self.is_iot):
                return

            # Check native project
            for file in os.listdir(parent_dir):
                if(file.endswith('platformio.ini')):
                    self.dir = parent_dir
                    self.src = False
                    self.is_native = True
                    break

            # set native paths
            if(not self.is_native):
                build_dir = self.Preferences.get('build_dir', False)
                if(not build_dir):
                    build_dir = Paths.getTempPath(temp_name)
                self.src = current_dir
                self.dir = build_dir

            # unsaved changes
            if (command and view.is_dirty()):
                view.run_command('save')

            if(console):
#.........这里部分代码省略.........
开发者ID:BadgerAAV,项目名称:Deviot,代码行数:103,代码来源:PlatformioCLI.py

示例4: run

# 需要导入模块: from libs import Paths [as 别名]
# 或者: from libs.Paths import getTempPath [as 别名]
 def run(self, edit):
     temp = Paths.getTempPath()
     url = Paths.getOpenFolderPath(temp)
     sublime.run_command('open_url', {'url': url})
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:6,代码来源:DeviotStarter.py


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