I have a problem when I install the package control of sublime text 3 because of the proxy set but I need to install a plugin. When I do getproxy in the console it returns me {} and when I try to set the proxy with python in console with
urllib.set_proxy('http://user:password#server:port', 'http')
I replaced the user, password, server and port by their values but it returns me
Traceback (most recent call last):
File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'set_proxy'
what can I do to make it work? I need to install a plugin .
Setting Up Package Control to Work from Behind a Proxy Server
You will need to setup your proxy server in the Package Control settings.
Copy and paste the code below into a file called Package Control.sublime-settings which must be saved in your User config folder. That is the same folder as your USER Preferences.sublime-settings file is saved in. The Data Directory states where this is on your operating system. i.e.
Windows: %APPDATA%\Sublime Text 3\Packages\User\Package Control.sublime-settings
OS X: ~/Library/Application Support/Sublime Text 3/Packages/User/Package Control.sublime-settings
Linux: ~/.config/sublime-text-3/Packages/User/Package Control.sublime-settings
Clearly you must add the domain and port and your user name and password in the relevant fields below. The proxy should be in the form: proxyserver:port. e.g.
{
"http_proxy": "server.com:80",
"https_proxy": "server.com:8080",
"proxy_username": "mynameis",
"proxy_password": "mypassis",
}
See also: Package Control Settings
{
// An HTTP proxy server to use for requests. Not normally used on Windows
// since the system proxy configuration is utilized via WinINet. However,
// if WinINet is not working properly, this will be used by the Urllib
// downloader, which acts as a fallback.
"http_proxy": "",
// An HTTPS proxy server to use for requests - this will inherit from
// http_proxy if it is set to "" or null and http_proxy has a value. You
// can set this to false to prevent inheriting from http_proxy. Not
// normally used on Windows since the system proxy configuration is
// utilized via WinINet. However, if WinINet is not working properly, this
// will be used by the Urllib downloader, which acts as a fallback.
"https_proxy": "",
// Username and password for both http_proxy and https_proxy. May be used
// with WinINet to set credentials for system-level proxy config.
"proxy_username": "",
"proxy_password": "",
}
You could simply run the below command in the Sublime 3 console (launch console using CTRL+` or View -> Show Console)
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler({'http': 'http://USER:PASSWORD#HOST:PORT', 'https': 'https://USER:PASSWORD#HOST:PORT'})) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())
In the above code, you need to replace the value(USER:PASSWORD#HOST:PORT) of http and https keys as per your proxy details
Then hit Enter and it will install the Package Control using the provided proxy
I exactly had the same issue, I was unable to download packages for Sublime Text 3. I set up the proxy server at runtime as shown in below snippet in the Sublime console (Mac Shortcut Ctrl + `) and it worked for me.
import os
proxy_server = 'http://username:password#proxy_server_name:port'
os.environ['http_proxy'] = proxy_server
os.environ['HTTP_PROXY'] = proxy_server
os.environ['https_proxy'] = proxy_server
os.environ['HTTPS_PROXY'] = proxy_server
os.environ['all_proxy'] = proxy_server
os.environ['ALL_PROXY'] = proxy_server
os.environ['ftp_proxy'] = proxy_server
os.environ['FTP_PROXY'] = proxy_server
for socks5 proxy settings:
menubar: Preferences > Package Settings > Package Control > Settings
NOTE: curl downloadder backend support socks5.
{
"downloader_precedence": {
"linux": ["curl"]
},
"http_proxy": "socks5://127.0.0.1:1080",
"proxy_password": "",
"proxy_username": "",
...
Related
I setup Neovim LSP using the nvim-lspconfig and the lsp-installer where I also installed the pyright server.
Without any further configuration it worked out of the box. However when I have a class in a subfolder and add a new method, pyright does not recognize this method when I want to access it in a different file. When I restart neovim, or open and close the file, pyright suddenly recognizes the newly added method.
I also tried :LspRestart with no effect.
I tried to add some settings to the pyright server:
return {
settings = {
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = "workspace",
useLibraryCodeForTypes = true,
}
}
},
}
But this also had no effect.
:LspLog also does not show anything which could point to the issue:
[START][2022-07-15 11:11:05] LSP logging initiated
[WARN][2022-07-15 11:11:09] ...lsp/handlers.lua:109 "The language server pyright triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[WARN][2022-07-15 11:11:09] ...lsp/handlers.lua:456 "stubPath typings is not a valid directory."
[WARN][2022-07-15 11:11:20] ...lsp/handlers.lua:109 "The language server pyright triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
I also could not find any setting regarding to this issue here which could solve this.
Since I am new to python, the way I import and structure classes might not be common and might be an issue which could cause this problem.
As a main entry point I have main.py in the root folder
All other source files are in a program/ folder which does not have a __init__.py
Inside program/ there are folders which each have a __init__.py file f.e. core/
core/__init__.py:
from .myClass import myClass
and in main.py I import it like this:
from subfolder.core import myClass
myClass.newMethod() # this is only recognized by lsp/pyright after the file is closed and reopen
Is the issue a bug in pyright (not likely I guess), a missing setting or my strange folder/import structure?
Can you try this: create (or modify) pyproject.toml, put it in the project root directory. Inside pyproject.toml, add the following lines:
[tool.pyright]
extraPaths = ["program/core" ,"program/directory_2", "program/directory_3"]
The idea is that you have to add the sub directories manually, which is really tedious but at least it works in my case.
I have requirement to refactor a K8s Python app so that it gets some configuration from a remote Giltab project because for various reasons we want to decouple applicaton settings from our pipeline/deployment environment.
In my functional testing, this works:
import configparser
config = configparser.ConfigParser()
config_file = "config.ini" # local file for testing
config.read(config_file)
['config.ini']
However, when I attempt to read the configuration from a remote file (our requirement), this DOES NOT work:
import requests
import os
token = os.environ.get('GITLAB_TOKEN')
headers = {'PRIVATE_TOKEN': token}
params = { 'ref' : 'master' }
response = requests.get('https:/path/to/corp/gitlab/file/raw', params=params,
headers=headers
config = configparser.ConfigParser()
configfile = response.content.decode('utf-8')
print(configfile) # this is good!
config.read(configfile) # this fails to load the contents into configparser
[]
I get an empty list. I can create a file and or print the contents of the configfile object from the requests.get call, and the ini data looks good. config.read() seems unable to load this as an object in memory and only seems to work by reading a file from disk. Seems like writing the contents of the requests.get to a local .ini file would defeat the whole purpose of using the remote configuration repo.
Is there a good way to read that configuration file from the remote and have configparser access it at container runtime?
I got this working with:
config.read_string(configfile)
I'm having an issue with Selenium standalone webdriver used with webdriver-manager npm module. I'm using the Firefox Gecko driver. I need to select a file from an HTML file input component. When I try this on my local machine or on BrowserStack I get the error:
"WebDriverError: File not found: /Users/christophergrigg/a.pdf"
const requestFile = By.id('requestFile');
driver.wait(until.elementLocated(requestFile));
const requestFileEl = driver.findElement(requestFile);
driver.wait(until.elementIsVisible(requestFileEl), TIMEOUT).click();
requestFileEl.sendKeys('/Users/christophergrigg/a.pdf');
requestFileEl.sendKeys(webdriver.Key.ENTER);
On Browser stack I'm using this path:
requestFileEl.sendKeys('C:\\Desktop\\documents\\pdf-sample2.pdf'); // Windows 7 / 8 / 8.1
You need to provide the full path of the file. And if the file is not present on the machine running the remote instance, you'll also have to set the file detector to automatically upload the file.
On mac OS X:
var remote = require('selenium-webdriver/remote');
driver.setFileDetector(new remote.FileDetector);
driver.sendKeys('/Users/christophergrigg/Desktop/a.pdf');
, or Windows:
var remote = require('selenium-webdriver/remote');
driver.setFileDetector(new remote.FileDetector);
driver.sendKeys('C:\\Users\\christophergrigg\\Desktop\\a.pdf');
I have installed sublime2, package control module and nodejs through it.
After opening my js application I am getting next error, when try to run my application Tools->NodeJS->Run.
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 445, in is_enabled_
raise ValueError("is_enabled must return a bool", self)
ValueError: ('is_enabled must return a bool', <Nodejs.Nodejs.NodeUglifyCommand object at 0x10f70bc90>)
All items in the menu are disabled.
Also I have tried modify user settings use next one:
{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "/usr/local/bin/node",
// Same for NPM command
"npm_command": "/usr/local/bin/npm",
// as 'NODE_PATH' environment variable for node runtime
"node_path": "/usr/local/Cellar/node/0.10.25",
"expert_mode": false,
"ouput_to_new_tab": false
}
I have installed node via brew.
I had the same problem with my custom build system. The solution is just to choose the build system you want to use.
There must be checkmark alongside some build system in Tools->Build System
I'm using Tornado working with Python 3 and Linux server, when I edit and save some text or XML files I want Tornado to restart itself. I checked the document and found the autoreload module and the watch function here.
It seems it only worked for pyo files. What can I do if I want it to reload when a certain URI is modified?
Setting the debug flag to True in settings forces Tornado to reload whenever a file is modified or whenever a URI is changed in app.py (or where ever you have defined your handlers). Tornado also automatically reloads template files so any changes in there will be seen instantly.
settings = {
'debug':True,
# other stuff
}
tornado.web.Application.__init__(self, handlers, **settings)
the file added must be an absolute path.
def addwatchfiles(*paths):
for p in paths:
autoreload.watch(os.path.abspath(p))
addwatchfiles('config.xml')
config.xml is at the same directory in where the server's python file start at.
You need to turn autoreload on:
tornado.autoreload.start()
tornado.autoreload.watch('myfile')
Complete example at https://gist.github.com/renaud/10356841