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


Python libs.Tools类代码示例

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


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

示例1: removeLibrary

    def removeLibrary(self, selected):
        """
        Run a CLI command with the ID of the library to uninstall,
        also remove the reference of the ID in the preferences file.

        Arguments:
            selected {int}
                position of the option selected in the quick panel.
        """
        list = self.getLibrary('quick_list.json')
        lib_id = list[selected][2]
        lib_name = list[selected][0]

        self.message_queue.startPrint()
        self.message_queue.put('[ Deviot {0} ]\\n', version)
        time.sleep(0.01)

        # uninstall Library with CLI
        command = ['lib', 'uninstall', lib_id]
        self.Commands.runCommand(command, extra_message=lib_name)

        # remove from preferences
        if (not self.Commands.error_running):
            installed = self.Preferences.get('user_libraries', '')
            if(installed):
                if(lib_id in installed):
                    self.Preferences.data.setdefault(
                        'user_libraries', []).remove(lib_id)
                    self.Preferences.saveData()

        # update menu
        Tools.updateMenuLibs()
开发者ID:BadgerAAV,项目名称:Deviot,代码行数:32,代码来源:Libraries.py

示例2: plugin_unloaded

def plugin_unloaded():
    try:
        from package_control import events

        if events.remove(package_name):
            Tools.removePreferences()
    except:
        pass
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:8,代码来源:DeviotStarter.py

示例3: run

    def run(self, board_id):
        native = Preferences().get('native', False)

        key = 'env_selected'
        if(native):
            key = 'native_env_selected'

        Preferences().set(key, board_id)
        Tools.userPreferencesStatus(self.window.active_view())
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:9,代码来源:DeviotStarter.py

示例4: on_activated

    def on_activated(self, view):
        """
        Set the current version of Deviot

        Arguments: view {ST object} -- Sublime Text Object
        """
        PlatformioCLI(view, command=False).checkInitFile()
        Tools.setStatus(view)
        Tools.userPreferencesStatus(view)
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:9,代码来源:DeviotStarter.py

示例5: endSetup

    def endSetup(self):
        # get pio version
        executable = os.path.join(self.env_bin_dir, 'pio')
        cmd = ['\"' + executable + '\"', '--version']
        out = childProcess(cmd)

        pio_version = match(r"\w+\W \w+ (.+)", out[1]).group(1)
        self.Preferences.set('pio_version', pio_version)

        # save env paths
        env_path = [self.env_bin_dir]
        self.saveEnvPaths(env_path)

        # copy menu
        sys_os = Tools.getOsName()
        preset_path = Paths.getPresetPath()
        plg_path = Paths.getPluginPath()
        dst = os.path.join(plg_path, 'Settings-Default', 'Main.sublime-menu')

        if(sys_os == 'windows'):
            src_path = os.path.join(preset_path, 'Main.sublime-menu.windows')
            copy(src_path, dst)
        elif(sys_os == 'osx'):
            src_path = os.path.join(preset_path, 'Main.sublime-menu.osx')
            copy(src_path, dst)
        else:
            src_path = os.path.join(preset_path, 'Main.sublime-menu.linux')
            copy(src_path, dst)

        # creating files (menu, completions, syntax)
        generateFiles()
开发者ID:ikthap,项目名称:Deviot,代码行数:31,代码来源:Install.py

示例6: generateFiles

def generateFiles(install=False):
    # Creates new menu
    api_boards = Paths.getTemplateMenuPath('platformio_boards.json',
                                           user_path=True)
    # create main files
    PlatformioCLI().saveAPIBoards(install=install)
    Menu().createMainMenu()

    Tools.createCompletions()
    Tools.createSyntaxFile()
    Menu().createLibraryImportMenu()
    Menu().createLibraryExamplesMenu()

    # Run serial port listener
    Serial = SerialListener(func=Menu().createSerialPortsMenu)
    Serial.start()
开发者ID:gro00,项目名称:Deviot,代码行数:16,代码来源:PlatformioCLI.py

