Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
    def endSetup(self):
        try:
            from .PlatformioCLI import generateFiles
        except:
            from libs.PlatformioCLI import generateFiles

        # save env paths
        if(self.os != 'osx'):
            env_path = [self.env_bin_dir]
            self.saveEnvPaths(env_path)

        # get pio version
        if(self.os == 'osx'):
            executable = os.path.join(self.env_bin_dir, 'python')
            cmd = ['"%s"' % (executable), '-m', 'platformio', '--version']
        else:
            executable = os.path.join(self.env_bin_dir, 'pio')
            cmd = ['"%s"' % (executable), '--version']
        out = childProcess(cmd)

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

        # 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'):
            if(platform.release() == '7'):
                src_path = os.path.join(preset_path, 'Main.sublime-menu.w7')
            else:    
                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)
        sublime.set_timeout(generateFiles, 0)

        self.Preferences.set('protected', True)
        self.Preferences.set('enable_menu', True)
Ejemplo n.º 9
0
    def __init__(self):
        self.Preferences = Preferences()
        self.base_dir = Paths.getDeviotUserPath()
        self.env_dir = Paths.getEnvDir()
        self.env_bin_dir = Paths.getEnvBinDir()
        self.cache_dir = Paths.getCacheDir()
        self.env_file = Paths.getEnvFile()
        self.cached_file = False
        self.os = Tools.getOsName()

        # console
        window = sublime.active_window()
        console_name = 'Deviot|Pio_Install' + str(time.time())
        console = Messages.Console(window, name=console_name)

        # Queue for the user console
        self.message_queue = Messages.MessageQueue(console)
Ejemplo n.º 10
0
def getTempPath(file_name=False):
    tmp_path = '/tmp'
    os_name = Tools.getOsName()
    if os_name == 'windows':
        tmp_path = os.environ['tmp']

    tmp_path = os.path.join(tmp_path, 'Deviot')

    if(file_name):
        tmp_path = os.path.join(tmp_path, file_name)

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

    return tmp_path
Ejemplo n.º 11
0
def getTempPath(file_name=False):
    tmp_path = '/tmp'
    os_name = Tools.getOsName()
    if os_name == 'windows':
        tmp_path = os.environ['tmp']

    tmp_path = os.path.join(tmp_path, 'Deviot')

    if (file_name):
        tmp_path = os.path.join(tmp_path, file_name)

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

    return tmp_path
Ejemplo n.º 12
0
import time
import glob
import threading

try:
    from . import Tools
    from . import pyserial
    from . import Messages
    from .Preferences import Preferences
except:
    from libs import Tools
    from libs import pyserial
    from libs import Messages
    from libs.Preferences import Preferences

if Tools.getOsName() == 'windows':
    if Tools.getPythonVersion() < 3:
        import _winreg as winreg
    else:
        import winreg


@Tools.singleton
class SerialListener(object):
    """
    Constantly checks if a port has been connected or disconnected
    """

    def __init__(self, func=None):
        self.func = func
        self.serial_list = []
Ejemplo n.º 13
0
import time
import glob
import threading

try:
    from . import Tools
    from . import pyserial
    from . import Messages
    from .Preferences import Preferences
except:
    from libs import Tools
    from libs import pyserial
    from libs import Messages
    from libs.Preferences import Preferences

if Tools.getOsName() == 'windows':
    if Tools.getPythonVersion() < 3:
        import _winreg as winreg
    else:
        import winreg


@Tools.singleton
class SerialListener(object):
    """
    Constantly checks if a port has been connected or disconnected
    """
    def __init__(self, func=None):
        self.func = func
        self.serial_list = []
        self.is_alive = False