コード例 #1
0
ファイル: xmake.py プロジェクト: swordday/xmake-sublime
    def _on_select(self, idx):

        # selected
        if idx > -1:

            # get the selected platform
            plat = self.plats[idx]
            if plat:
                plugin.set_option("plat", plat)

                # update architecture
                arch = None
                host = {
                    "osx": "macosx",
                    "linux": "linux",
                    "windows": "windows"
                }[sublime.platform()]
                if plat == host:
                    arch = sublime.arch() if sublime.platform(
                    ) == "windows" else {
                        "x86": "i386",
                        "x64": "x86_64"
                    }[sublime.arch()]
                else:
                    arch = {
                        "windows": "x86",
                        "macosx": "x86_64",
                        "linux": "x86_64",
                        "mingw": "x86_64",
                        "iphoneos": "arm64",
                        "watchos": "armv7k",
                        "android": "armv7-a"
                    }[plat]
                if arch:
                    plugin.set_option("arch", arch)
コード例 #2
0
    def run(self):
        if int(self.getLatestVersion()) == int(sublime.version()):
            print ("currently on latest version")
        else:
            print ("new version available")
            if sublime.platform() == "windows":
                #download the latest installer
                s = sublime.load_settings("Preferences.sublime-settings") #get the install path from preferences
                install_path = s.get("install_path", "")

                f = urllib2.urlopen("http://www.sublimetext.com/2")
                format = formatter.NullFormatter()
                parser = LinksParser(format)
                html = f.read() 
                parser.feed(html) #get the list of latest installer urls
                parser.close()
                urls = parser.get_links()
                if sublime.arch() == "x32":
                    download_link = urls[1]

                elif sublime.arch() == "x64":
                    download_link = urls[3]

                download_link = quote(download_link, safe="%/:=&?~#+!$,;'@()*[]")
                sublime.status_message('SublimeUpdater is downloading update')
                thr = BackgroundDownloader(download_link, install_path, download_link) #start the download thread
                threads = []
                threads.append(thr)
                thr.start()

            elif sublime.platform() == "linux":
                print "linux detected"
        
            elif sublime.platform() == "osx":
                print "mac detected"
コード例 #3
0
 def env(self):
     if self.visual_studio_versions:
         vs_versions = self.visual_studio_versions
     else:
         vs_versions = [15, 14.1, 14, 13, 12, 11, 10, 9, 8]
     if self.target_architecture:
         arch = self.target_architecture
     else:
         arch = 'x86'
     if sublime.arch() == 'x32':
         host = 'x86'
     elif sublime.arch() == 'x64':
         host = 'amd64'
     else:
         sublime.error_message('Unknown Sublime architecture: %s' %
                               sublime.arch())
         return
     if arch != host:
         arch = host + '_' + arch
     for version in vs_versions:
         try:
             vcvars = query_vcvarsall(version, arch)
             if vcvars:
                 print('found vcvarsall for version', version)
                 return vcvars
         except Exception:
             print('could not find vsvcarsall for version', version)
             continue
     print('warning: did not find vcvarsall.bat')
     return {}
コード例 #4
0
ファイル: ConvertToUTF8.py プロジェクト: dingdada/tain335
    def run(self, edit, encoding, file_name):
        self.view.set_name("ConvertToUTF8 Instructions")
        self.view.set_scratch(True)
        self.view.settings().set("word_wrap", True)
        msg = "Oops! The file {0} is detected as {1} which is not supported by your Sublime Text.\n\nPlease check whether it is in the list of Python's Standard Encodings (http://docs.python.org/library/codecs.html#standard-encodings) or not.\n\nIf yes, ".format(
            file_name, encoding
        )
        branch = self.get_branch(sublime.platform(), sublime.arch())
        if branch:
            ver = "33" if ST3 else "26"
            msg = (
                msg
                + "please install Codecs{0} (https://github.com/seanliang/Codecs{0}/tree/{1}) and restart Sublime Text to make ConvertToUTF8 work properly. If it is still not working, ".format(
                    ver, branch
                )
            )

        import platform

        msg = (
            msg
            + "please kindly send the following information to sunlxy#yahoo.com:\n====== Debug Information ======\nVersion: {0}-{1}\nPlatform: {2}\nPath: {3}\nEncoding: {4}\n".format(
                sublime.version(), sublime.arch(), platform.platform(), sys.path, encoding
            )
        )
        self.view.insert(edit, 0, msg)
        self.view.set_read_only(True)
        self.view.window().focus_view(self.view)
