In a previous post I talked about setting up an encrypted file based keyring store for Mercurial. With some recent updates of the Python keyring modules, the setup changed a little bit again.
The file-backed keyrings got moved out to the keyrings.alt package.
$HOME/.local/share/python_keyring/keyringrc.cfg needs to be adjusted as follows:
So today I was trying to fix a problem with the deployment of some software with Ansible. I am using
get_url in combination with a
http_proxy environment setting in order to pull a file in from a HTTP URL. However, when I ran the playbook I was greeted with a
[Errno 111] Connection refused error message. After fixing the proxy to have the netblock properly configured I tested again and was again greeted by the error. The problem became more confounding when I ran a test with curl on the command line using the proxy parameters, this test actually worked. So the proxy was running as it should. After some long testing and trying to figure out just what was going wrong, I replaced the
get_url with a
command: curl set up to test if it might be Ansible itself. The output of curl was enlightening, it turned out the HTTP URL was 301 redirecting to another HTTP URL, which in turn was 302 redirecting to a HTTPS URL! And since I wanted to be explicit I had not added the https_proxy environment variable.
The problem however now comes in how to to fix this. Is it documentation? Ansible code fix? Python code fix?
In an earlier post I documented how to set up an encrypted file store for your keyring. With recent versions of Python keyring (at least 3 and up) the
CryptedFileKeyring backend got removed and replaced by
EncryptedKeyring. So in your
$HOME/.local/share/python_keyring/keyringrc.cfg you need to now have the following:
If PyCharm complains that it
Can't start Mercurial: /usr/bin/hg Probably the path to hg executable is not valid, then check if running hg from the command line triggers a problem running a certain extension. In my case I had a version of
mercurial_keyring that did not play nice with each other. After upgrading these to 3.0.5 and 0.6.0 respectively, the problem went away. I guess PyCharm tests the run of the hg binary and if the shell return code (
echo $?) is something other than 0 will show this warning.
If you are doing Selenium testing using Chromedriver2 0.8 and are having problems with self-signed SSL certificates, this is a known problem and will be fixed in a subsequent release. In the meantime I found that using the Chromedriver 26.0.1383.0 still worked without problems for Chrome 27 and also did not have this SSL certificate regression in it.
Mercurial allows for tying in keyring configuration for those of us who do not want to store passwords in plain-text in our
.hgrc files or constantly using SSH.
First install the Python keyring library by running
pip install keyring. After that is installed, checkout https://bitbucket.org/Mekk/mercurial_keyring/ and add to
$HOME/.hgrc the following:
mercurial_keyring = ~/path/to/mercurial_keyring/mercurial_keyring.py
Next up, configure your repositories, e.g. in the case of Bitbucket I use:
bitbucket.prefix = bitbucket.org/asmodai
bitbucket.username = asmodai
bitbucket.schemes = https
Mercurial keyring will automatically decide on the best keyring to use. On a FreeBSD system with no Gnome or other systems providing a keyring, if you do not specify a specific keyring, the system will use the file
~/.local/share/python_keyring/keyring_pass.cfg. This keyring file stores the passwords encoded in Base64 in plain-text. This is not quite what you would want from a security point of view. You can configure which backend store to use by editing
$HOME/.local/share/python-keyring/keyringrc.cfg. To get a plain-text file with encrypted keys use the following configuration:
This will create the file
~/.local/share/python-keyring/crypted_pass.cfg after initializing the backend store with a password. Look at the documentation for keyring on what other configuration options are available.
Note: make sure the PyCrypto dependency is installed with the
_fastmath module. This in turn depends on the
PyCharm 1.1.1 was released yesterday. It consists mostly of bugfixes, find the full release notes on their site.
PyCharm already has a number of features present in various tools to lint/check your source code with, but offers a way to hook up external tools. Under
File > Settings is a section called
IDE Settings. One of the headings here is called
External Tools. Select this heading and then press the
Add... button on the right hand pane to configure a new external tool.
Edit Tool window that now appeared fill in a name, e.g.
PEP8 and a group name
Lint and add a description. Next point the
Program to the location of the
pep8.exe executable, e.g.
Parameters you need to use
Working directory should be filled in by default. Once done, you can close it by pressing the
Now, pyflakes has no .exe or .bat file to accompany it. You will need to add a pyflakes.bat in your
Scripts directory inside Python with the following contents:
rem Use python to execute the python script having the same name as this batch
rem file, but without any extension, located in the same directory as this
rem batch file
python "%~dpn0" %*
Within PyCharm you follow largely the same settings as for pep8, however make sure to point to the batch file of pyflakes under
Program. Close the external tools configuration windows by clicking
OK twice. Under the menu heading
Tools you should see an submenu heading
Lint which, in turn, should contain two menu items: PEP8 and Pyflakes.
Now open a Python file, go to
Tools > Lint > PEP8 and you should get output like the following in your Run (4) window:
D:\pprojects\babel\babel\tests\__init__.py:16:1: E302 expected 2 blank lines, found 1
Process finished with exit code 1
So I was so impressed by PyCharm that I purchased a license. I haven’t noticed much of any delays or slowdowns that other people have complained about.
For some reason setup.py can fail with docutils complaining it cannot find the roman module. One thing that works is just removing docutils from your site-packages and reinstall it.