示例7: uploadSketchProject

    def uploadSketchProject(self):
        '''
        Upload the sketch to the select board to the select COM port
        it returns an error if any com port is selected
        '''
        id_port = self.Preferences.get('id_port', '')
        current_ports = listSerialPorts()

        if(id_port not in current_ports and id_port != 'none'):
            id_port = False

        # check port selected
        if(not id_port):
            current_time = time.strftime('%H:%M:%S')
            self.message_queue.put('none_port_select_{0}', current_time)
            self.execute = False

        if(not self.execute):
            self.message_queue.stopPrint()
            return

        # Stop serial monitor
        Tools.closeSerialMonitors(self.Preferences)

        # Compiling code
        choosen_env = self.buildSketchProject()
        if(not choosen_env):
            return

        if(self.Commands.error_running):
            self.message_queue.stopPrint()
            return

        up_port = '--upload-port %s' % id_port
        if(id_port == 'none'):
            up_port = ''

        command = ['run', '-t upload %s -e %s' %
                   (up_port, choosen_env)]

        self.Commands.runCommand(command)
        if(not self.Commands.error_running):
            autorun = self.Preferences.get('autorun_monitor', False)
            if(autorun):
                Tools.toggleSerialMonitor()
                self.Preferences.set('autorun_monitor', False)
        self.message_queue.stopPrint()
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:47,代码来源:PlatformioCLI.py

示例8: plugin_loaded

def plugin_loaded():
    protected = Preferences().get('protected')
    if(not protected):
        thread = threading.Thread(target=PioInstall().checkPio)
        thread.start()
        ThreadProgress(thread, _('processing'), _('done'))
    else:
        # creating files
        Tools.createCompletions()
        Tools.createSyntaxFile()
        Menu().createMainMenu()
        Menu().createLibraryImportMenu()
        Menu().createLibraryExamplesMenu()

        # Run serial port listener
        Serial_Lib = Serial.SerialListener(func=Menu().createSerialPortsMenu)
        Serial_Lib.start()
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:17,代码来源:DeviotStarter.py

示例9: listRootPath

def listRootPath():
    root_list = []
    os_name = Tools.getOsName()
    if os_name == 'windows':
        root_list = listWinVolume()
    else:
        home_path = os.getenv('HOME')
        root_list = [home_path, ROOT_PATH]
    return root_list
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:9,代码来源:Paths.py

示例10: __init__

 def __init__(self):
     self.lang_params = {}
     self.ids_lang = []
     self.id_path_dict = {}
     self.trans_dict = {}
     self.listIds()
     self.Preferences = Preferences()
     self.id_lang = self.Preferences.get('id_lang', Tools.getSystemLang())
     self.changeLang(self.id_lang)
开发者ID:BadgerAAV,项目名称:Deviot,代码行数:9,代码来源:I18n.py

示例11: getAPIBoards

    def getAPIBoards(self):
        '''
        Get the list of boards from platformIO API using CLI.
        To know more info about platformIO visit:  http://www.platformio.org/

        Returns: {json object} -- list with all boards in a JSON format
        '''
        window = sublime.active_window()
        view = window.active_view()
        Tools.setStatus(view, _('updating_board_list'))

        boards = []
        Run = CommandsPy()

        command = ['boards', '--json-output']
        boards = Run.runCommand(command, setReturn=True)

        Tools.setStatus(view, _('Done'), erase_time=4000)

        return boards
开发者ID:BadgerAAV,项目名称:Deviot,代码行数:20,代码来源:PlatformioCLI.py

示例12: listSerialPorts

def listSerialPorts():
    """
    List all the serial ports availables in the diffents O.S
    """
    os_name = Tools.getOsName()
    if os_name == "windows":
        serial_ports = listWinSerialPorts()
    elif os_name == 'osx':
        serial_ports = listOsxSerialPorts()
    else:
        serial_ports = listLinuxSerialPorts()
    serial_ports.sort()
    return serial_ports
开发者ID:BadgerAAV,项目名称:Deviot,代码行数:13,代码来源:Serial.py

示例13: getEnvPaths

    def getEnvPaths(self):
        # default paths
        default_paths = Tools.getDefaultPaths()
        system_paths = os.environ.get("PATH", "").split(os.path.pathsep)

        env_paths = []
        env_paths.extend(default_paths)
        env_paths.extend(system_paths)

        env_paths = list(OrderedDict.fromkeys(env_paths))
        env_paths = os.path.pathsep.join(env_paths)

        return env_paths
开发者ID:ikthap,项目名称:Deviot,代码行数:13,代码来源:Install.py

示例14: getEnvBinDir

def getEnvBinDir():
    env_dir = getEnvDir()
    env_bin_dir = os.path.join(
        env_dir, 'Scripts' if 'windows' in Tools.getOsName() else 'bin')

    try:
        os.makedirs(env_bin_dir)
    except OSError as exc:
        if exc.errno != errno.EEXIST:
            raise exc
        pass

    return env_bin_dir
开发者ID:dattasaurabh82,项目名称:Deviot,代码行数:13,代码来源:Paths.py

示例15: on_close

    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,代码行数:39,代码来源:DeviotStarter.py


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