コード例 #5
0
def get_cache():
    import platform
    import os
    if cindex.conf == None:
        try:
            cindex.conf = cindex.Config()
            cindex.arch = sublime.arch()
            cindex.register_enumerations()
            print(cindex.conf.library_file)
        except OSError as err:
            print(err)
            library = cindex.conf.library_file
            if os.system == 'Linux':
                common.error_message(
"""It looks like '%s' couldn't be loaded. On Linux use your package manager to install clang-3.7.1\n\n \
or alternatively download a pre-built binary from http://www.llvm.org and put it in your ~/bin/\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (library))
            else:
                common.error_message(
"""It looks like '%s' couldn't be loaded.\n\n \
Download a pre-built binary from http://www.llvm.org and install it in your system.\n\n \
Note that the architecture needs to match your SublimeText 2 architecture.\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (library))
            raise err

    if tulib.cachelib == None:
        libcache = ""
        packages = sublime.packages_path()
        package  = os.path.join(packages, "SublimeClang")
        arch     = sublime.arch()
        try:
            libname  = tulib.get_cache_library(arch)
            libcache = os.path.join(package, libname)

            tulib.init_cache_lib(libcache)
            print("Loaded: '%s'" % (libcache))
        except OSError as err:
            print(err)
            if os.system == 'Linux':
                common.error_message(
"""It looks like '%s' couldn't be loaded. On Linux you have to compile it yourself.\n\n \
Go to into your ~/.config/sublime-text-2/Packages/SublimeClang and run make.\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (libcache))
            else:
                common.error_message(
"""It looks like '%s' couldn't be loaded.\n\n \
Visit https://github.com/ensisoft/SublimeClang for more information.""" % (libcache))
            raise err

    if cache.tuCache == None:
        number_threads = 4
        cache.tuCache = TUCache(number_threads)

    return cache.tuCache
コード例 #6
0
ファイル: xmake.py プロジェクト: swordday/xmake-sublime
    def load_options(self):

        # get window
        window = sublime.active_window()

        # get project directory
        projectdir = self.get_projectdir(False)
        if projectdir == None:
            return

        # get cache config
        cache = None
        config = subprocess.Popen(
            self.get_xmake() +
            """ l -c 'import("core.project.config"); config.load(); print("$(plat) $(arch) $(mode)")'""",
            stdout=subprocess.PIPE,
            cwd=projectdir,
            shell=True).communicate()
        if config and len(config) != 0:
            cache = config[0].strip().decode('utf-8').split(' ')

        # get platform
        plat = cache[0] if cache != None and len(cache) > 0 else None
        if plat != None and len(plat) > 0:
            self.options["plat"] = plat
        else:
            self.options["plat"] = {
                "osx": "macosx",
                "linux": "linux",
                "windows": "windows"
            }[sublime.platform()]

        # get architecture
        arch = cache[1] if cache != None and len(cache) > 1 else None
        if arch != None and len(arch) > 0:
            self.options["arch"] = arch
        else:
            self.options["arch"] = sublime.arch() if sublime.platform(
            ) == "windows" else {
                "x86": "i386",
                "x64": "x86_64"
            }[sublime.arch()]

        # get architecture
        mode = cache[2] if cache != None and len(cache) > 2 else None
        if mode != None and len(mode) > 0:
            self.options["mode"] = mode
        else:
            self.options["mode"] = "release"
コード例 #7
0
    def is_compatible(self, metadata):
        """
        Detects if a package is compatible with the current Sublime Text install

        :param metadata:
            A dict from a metadata file

        :return:
            If the package is compatible
        """

        sublime_text = metadata.get("sublime_text")
        platforms = metadata.get("platforms", [])

        # This indicates the metadata is old, so we assume a match
        if not sublime_text and not platforms:
            return True

        if not is_compatible_version(sublime_text):
            return False

        if not isinstance(platforms, list):
            platforms = [platforms]

        platform_selectors = [sublime.platform() + "-" + sublime.arch(), sublime.platform(), "*"]

        for selector in platform_selectors:
            if selector in platforms:
                return True

        return False
コード例 #8
0
def plugin_loaded():
    global s, Pref, EncodingOnStatusBarListener

    s = sublime.load_settings('Preferences.sublime-settings')
    if not s.get('show_encoding', False):
        s.set('show_encoding', True)
        sublime.save_settings("Preferences.sublime-settings")

    s = sublime.load_settings('EncodingHelper.sublime-settings')
    Pref = Pref()
    Pref.load()
    s.clear_on_change('reload')
    s.add_on_change('reload', lambda: Pref.load())

    if sublime.platform() in ('linux', 'osx'):
        import sys
        path = os.path.normpath(
            os.path.dirname(sublime.packages_path()) +
            '/Packages/EncodingHelper/Codecs33-' + sublime.platform() + '-' +
            sublime.arch() + '/lib')
        if path not in sys.path:
            sys.path.append(path)

    EncodingOnStatusBarListener = EncodingOnStatusBarListener()
    EncodingOnStatusBarListener.init_()
コード例 #9
0
 def get_usages_data(self):
     return {
         "SchemaVersion":
         Constant.get_usages_schema_version(),
         "Version":
         Constant.get_version(),
         "DebugMode":
         str.lower(str(Settings().get("debug_mode"))),
         "AsPackage":
         str.lower(
             str(
                 os.path.exists(
                     os.path.join(sublime.installed_packages_path(),
                                  "Javatar.sublime-package")))),
         "StartupTime":
         "{0:.2f}s".format(Constant.startup_time),
         "ActionHistory":
         str.lower(str(Settings().get("enable_action_history"))),
         "SublimeVersion":
         str(sublime.version()),
         "Platform":
         sublime.platform(),
         "Architecture":
         sublime.arch()
     }
コード例 #10
0
def generate_dependency_paths(name):
    """
    Accepts a dependency name and generates a dict containing the three standard
    import paths that are valid for the current machine.

    :param name:
        A unicode string name of the dependency

    :return:
        A dict with the following keys:
         - 'ver'
         - 'plat'
         - 'arch'
    """

    dependency_dir = os.path.join(packages_path, name)

    ver = u'st%s' % st_version
    plat = sublime.platform()
    arch = sublime.arch()

    return {
        'all': os.path.join(dependency_dir, u'all'),
        'ver': os.path.join(dependency_dir, ver),
        'plat': os.path.join(dependency_dir, u'%s_%s' % (ver, plat)),
        'arch': os.path.join(dependency_dir, u'%s_%s_%s' % (ver, plat, arch))
    }
コード例 #11
0
ファイル: support.py プロジェクト: qscgu23/gruvbox
def get_support_info():
    pc_settings = sublime.load_settings('Package Control.sublime-settings')
    is_installed_by_pc = str(
        PACKAGE_NAME in set(pc_settings.get('installed_packages', [])))
    info = {}
    info['channel'] = sublime.channel()
    info['version'] = sublime.version()
    info['platform'] = sublime.platform()
    info['arch'] = sublime.arch()
    info['package_name'] = PACKAGE_NAME
    info['package_version'] = PACKAGE_VERSION
    info['pc_install'] = is_installed_by_pc
    try:
        import mdpopups
        info['mdpopups_version'] = format_version(mdpopups,
                                                  'version',
                                                  call=True)
    except Exception:
        info['mdpopups_version'] = 'Version could not be acquired!'
    try:
        import markdown
        info['markdown_version'] = format_version(markdown, 'version')
    except Exception:
        info['markdown_version'] = 'Version could not be acquired!'
    try:
        import jinja2
        info['jinja_version'] = format_version(jinja2, '__version__')
    except Exception:
        info['jinja_version'] = 'Version could not be acquired!'
    try:
        import pygments
        info['pygments_version'] = format_version(pygments, '__version__')
    except Exception:
        info['pygments_version'] = 'Version could not be acquired!'
    return '''%(package_name)s:\n\n* version: %(package_version)s\n* installed via Package Control: %(pc_install)s\n\nSublime Text:\n\n* channel: %(channel)s\n* version: %(version)s\n* platform: %(platform)s\n* architecture: %(arch)s\n\nDependency versions:\n\n* mdpopups: %(mdpopups_version)s\n* markdown: %(markdown_version)s\n* pygments: %(pygments_version)s\n* jinja2: %(jinja_version)s''' % info
コード例 #12
0
ファイル: support.py プロジェクト: Briles/gruvbox
def get_support_info():
    pc_settings = sublime.load_settings('Package Control.sublime-settings')
    is_installed_by_pc = str(PACKAGE_NAME in set(pc_settings.get('installed_packages', [])))
    info = {}
    info['channel'] = sublime.channel()
    info['version'] = sublime.version()
    info['platform'] = sublime.platform()
    info['arch'] = sublime.arch()
    info['package_name'] = PACKAGE_NAME
    info['package_version'] = PACKAGE_VERSION
    info['pc_install'] = is_installed_by_pc
    try:
        import mdpopups
        info['mdpopups_version'] = format_version(mdpopups, 'version', call=True)
    except Exception:
        info['mdpopups_version'] = 'Version could not be acquired!'
    try:
        import markdown
        info['markdown_version'] = format_version(markdown, 'version')
    except Exception:
        info['markdown_version'] = 'Version could not be acquired!'
    try:
        import jinja2
        info['jinja_version'] = format_version(jinja2, '__version__')
    except Exception:
        info['jinja_version'] = 'Version could not be acquired!'
    try:
        import pygments
        info['pygments_version'] = format_version(pygments, '__version__')
    except Exception:
        info['pygments_version'] = 'Version could not be acquired!'
    return '''%(package_name)s:\n\n* version: %(package_version)s\n* installed via Package Control: %(pc_install)s\n\nSublime Text:\n\n* channel: %(channel)s\n* version: %(version)s\n* platform: %(platform)s\n* architecture: %(arch)s\n\nDependency versions:\n\n* mdpopups: %(mdpopups_version)s\n* markdown: %(markdown_version)s\n* pygments: %(pygments_version)s\n* jinja2: %(jinja_version)s''' % info
コード例 #13
0
ファイル: packages.py プロジェクト: themilkman/OverrideAudit
    def __select_dependencies(self, dependency_info):
        """
        This is taken from Package Control (and slightly modified). It takes a
        dependency JSON object from dependencies.json and determines which
        entry  (if any) should be used based on sublime version, os and
        architecture. It will return an empty list if there is no match.
        """
        platform_selectors = [
            sublime.platform() + '-' + sublime.arch(),
            sublime.platform(), '*'
        ]

        for platform_selector in platform_selectors:
            if platform_selector not in dependency_info:
                continue

            platform_dependency = dependency_info[platform_selector]
            versions = platform_dependency.keys()

            # Sorting reverse will give us >, < then *
            for version_selector in sorted(versions, reverse=True):
                if not _is_compatible_version(version_selector):
                    continue
                return platform_dependency[version_selector]

        # If there were no matches in the info, but there also weren't any
        # errors, then it just means there are not dependencies for this machine
        return []
コード例 #14
0
    def is_compatible(self, metadata):
        """
        Detects if a package is compatible with the current Sublime Text install

        :param metadata:
            A dict from a metadata file

        :return:
            If the package is compatible
        """

        sublime_text = metadata.get('sublime_text')
        platforms = metadata.get('platforms', [])

        # This indicates the metadata is old, so we assume a match
        if not sublime_text and not platforms:
            return True

        if not is_compatible_version(sublime_text):
            return False

        if not isinstance(platforms, list):
            platforms = [platforms]

        platform_selectors = [
            sublime.platform() + '-' + sublime.arch(),
            sublime.platform(), '*'
        ]

        for selector in platform_selectors:
            if selector in platforms:
                return True

        return False
コード例 #15
0
def plugin_loaded():
    if DEBUG:
        UTC_TIME = datetime.utcnow()
        PYTHON = sys.version_info[:3]
        VERSION = sublime.version()
        PLATFORM = sublime.platform()
        ARCH = sublime.arch()
        PACKAGE = sublime.packages_path()
        INSTALL = sublime.installed_packages_path()

        message = ('Jekyll debugging mode enabled...\n'
                   '\tUTC Time: {time}\n'
                   '\tSystem Python: {python}\n'
                   '\tSystem Platform: {plat}\n'
                   '\tSystem Architecture: {arch}\n'
                   '\tSublime Version: {ver}\n'
                   '\tSublime Packages Path: {package}\n'
                   '\tSublime Installed Packages Path: {install}\n').format(
                       time=UTC_TIME,
                       python=PYTHON,
                       plat=PLATFORM,
                       arch=ARCH,
                       ver=VERSION,
                       package=PACKAGE,
                       install=INSTALL)

        sublime.status_message('Jekyll: Debugging enabled...')
        debug('Plugin successfully loaded.', prefix='\n\nJekyll', level='info')
        debug(message, prefix='Jekyll', level='info')
コード例 #16
0
def get_dict_arch_path():
    """Return Dict_arch.zip path."""
    arch = sublime.arch()
    if arch == "x32":
        return os.path.join(BASE_PATH, "Dict32.zip")
    elif arch == "x64":
        return os.path.join(BASE_PATH, "Dict64.zip")
コード例 #17
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
def setup():
    if int(sublime.version()) < 3000:
        # Sublime Text 2 & Python 2.6
        pass
    else:
        # Sublime Text 3 & Python 3.3
        globalhook.setup(sublime.arch() == 'x64')
コード例 #18
0
 def setUpClass(cls):
     basedir = os.path.dirname(__file__)
     mpath = os.path.normpath(os.path.join(
         basedir, "..", "st3_{}_{}".format(sublime.platform(), sublime.arch())))
     if mpath not in sys.path:
         cls.mpath = mpath
         sys.path.append(mpath)
コード例 #19
0
ファイル: jekyll.py プロジェクト: nighthawk/sublime-jekyll
def plugin_loaded():
    if DEBUG:
        UTC_TIME = datetime.utcnow()
        PYTHON = sys.version_info[:3]
        VERSION = sublime.version()
        PLATFORM = sublime.platform()
        ARCH = sublime.arch()
        PACKAGE = sublime.packages_path()
        INSTALL = sublime.installed_packages_path()

        message = (
            'Jekyll debugging mode enabled...\n'
            '\tUTC Time: {time}\n'
            '\tSystem Python: {python}\n'
            '\tSystem Platform: {plat}\n'
            '\tSystem Architecture: {arch}\n'
            '\tSublime Version: {ver}\n'
            '\tSublime Packages Path: {package}\n'
            '\tSublime Installed Packages Path: {install}\n'
        ).format(time=UTC_TIME, python=PYTHON, plat=PLATFORM, arch=ARCH,
                 ver=VERSION, package=PACKAGE, install=INSTALL)

        sublime.status_message('Jekyll: Debugging enabled...')
        debug('Plugin successfully loaded.', prefix='\n\nJekyll', level='info')
        debug(message, prefix='Jekyll', level='info')
コード例 #20
0
ファイル: sys_path.py プロジェクト: Nielingluo/Sublime-Text-2
def generate_dependency_paths(name):
    """
    Accepts a dependency name and generates a dict containing the three standard
    import paths that are valid for the current machine.

    :param name:
        A unicode string name of the dependency

    :return:
        A dict with the following keys:
         - 'ver'
         - 'plat'
         - 'arch'
    """

    packages_dir = os.path.join(st_dir, u'Packages')
    dependency_dir = os.path.join(packages_dir, name)

    ver = u'st%s' % st_version
    plat = sublime.platform()
    arch = sublime.arch()

    return {
        'all': os.path.join(dependency_dir, 'all'),
        'ver': os.path.join(dependency_dir, ver),
        'plat': os.path.join(dependency_dir, u'%s_%s' % (ver, plat)),
        'arch': os.path.join(dependency_dir, u'%s_%s_%s' % (ver, plat, arch))
    }
コード例 #21
0
def setup(hwnd):
    if int(sublime.version()) < 3000:
        pass
    else:

        # load dll
        globalhook.setup(hwnd, sublime.arch() == 'x64')
コード例 #22
0
def _PrintDebugInfo():
    """Prints debug info into the sublime console."""
    if not is_debug():
        return
    message = (
        'AutoPEP8:'
        '\n\tsublime: version=%(subl_version)s, platform=%(subl_platform)s,'
        ' arch=%(subl_arch)s,'
        ' packages_path=%(subl_packages)s\n,'
        ' installed_packages_path=%(subl_installed_packages)s'
        '\n\tplugin: version=%(plugin_version)s'
        '\n\tconfig: %(config)s'
    )
    config_keys = (
        'max-line-length', 'list-fixes', 'ignore', 'select', 'aggressive',
        'indent-size', 'format_on_save', 'syntax_list',
        'file_menu_search_depth', 'avoid_new_line_in_select_mode', 'debug',
    )
    config = {}
    for key in config_keys:
        config[key] = Settings(key, None)

    message_values = {
        'plugin_version': VERSION,
        'subl_version': sublime.version(),
        'subl_platform': sublime.platform(),
        'subl_arch': sublime.arch(),
        'subl_packages': sublime.packages_path(),
        'subl_installed_packages': sublime.installed_packages_path(),
        'config': config
    }
    get_logger().debug(message, message_values)
コード例 #23
0
ファイル: AAA.py プロジェクト: lgunsch/config
    def run(self, message):
        v = OutputPanel('dart.config.check')
        text = HEADING + '\n'
        text += ('=' * 80) + '\n'
        text += 'MESSAGE:\n'
        text += message + '\n'
        text += '\n'
        text += 'CONFIGURATION:\n'
        text += ('-' * 80) + '\n'
        text += "editor version: {} ({})".format(sublime.version(),
                                               sublime.channel())
        text += '\n'
        text += ('-' * 80) + '\n'
        text += "os: {} ({})".format(sublime.platform(),
                                   sublime.arch())
        text += '\n'
        text += ('-' * 80) + '\n'

        setts = sublime.load_settings('Dart - Plugin Settings.sublime-settings')
        text += "dart_sdk_path: {}".format(setts.get('dart_sdk_path'))
        text += '\n'

        text += '=' * 80

        v.write(text)
        v.show()
コード例 #24
0
    def collect(self):
        self.elements.clear()

        db0 = DataBlock('Version and architecture')
        db0.items.append(DataItem('name', 'Sublime Text'))
        db0.items.append(DataItem('version', sublime.version()))
        db0.items.append(DataItem('architecture', sublime.arch()))
        db0.items.append(DataItem('channel', sublime.channel()))
        db0.items.append(DataItem('platform', sublime.platform()))

        view = sublime.active_window().active_view()
        view_settings = view.settings()

        db1 = DataBlock('View settings')
        for setting_name in ('syntax', 'tab_size', 'translate_tabs_to_spaces'):
            db1.items.append(DataItem(setting_name, view_settings.get(setting_name)))

        db2 = DataBlock('View state')
        db2.items.append(DataItem('is view dirty', view.is_dirty()))
        db2.items.append(DataItem('is view readonly', view.is_read_only()))
        db1.items.append(DataItem('encoding', view.encoding()))
        db1.items.append(DataItem('em width', view.em_width()))
        db1.items.append(DataItem('selection count', len(view.sel())))
        db1.items.append(DataItem('has non empty selections', view.has_non_empty_selection_region()))

        self.elements.append(db0)

        # TODO: Split the rest up into methods.
        self.collect_package_data()

        self.elements.append(db1)
        self.elements.append(db2)

        self.collect_profiling_data()
コード例 #25
0
def setup():
    if int(sublime.version()) < 3000:
        # Sublime Text 2 & Python 2.6
        pass
    else:
        # Sublime Text 3 & Python 3.3
        globalhook.setup(sublime.arch() == 'x64')
コード例 #26
0
def setup():
    if int(sublime.version()) < 3000:
        # Sublime Text 2 & Python 2.6
        messagehook.setup(callback)
    else:
        # Sublime Text 3 & Python 3.3
        globalhook.setup(sublime.arch() == 'x64')
コード例 #27
0
 def get_predefined_param(self, match):
     '''{%%}'''
     key = match.group(1)
     if key == 'filename':
         return os.path.basename(self.view.file_name() or '')
     elif key == 'filepath':
         return self.view.file_name() or ''
     elif key == 'dirname':
         return os.path.dirname(self.view.file_name() or '')
     elif key == 'platform':
         return sublime.platform()
     elif key == 'arch':
         return sublime.arch()
     elif key == 'encoding':
         encoding = self.view.encoding()
         return encoding if 'Undefined' != encoding else self.settings.get('default_encoding')
     elif key == 'ip':
         return get_local_ip()
     elif key == 'user':
         user = os.getlogin() if 'windows' != sublime.platform() else ''
         if user:
             return user
             #windows?
         user = os.popen('whoami').read()
         p = re.compile('[\r\n]', re.M)
         return re.sub(p, '', user)
     elif key == 'ext':
         return get_ext(self.view.file_name())
     elif key == 'year':
         t = datetime.datetime.today()
         return t.strftime('%Y')
     elif key == 'datetime':
         t = datetime.datetime.today()
         return t.strftime(self.get_action_param('datetime_format', '%Y-%m-%d %H:%M:%S'))
     return match.group(1)
コード例 #28
0
    def run(self, message):
        v = OutputPanel('dart.config.check')
        text = HEADING + '\n'
        text += ('=' * 80) + '\n'
        text += 'MESSAGE:\n'
        text += message + '\n'
        text += '\n'
        text += 'CONFIGURATION:\n'
        text += ('-' * 80) + '\n'
        text += "editor version: {} ({})".format(sublime.version(),
                                                 sublime.channel())
        text += '\n'
        text += ('-' * 80) + '\n'
        text += "os: {} ({})".format(sublime.platform(), sublime.arch())
        text += '\n'
        text += ('-' * 80) + '\n'

        setts = sublime.load_settings(
            'Dart - Plugin Settings.sublime-settings')
        text += "dart_sdk_path: {}".format(setts.get('dart_sdk_path'))
        text += '\n'

        text += '=' * 80

        v.write(text)
        v.show()
コード例 #29
0
    def run(self):
        """Run command."""

        info = {}

        info["platform"] = sublime.platform()
        info["version"] = sublime.version()
        info["arch"] = sublime.arch()
        info["bh_version"] = __version__
        info["pc_install"] = is_installed_by_package_control()
        try:
            import mdpopups
            info["mdpopups_version"] = format_version(mdpopups,
                                                      'version',
                                                      call=True)
        except Exception:
            info["mdpopups_version"] = 'Version could not be acquired!'

        try:
            import markdown
            info["markdown_version"] = format_version(markdown, 'version')
        except Exception:
            info["markdown_version"] = 'Version could not be acquired!'

        try:
            import jinja2
            info["jinja_version"] = format_version(jinja2, '__version__')
        except Exception:
            info["jinja_version"] = 'Version could not be acquired!'

        try:
            import pygments
            info["pygments_version"] = format_version(pygments, '__version__')
        except Exception:
            info["pygments_version"] = 'Version could not be acquired!'

        msg = textwrap.dedent("""\
            - Sublime Text:   %(version)s
            - Platform:   %(platform)s
            - Arch:   %(arch)s
            - Theme:   %(bh_version)s
            - Install via PC:   %(pc_install)s
            - Dependencies:
                * mdpopups:   %(mdpopups_version)s
                * markdown:   %(markdown_version)s
                * pygments:   %(pygments_version)s
                * jinja2:   %(jinja_version)s
            """ % info)

        view = sublime.active_window().active_view()

        def copy_and_hide(msg):
            sublime.set_clipboard(msg)
            view.hide_popup()

        view.show_popup(msg.replace('\n', '<br>') + '<br><a href="' + msg +
                        '">Copy</a>',
                        on_navigate=copy_and_hide,
                        max_height=340)
コード例 #30
0
def GetSimulatorCmd(mainlua=None, debug=False):
    platform = sublime.platform()
    arch = sublime.arch()
    view = sublime.active_window().active_view()

    simulator_path = ""
    simulator_flags = []
    simulator_version = GetSetting("corona_sdk_version", None)

    if mainlua is not None:
        simulator_path = GetSimulatorPathFromBuildSettings(mainlua)
        if simulator_path is None:
            simulator_path = GetSetting("corona_sdk_simulator_path", None)

    if platform == "osx":
        if simulator_path is None:
            simulator_path = GetLatestDailyBuildSimulatorPath()
        if simulator_path is None:
            simulator_path = "/Applications/CoronaSDK/Corona Simulator.app"
        if simulator_path.endswith(".app"):
            simulator_path += "/Contents/MacOS/Corona Simulator"
        simulator_flags = ["-singleton", "1"]
        if not GetSetting("corona_sdk_simulator_show_console", False):
            simulator_flags += ["-no-console", "1"]
        if debug:
            simulator_flags.append("-debug")
            simulator_flags.append("1")
            simulator_flags.append("-project")
        if os.path.isfile(simulator_path) and os.access(
                simulator_path, os.X_OK):
            simulator_version = str(
                subprocess.check_output(
                    [
                        'defaults', 'read',
                        os.path.join(os.path.dirname(simulator_path),
                                     '../Info.plist'), 'CFBundleVersion'
                    ],
                    stderr=subprocess.STDOUT).decode('utf8').strip())
    elif platform == 'windows':
        if simulator_path is None:
            if arch == "x64":
                simulator_path = "C:\\Program Files (x86)\\Corona Labs\\Corona SDK\\Corona Simulator.exe"
            else:
                simulator_path = "C:\\Program Files\\Corona Labs\\Corona SDK\\Corona Simulator.exe"
        simulator_flags = ["/singleton"]
        if not GetSetting("corona_sdk_simulator_show_console", False):
            simulator_flags += ["/no-console"]
        if debug:
            simulator_flags.append("/debug")

    # Can we find an executable file at the path
    if not os.path.isfile(simulator_path) or not os.access(
            simulator_path, os.X_OK):
        sublime.error_message(
            "Cannot find executable Corona Simulator at path '{0}'\n\nYou can set the user preference 'corona_sdk_simulator_path' to the location of the Simulator."
            .format(simulator_path))
        return None, None, None

    return simulator_path, simulator_flags, simulator_version
コード例 #31
0
    def send_to_api(self):
        """
        Send archive file to API
        """
        self.set_message("Sending archive...")
        f = open(self.archive_filename, 'rb')

        files = {
            'package': f.read(),
            'version': sublime.version()[:1],
            'platform': sublime.platform(),
            'arch': sublime.arch(),
            'email': self.email,
            'api_key': self.api_key,
        }

        # Send data and delete temporary file
        try:
            r = requests.post(
                url=self.api_upload_url, files=files, timeout=50)
        except requests.exceptions.ConnectionError as err:
            self.set_timed_message(
                "Error while sending archive: server not available, try later",
                clear=True)
            self.running = False
            logger.error(
                'Server (%s) not available, try later.\n'
                '==========[EXCEPTION]==========\n'
                '%s\n'
                '===============================' % (
                    self.api_upload_url, err))
            return

        f.close()
        os.unlink(self.archive_filename)

        if r.status_code == 201:
            self.set_timed_message("Successfully sent archive", clear=True)
            logger.info('HTTP [%s] Successfully sent archive' % r.status_code)
        elif r.status_code == 403:
            self.set_timed_message(
                "Error while sending archive: wrong credentials", clear=True)
            logger.info('HTTP [%s] Bad credentials' % r.status_code)
        elif r.status_code == 413:
            self.set_timed_message(
                "Error while sending archive: filesize too large (>20MB)", clear=True)
            logger.error("HTTP [%s] %s" % (r.status_code, r.content))
        else:
            msg = "Unexpected error (HTTP STATUS: %s)" % r.status_code
            try:
                j = r.json()
                for error in j.get('errors'):
                    msg += " - %s" % error
            except:
                pass
            self.set_timed_message(msg, clear=True, time=10)
            logger.error('HTTP [%s] %s' % (r.status_code, r.content))

        self.post_send()
コード例 #32
0
ファイル: misc.py プロジェクト: saqua/sublime-fish
def commandOnAbsolutePath(command, settings):
    dirPath = settings.get('fish_directory')

    if not dirPath and sublime.platform() == 'windows':
        if sublime.arch() == 'x32':
            testPaths = ('C:/cygwin/bin', 'C:/msys32/usr/bin')
        elif sublime.arch() == 'x64':
            testPaths = ('C:/cygwin64/bin', 'C:/msys64/usr/bin')
        for p in testPaths:
            if os.path.exists(p):
                dirPath = p
                break

    if dirPath:
        return os.path.join(dirPath, command)
    else:
        return command
コード例 #33
0
ファイル: plugin.py プロジェクト: sublimelsp/LSP-lua
 def platform_arch(cls) -> str:
     return {
         "linux_x64": "linux-x64",
         "osx_arm64": "darwin-arm64",
         "osx_x64": "darwin-x64",
         "windows_x32": "win32-ia32",
         "windows_x64": "win32-x64",
     }[sublime.platform() + "_" + sublime.arch()]
コード例 #34
0
	def run(self, edit, encoding):
		self.view.set_name('ConvertToUTF8 Instructions')
		self.view.set_scratch(True)
		self.view.settings().set("word_wrap", True)
		msg = 'Due to the limitation of embedded Python with Sublime Text, ConvertToUTF8 might not work properly.\n\nYou have to install an extra plugin to solve this problem, please kindly send the debug information to sunlxy#yahoo.com to get it:\n====== Debug Information ======\nVersion: {0}\nPlatform: {1}\nArch: {2}\nPath: {3}\nEncoding: {4}\n'.format(
			sublime.version(), sublime.platform(), sublime.arch(), sys.path, encoding
		)
		self.view.insert(edit, 0, msg)
コード例 #35
0
 def run(self, edit, encoding):
     self.view.set_name('ConvertToUTF8 Instructions')
     self.view.set_scratch(True)
     self.view.settings().set("word_wrap", True)
     msg = 'Due to the limitation of embedded Python with Sublime Text, ConvertToUTF8 might not work properly.\n\nYou have to install an extra plugin to solve this problem, please kindly send the debug information to sunlxy#yahoo.com to get it:\n====== Debug Information ======\nVersion: {0}\nPlatform: {1}\nArch: {2}\nPath: {3}\nEncoding: {4}\n'.format(
         sublime.version(), sublime.platform(), sublime.arch(), sys.path, encoding
     )
     self.view.insert(edit, 0, msg)
コード例 #36
0
def _color_picker_file():
    executable_suffix = None
    platform = sublime.platform()
    if platform == "windows":
        executable_suffix = "win.exe"
    else:
        executable_suffix = "%s_%s" % (platform, sublime.arch())
    return "ColorPicker_" + executable_suffix
コード例 #37
0
    def run(self):
        """Run command."""

        info = {}

        info["platform"] = sublime.platform()
        info["version"] = sublime.version()
        info["arch"] = sublime.arch()
        info["plugin_version"] = __version__
        info["pc_install"] = is_installed_by_package_control()
        try:
            import mdpopups
            info["mdpopups_version"] = format_version(mdpopups,
                                                      'version',
                                                      call=True)
        except Exception:
            info["mdpopups_version"] = 'Version could not be acquired!'

        try:
            import backrefs
            info["backrefs_version"] = format_version(backrefs, 'version')
        except Exception:
            info["backrefs_version"] = 'Version could not be acquired!'

        try:
            import markdown
            info["markdown_version"] = format_version(markdown, 'version')
        except Exception:
            info["markdown_version"] = 'Version could not be acquired!'

        try:
            import jinja2
            info["jinja_version"] = format_version(jinja2, '__version__')
        except Exception:
            info["jinja_version"] = 'Version could not be acquired!'

        try:
            import pygments
            info["pygments_version"] = format_version(pygments, '__version__')
        except Exception:
            info["pygments_version"] = 'Version could not be acquired!'

        msg = textwrap.dedent("""\
            - ST ver.: %(version)s
            - Platform: %(platform)s
            - Arch: %(arch)s
            - Plugin ver.: %(plugin_version)s
            - Install via PC: %(pc_install)s
            - mdpopups ver.: %(mdpopups_version)s
            - backrefs ver.: %(backrefs_version)s
            - markdown ver.: %(markdown_version)s
            - pygments ver.: %(pygments_version)s
            - jinja2 ver.: %(jinja_version)s
            """ % info)

        sublime.message_dialog(msg +
                               '\nInfo has been copied to the clipboard.')
        sublime.set_clipboard(msg)
コード例 #38
0
ファイル: javatar_help.py プロジェクト: jontyq/Javatar
	def run(self, selector=None, action=""):
		if self.action != "":
			action = self.action
			self.action = ""
		if action == "additional_packages":
			view = self.window.new_file()
			view.set_name("Javatar - Additional Packages")
			view.set_scratch(True)
			view.run_command("javatar_util", {"type": "insert", "text": "==== This section is under development ====\n\nAdditional packages\n========\n   To reduce plugin size, Javatar provides additional packages for different version of Java you are working.\n\nHere are all available packages:\n\nJavaSE7: http://\nJavaSE8: http://\nJavaFX8: http://\n\n==== This section is under development ===="})
		if action == "actions_history":
			if not getSettings("enable_actions_history"):
				sublime.message_dialog("Actions History is disabled. Please enable them first.")
				return
			self.action = action
			if selector is not None:
				report = "## Javatar Report\n### System Informations\n* Javatar Version: `%javatar_version%`\n* Sublime Version: `%sublime_version%`\n* Package Path: `%packages_path%`\n* Javatar Channel: `%javatar_channel%`\n* Sublime Channel: `%sublime_channel%`\n* Platform: `%platform%`\n* As Packages: `%is_package%`\n* Package Control: `%package_control%`\n* Architecture: `%arch%`\n* Javatar's Parent Folder: `%parent_folder%`\n* Is Project: `%is_project%`\n* Is File: `%is_file%`\n* Is Java: `%is_java%`\n\n### Action List\n%actions%"
				report = report.replace("%javatar_version%", getVersion())
				report = report.replace("%javatar_channel%", str.lower(getSettings("package_channel")))
				report = report.replace("%is_package%", str(getPath("exist", getPath("join", sublime.installed_packages_path(), "Javatar.sublime-package"))))
				report = report.replace("%parent_folder%", getPath("javatar_parent"))

				report = report.replace("%sublime_version%", str(sublime.version()))
				report = report.replace("%sublime_channel%", sublime.channel())
				report = report.replace("%package_control%", str(getPath("exist", getPath("join", sublime.packages_path(), "Package Control")) or getPath("exist", getPath("join", sublime.installed_packages_path(), "Package Control.sublime-package"))))
				report = report.replace("%is_project%", str(isProject()))
				report = report.replace("%is_file%", str(isFile()))
				report = report.replace("%is_java%", str(isJava()))

				report = report.replace("%packages_path%", sublime.packages_path())
				report = report.replace("%platform%", sublime.platform())
				report = report.replace("%arch%", sublime.arch())

				selectors = selector.split("|")
				if len(selectors) > 1:
					include = selectors[0].split(",")
					exclude = selectors[1].split(",")
				else:
					include = selectors[0].split(",")
					exclude = []

				actionText = ""
				actions = getAction().getAction(include, exclude)
				c = 1
				for action in actions:
					if c > 1:
						actionText += "\n"
					actionText += str(c) + ". " + action
					c += 1
				report = report.replace("%actions%", actionText)

				view = self.window.new_file()
				view.set_name("Javatar Actions History Report")
				view.set_scratch(True)
				view.run_command("javatar_util", {"type": "add", "text": report, "dest": "Actions History"})
				view.run_command("javatar_util", {"type": "set_read_only"})
			else:
				self.window.show_input_panel("Selector: ", "", self.run, "", "")
コード例 #39
0
    def run(self):
        """Run command."""

        info = {}

        info["platform"] = sublime.platform()
        info["version"] = sublime.version()
        info["arch"] = sublime.arch()
        info["plugin_version"] = __version__
        info["pc_install"] = is_installed_by_package_control()
        try:
            import mdpopups
            info["mdpopups_version"] = format_version(mdpopups, 'version', call=True)
        except Exception:
            info["mdpopups_version"] = 'Version could not be acquired!'

        try:
            import backrefs
            info["backrefs_version"] = format_version(backrefs, 'version')
        except Exception:
            info["backrefs_version"] = 'Version could not be acquired!'

        try:
            import markdown
            info["markdown_version"] = format_version(markdown, 'version')
        except Exception:
            info["markdown_version"] = 'Version could not be acquired!'

        try:
            import jinja2
            info["jinja_version"] = format_version(jinja2, '__version__')
        except Exception:
            info["jinja_version"] = 'Version could not be acquired!'

        try:
            import pygments
            info["pygments_version"] = format_version(pygments, '__version__')
        except Exception:
            info["pygments_version"] = 'Version could not be acquired!'

        msg = textwrap.dedent(
            """\
            - ST ver.: %(version)s
            - Platform: %(platform)s
            - Arch: %(arch)s
            - Plugin ver.: %(plugin_version)s
            - Install via PC: %(pc_install)s
            - mdpopups ver.: %(mdpopups_version)s
            - backrefs ver.: %(backrefs_version)s
            - markdown ver.: %(markdown_version)s
            - pygments ver.: %(pygments_version)s
            - jinja2 ver.: %(jinja_version)s
            """ % info
        )

        sublime.message_dialog(msg + '\nInfo has been copied to the clipboard.')
        sublime.set_clipboard(msg)
コード例 #40
0
def collect_all_options(view, filename, language):
    assert view is not None
    assert filename is not None
    assert language is not None
    assert language.is_supported()
    assert cindex.conf is not None

    global SystemIncludes

    # use clang to figure out the magical -isystem paths
    # todo: ObjC and ObjCPP ??
    if SystemIncludes == None:
        packages = sublime.packages_path()
        package  = os.path.join(packages, "SublimeClang")
        source = ""
        compiler = ""
        cindex.conf.arch = sublime.arch()
        if language.kind == Language.C:
            source = "test.c"
            compiler = cindex.conf.locate_clang()
        elif language.kind == Language.CPP:
            source = "test.cpp"
            compiler = cindex.conf.locate_clang_cpp()
        else:
            raise Error("Unsupported language.")

        source = os.path.join(package, source)
        info = common.ClangInfo.collect(compiler, source)
        SystemIncludes = info.internal_isystem
        print("Found system includes:")
        print(SystemIncludes)

    # this is how we got it from the settings before...
    #sys_includes = common.get_setting("system_include_paths", [])

    opt = CompileOptions(language, SystemIncludes)

    # This is the bitmask sent to index.parse.
    # For example, to be able to go to the definition of
    # preprocessed macros, set it to 1, for using an implicit
    # precompiled header set it to 4 and for caching completion
    # results, set it to 8. Or all together 1+4+8=13.
    # See http://clang.llvm.org/doxygen/group__CINDEX__TRANSLATION__UNIT.html#gab1e4965c1ebe8e41d71e90203a723fe9
    # and http://clang.llvm.org/doxygen/Index_8h_source.html
    # for more details
    opt.index_parse_type = 13

    language_options = common.get_setting("language_options", {})
    if language_options.has_key(language.key()):
        opt.language_options = language_options[language.key()]

    project_file, project_options = common.get_project_settings(filename)
    if project_file != None:
        opt.project_file = project_file
        opt.project_options  = project_options
    return opt
コード例 #41
0
ファイル: info.py プロジェクト: themycode/material-theme
    def run(self):
        """Run command."""

        info = {}

        info["platform"] = sublime.platform()
        info["version"] = sublime.version()
        info["arch"] = sublime.arch()
        info["bh_version"] = __version__
        info["pc_install"] = is_installed_by_package_control()
        try:
            import mdpopups
            info["mdpopups_version"] = format_version(mdpopups, 'version', call=True)
        except Exception:
            info["mdpopups_version"] = 'Version could not be acquired!'

        try:
            import markdown
            info["markdown_version"] = format_version(markdown, 'version')
        except Exception:
            info["markdown_version"] = 'Version could not be acquired!'

        try:
            import jinja2
            info["jinja_version"] = format_version(jinja2, '__version__')
        except Exception:
            info["jinja_version"] = 'Version could not be acquired!'

        try:
            import pygments
            info["pygments_version"] = format_version(pygments, '__version__')
        except Exception:
            info["pygments_version"] = 'Version could not be acquired!'

        msg = textwrap.dedent(
            """\
            - Sublime Text:   %(version)s
            - Platform:   %(platform)s
            - Arch:   %(arch)s
            - Theme:   %(bh_version)s
            - Install via PC:   %(pc_install)s
            - Dependencies:
                * mdpopups:   %(mdpopups_version)s
                * markdown:   %(markdown_version)s
                * pygments:   %(pygments_version)s
                * jinja2:   %(jinja_version)s
            """ % info
        )

        view = sublime.active_window().active_view()

        def copy_and_hide(msg):
            sublime.set_clipboard(msg)
            view.hide_popup()

        view.show_popup(msg.replace('\n', '<br>') + '<br><a href="' + msg + '">Copy</a>', on_navigate = copy_and_hide, max_height = 340)
コード例 #42
0
    def run(self):
        info = {}

        info['platform'] = sublime.platform()
        info['version'] = sublime.version()
        info['arch'] = sublime.arch()
        info['boxy_version'] = __version__
        info['pc_install'] = is_installed_by_package_control()

        try:
            import mdpopups
            info['mdpopups_version'] = format_version(mdpopups,
                                                      'version',
                                                      call=True)
        except Exception:
            info['mdpopups_version'] = 'Version could not be acquired!'

        try:
            import markdown
            info['markdown_version'] = format_version(markdown, 'version')
        except Exception:
            info['markdown_version'] = 'Version could not be acquired!'

        try:
            import jinja2
            info['jinja_version'] = format_version(jinja2, '__version__')
        except Exception:
            info['jinja_version'] = 'Version could not be acquired!'

        try:
            import pygments
            info['pygments_version'] = format_version(pygments, '__version__')
        except Exception:
            info['pygments_version'] = 'Version could not be acquired!'

        msg = textwrap.dedent('''\
            - Boxy Theme: %(boxy_version)s
            - Sublime Text: %(version)s
            - Platform: %(platform)s
            - Package Control: %(pc_install)s
            - Dependencies:
                * mdpopups: %(mdpopups_version)s
                * markdown: %(markdown_version)s
                * pygments: %(pygments_version)s
                * jinja2: %(jinja_version)s
            ''' % info)

        view = sublime.active_window().active_view()

        def copy_and_hide(msg):
            sublime.set_clipboard(msg)
            view.hide_popup()

        view.show_popup(msg.replace('\n', '<br>') + '<br><a href="' + msg +
                        '">Copy</a>',
                        on_navigate=copy_and_hide)
コード例 #43
0
    def run(self, edit, encoding, file_name):
        self.view.set_name('ConvertToUTF8 Instructions')
        self.view.set_scratch(True)
        self.view.settings().set("word_wrap", True)
        msg = 'Oops! The file {0} is detected as {1} which is not supported by your Sublime Text.\n\nPlease check whether it is in the list of Python\'s Standard Encodings (http://docs.python.org/library/codecs.html#standard-encodings) or not.\n\nIf yes, '.format(
            file_name, encoding)
        branch = self.get_branch(sublime.platform(), sublime.arch())
        if branch:
            ver = '33' if ST3 else '26'
            msg = msg + 'please install Codecs{0} (https://github.com/seanliang/Codecs{0}/tree/{1}) and restart Sublime Text to make ConvertToUTF8 work properly. If it is still not working, '.format(
                ver, branch)

        import platform
        msg = msg + 'please kindly send the following information to sunlxy#yahoo.com:\n====== Debug Information ======\nVersion: {0}-{1}\nPlatform: {2}\nPath: {3}\nEncoding: {4}\n'.format(
            sublime.version(), sublime.arch(), platform.platform(), sys.path,
            encoding)
        self.view.insert(edit, 0, msg)
        self.view.set_read_only(True)
        self.view.window().focus_view(self.view)
コード例 #44
0
def filter_releases(package, settings, releases):
    """
    Returns all releases in the list of releases that are compatible with
    the current platform and version of Sublime Text

    :param package:
        The name of the package

    :param settings:
        A dict optionally containing the `install_prereleases` key

    :param releases:
        A list of release dicts

    :return:
        A list of release dicts
    """

    platform_selectors = [
        sublime.platform() + '-' + sublime.arch(),
        sublime.platform(), '*'
    ]

    install_prereleases = settings.get('install_prereleases')
    allow_prereleases = install_prereleases is True
    if not allow_prereleases and isinstance(
            install_prereleases, list) and package in install_prereleases:
        allow_prereleases = True

    if not allow_prereleases:
        releases = version_exclude_prerelease(releases)

    output = []
    st_version = int(sublime.version())
    for release in releases:
        platforms = release.get('platforms', '*')
        if not isinstance(platforms, list):
            platforms = [platforms]

        matched = False
        for selector in platform_selectors:
            if selector in platforms:
                matched = True
                break
        if not matched:
            continue

        # Default to '*' (for legacy reasons), see #604
        if not is_compatible_version(release.get('sublime_text', '*'),
                                     st_version):
            continue

        output.append(release)

    return output
コード例 #45
0
ファイル: environment.py プロジェクト: trongthanh/dotfiles
    def run(self):
        info = {}

        info['platform'] = sublime.platform()
        info['version'] = sublime.version()
        info['arch'] = sublime.arch()
        info['boxy_version'] = __version__
        info['pc_install'] = is_installed_by_package_control()

        try:
            import mdpopups
            info['mdpopups_version'] = format_version(mdpopups, 'version',
                                                      call=True)
        except Exception:
            info['mdpopups_version'] = 'Version could not be acquired!'

        try:
            import markdown
            info['markdown_version'] = format_version(markdown, 'version')
        except Exception:
            info['markdown_version'] = 'Version could not be acquired!'

        try:
            import jinja2
            info['jinja_version'] = format_version(jinja2, '__version__')
        except Exception:
            info['jinja_version'] = 'Version could not be acquired!'

        try:
            import pygments
            info['pygments_version'] = format_version(pygments, '__version__')
        except Exception:
            info['pygments_version'] = 'Version could not be acquired!'

        msg = textwrap.dedent(
            '''\
            - Boxy Theme: %(boxy_version)s
            - Sublime Text: %(version)s
            - Platform: %(platform)s
            - Package Control: %(pc_install)s
            - Dependencies:
                * mdpopups: %(mdpopups_version)s
                * markdown: %(markdown_version)s
                * pygments: %(pygments_version)s
                * jinja2: %(jinja_version)s
            ''' % info
        )

        view = sublime.active_window().active_view()
        def copy_and_hide(msg):
            sublime.set_clipboard(msg)
            view.hide_popup()
        view.show_popup(msg.replace('\n', '<br>') +
                        '<br><a href="' + msg + '">Copy</a>',
                        on_navigate=copy_and_hide)
コード例 #46
0
	def run(self, edit, encoding):
		self.view.set_name('ConvertToUTF8 Instructions')
		self.view.set_scratch(True)
		self.view.settings().set("word_wrap", True)
		fp = open(os.path.join(PKG_PATH, 'python26.txt'), 'r')
		msg = fp.read()
		fp.close()
		msg += 'Version: {0}\nPlatform: {1}\nArch: {2}\nPath: {3}\nEncoding: {4}\n'.format(
			sublime.version(), sublime.platform(), sublime.arch(), sys.path, encoding
		)
		self.view.insert(edit, 0, msg)
コード例 #47
0
 def run(self, edit, encoding):
     self.view.set_name('ConvertToUTF8 Instructions')
     self.view.set_scratch(True)
     self.view.settings().set("word_wrap", True)
     fp = open(os.path.join(PKG_PATH, 'python26.txt'), 'r')
     msg = fp.read()
     fp.close()
     msg += 'Version: {0}\nPlatform: {1}\nArch: {2}\nPath: {3}\nEncoding: {4}\n'.format(
         sublime.version(), sublime.platform(), sublime.arch(), sys.path,
         encoding)
     self.view.insert(edit, 0, msg)
コード例 #48
0
def has_libclang():
    """Ensure libclang tests will run only on platforms that support this.

    Returns:
        str: row contents
    """
    # Older version of Sublime Text x64 have ctypes crash bug.
    if platform.system() == "Windows" and sublime.arch() == "x64" and \
            int(sublime.version()) < 3123:
        return False
    return True
コード例 #49
0
ファイル: dmc.py プロジェクト: BYOND/sublime-dreams
	def run(self, cmd = [], file_regex = "", kill_old = False, dream_seeker = False, dream_daemon = False):
		dmpath = path[sublime.arch()]

		dme_dir = self.build(dmpath, cmd[0], file_regex)
		dmb_dir = self.find_dmb(dme_dir)

		if dream_seeker:
			self.run_in_seeker(dmpath, dmb_dir)

		if dream_daemon:
			self.run_in_daemon(dmpath, dmb_dir)
コード例 #50
0
def getArch():
    result = ""
    if os.environ['OS'].startswith("Windows"):
        result = "windows_"
    else:
        result = "linux_"
    if sublime.arch() == "x64":
        result += "amd64"
    else:
        result += "386"
    return result
コード例 #51
0
def has_libclang():
    """Ensure libclang tests will run only on platforms that support this.

    Returns:
        str: row contents
    """
    # Older version of Sublime Text x64 have ctypes crash bug.
    if platform.system() == "Windows" and sublime.arch() == "x64" and \
            int(sublime.version()) < 3123:
        return False
    return True
コード例 #52
0
def get_arch():
    try:
        # handle a case of m1 running under roseeta
        if sublime.platform() == "osx":
            if "ARM64" in platform.version().upper():
                return "arm64"
    except Exception as e:
        print("Error checking if apple m1:", e)
        pass

    return sublime.arch()
コード例 #53
0
def getArch():
    result = ""
    if "windows" in sublime.platform():
        result = "windows_"
    else:
        result = "linux_"
    if sublime.arch() == "x64":
        result += "amd64"
    else:
        result += "386"
    return result
コード例 #54
0
ファイル: pushb.py プロジェクト: geovanisouza92/Pushb
 def __init__(self, *args, **kwargs):
     super(PushbCommand, self).__init__(*args, **kwargs)
     self.headers = {
         'Accept': 'application/json',
         'Authorization': 'Bearer ' + get_setting('token'),
         'Content-Type': 'application/json',
         'User-Agent': 'Sublime Text/%(version)s (%(platform)s/%(arch)s)' % {
             'version': sublime.version(),
             'platform': sublime.platform(),
             'arch': sublime.arch(),
         },
     }
コード例 #55
0
def filter_releases(package, settings, releases):
    """
    Returns all releases in the list of releases that are compatible with
    the current platform and version of Sublime Text

    :param package:
        The name of the package

    :param settings:
        A dict optionally containing the `install_prereleases` key

    :param releases:
        A list of release dicts

    :return:
        A list of release dicts
    """

    platform_selectors = [
        sublime.platform() + '-' + sublime.arch(),
        sublime.platform(),
        '*'
    ]

    install_prereleases = settings.get('install_prereleases')
    allow_prereleases = install_prereleases is True
    if not allow_prereleases and isinstance(install_prereleases, list) and package in install_prereleases:
        allow_prereleases = True

    if not allow_prereleases:
        releases = version_exclude_prerelease(releases)

    output = []
    for release in releases:
        platforms = release.get('platforms', '*')
        if not isinstance(platforms, list):
            platforms = [platforms]

        matched = False
        for selector in platform_selectors:
            if selector in platforms:
                matched = True
                break
        if not matched:
            continue

        # Default to '*' (for legacy reasons), see #604
        if not is_compatible_version(release.get('sublime_text', '*')):
            continue

        output.append(release)

    return output
コード例 #56
0
    def run():
        """Run command."""
        info = {
            'platform': sublime.platform(),
            'st_version': sublime.version(),
            'arch': sublime.arch(),
            'package_version': gitgutter_version(),
            'pc_install': is_installed_by_package_control(),
            'git_version': git_version()
        }

        try:
            import markdown
            info['markdown'] = module_version(markdown, 'version')
        except ImportError:
            info['markdown'] = 'not installed!'

        try:
            import mdpopups
            info['mdpopups'] = module_version(mdpopups, 'version')
        except ImportError:
            info['mdpopups'] = 'not installed!'

        try:
            import jinja2
            info['jinja'] = module_version(jinja2, '__version__')
        except ImportError:
            info['jinja'] = 'not installed!'

        try:
            import pygments
            info['pygments'] = module_version(pygments, '__version__')
        except ImportError:
            info['pygments'] = 'not installed!'

        msg = textwrap.dedent(
            """\
            - Sublime Text %(st_version)s
            - Platform: %(platform)s
            - Arch: %(arch)s
            - GitGutter %(package_version)s
            - Install via PC: %(pc_install)s
            - %(git_version)s
            - mdpopups %(mdpopups)s
            - markdown %(markdown)s
            - pygments %(pygments)s
            - jinja2 %(jinja)s
            """ % info
        )

        sublime.message_dialog(msg + '\nInfo has been copied to clipboard.')
        sublime.set_clipboard(msg)
コード例 #57
0
ファイル: environment.py プロジェクト: abdusa/sublime-boxy
    def run(self):
        info = {}

        info['platform'] = sublime.platform()
        info['version'] = sublime.version()
        info['arch'] = sublime.arch()
        info['boxy_version'] = __version__
        info['pc_install'] = is_installed_by_package_control()

        try:
            import mdpopups
            info['mdpopups_version'] = format_version(mdpopups, 'version',
                                                      call=True)
        except Exception:
            info['mdpopups_version'] = 'Version could not be acquired!'

        try:
            import markdown
            info['markdown_version'] = format_version(markdown, 'version')
        except Exception:
            info['markdown_version'] = 'Version could not be acquired!'

        try:
            import jinja2
            info['jinja_version'] = format_version(jinja2, '__version__')
        except Exception:
            info['jinja_version'] = 'Version could not be acquired!'

        try:
            import pygments
            info['pygments_version'] = format_version(pygments, '__version__')
        except Exception:
            info['pygments_version'] = 'Version could not be acquired!'

        msg = textwrap.dedent(
            '''\
            - Boxy Theme: %(boxy_version)s
            - Sublime Text: %(version)s
            - Platform: %(platform)s
            - Package Control: %(pc_install)s
            - Dependencies:
                * mdpopups: %(mdpopups_version)s
                * markdown: %(markdown_version)s
                * pygments: %(pygments_version)s
                * jinja2: %(jinja_version)s
            ''' % info
        )

        sublime.message_dialog(
            msg + '\nInfo has been copied to the clipboard.'
        )
        sublime.set_clipboard(msg)