當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。