How I feel when I try to address all pylint warning/errors:
How I feel when I try to address all pylint warning/errors:
I have been using quite a bit the anything-mode for Emacs, it’s basically a Quicksilver/Alfred or Gnome-do for Emacs and allow to configure a lot of different sources to complete some chosen ‘source’with different actions.
With my work on OpenStack I have found myself jumping a lot between git directories and due configured the variable ‘magit-repo-dirs for easy access to most of them easily.
Plugging those two just seemed natural I had already this in my emacs to quickly open those magit repository directories :
(global-set-key (read-kbd-macro "C-S-o") '(lambda ()(interactive) (dired (magit-read-top-dir nil))))
But going with anything is much nicer and I can add another action for openning the source to magit so I quickly came up with this magit source :
so now I open my different OpenStack Swift projects quickly with only a few keyboard touch (I bind my custom anything function to C-z) which shows graphically like this :
as always my full emacs config is available here:
I have released a python binding to Rackspace CloudDNS here which allow you to create/update/delete domains and records. It’s available on github
The binding is pretty simple and have unfortunately no documentation (or even tests) but you can figure out most of it from here :
I will be very welcoming pull request that add a bit of documentation.
This make things easy to add as a dependence of your project like you can have something like this in your setup.py :
requirements = ['python-cloudfiles']
and it will automatically download it as part of the dependence with easy_install or pip.
cool kids on latest debian/ubuntu can do stuff like this (from python-stdeb package) :
which would automatically download the tarball from pypi and install it as a packages (like the way it should be for prod machine!)
If you have a virtualenv environment you can easily do a (needs python-pip package) :
pip -E /usr/local/myvirtualenvroot install python-cloudfiles
and magic would be done to get you on latest python-cloudfiles.
As a bonus side you can browse online the python-cloudfiles library :
[Update] This has been renamed back to python-cloudfiles please update your setup.py or scripts.
This is available here :
for the scripter around you can just get (via curl or other) :
and it will automatically display it for that username.
I am sure there is billions or more people who already done that but I needed this quickly for my project and was not feeling googling around :
You want to connect to self signed SSL certificate from Java using the standard HttpsURLConnection and you are getting this error, because the self signed certificate is obviously not recognized by Java :
SEVERE: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at sun.security.ssl.Alerts.getSSLException(Alerts.java:192) at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1639) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:215) at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:209)
it seems that there is a lot of ‘solutions’ (read hack) or workaround around the web which is resumed well on this stack overflow article.
There is actually a very easy (and secure) way on Debian based systems.
– Go to your https url with Firefox
– Right Click to ‘View Page Info’
– In ‘Security’ tab you will see a button saying ‘View Certificate’
– Click now on the ‘Details’ tab
– Finally click on the ‘Export’ button which offer you to save the PEM certifcate of the website somewhere on your filesystem.
Call it my.self.signed.domain.name.pem or whatever my.self.signed.domain.name should be and put the file in /etc/ssl/certs now you just have to run the command :
and it should add your certificate to the java keystore, you can check it with the command (Enter for Password) :
keytool -list -v -keystore /etc/ssl/certs/java/cacerts
Lately I had to do a lot of works with the VMware VCloud product and since the python API did not seem available and I did not have the courage to use the PHP API I had to do most of the API works with Java. I never did any Java before and while I have found Eclipse+Java development surprisingly pleasant and easy to use/learn my favourite are still Emacs+Python.
I have then started to look over Jython to see if I can interact easily with Java via Python and this was actually pretty easy, it took me less than 10mn to convert a Login/Listing-VAPPS script in Jython.
The script is attached at the end of this post (or on github gist here). Don’t forget to adjust the classpath variable mine are defined like that :
#!/usr/bin/jython import sys from org.apache.commons.httpclient.protocol import Protocol from com.vmware.vcloud.sdk import VcloudClient, Organization, Vdc from com.vmware.vcloud.sdk.samples import FakeSSLSocketFactory class VcloudLogin(object): """ VcloudLogin: Login to vcloud class """ vcloudClient = None api_version = None vcloud_url = None def __init__(self, vcloud_url, api_version): # This is needed if you have a self certified certificate # remove it if you have a proper SSL certs. self.setup_fake_ssl() self.vcloud_url = vcloud_url self.api_version = api_version def setup_fake_ssl(self): https = Protocol("https", FakeSSLSocketFactory(), 443) Protocol.registerProtocol("https", https) def login(self, username, password): versions = VcloudClient.getSupportedVersions(self.vcloud_url + "/api/versions") self.vcloudClient = VcloudClient(versions.get(self.api_version)) return self.vcloudClient.login(username, password) if __name__ == '__main__': URL="https://URL" API_VERSION="0.9" USERNAME="user@organization" PASSWORD="password" vcl = VcloudLogin(URL, API_VERSION) organizations_list = vcl.login(USERNAME, PASSWORD) for org in organizations_list.values(): for vdcLink in \ Organization.getOrganizationByReference(vcl.vcloudClient, org).getVdcLinks(): vdc = Vdc.getVdc(vcl.vcloudClient, vdcLink) print "VDC Href: %s\n" % (vdcLink.getHref()) for vapps in vdc.getVappRefs(): print "Name: %s URL: %s" % (vapps.getName(), vapps.getHref())
Last week I have posted an article explaining how to connect to Rackspace Cloud Files via Rackspace ServiceNET but I actually got it wrong as pointed by my great colleague exlt so I had to take it down until figured out how to fix it.
I have add that feature properly to the PHP and Python API in version 1.5.0 to add a ‘servicenet’ argument to the connection and updated the blog post here :
It should give you all the information for the howto use that feature.
I have released as well a minor update in 1.5.1 to allow you to define the environment variable RACKSPACE_SERVICENET to force the use of the Rackspace ServiceNET this allow you to don’t have to modify the tools and have a clean code between prod and testing.
If you are a Rackspace customer and you are are planning to use Rackspace Cloud Files via it’s internal network (ServiceNet) so you don’t get billed for the bandwidth going over Cloud Files this is how you can do.
The first thing is to make sure with your support team if your servers are connected to ServiceNet and if you have that connection then there is a small change to do in your code.
The second thing is to use the just released 1.5.0 version on GitHUB for PHP :
and for python :
(you need to click on the download link at the top to download the tarball of the release).
Afer this is just a matter to set the argument servicenet=True, for example in PHP :
$user='username'; $api_key='theapi_key'; $auth = new CF_Authentication($user, $api_key); $auth->authenticate(); $conn = new CF_Connection($auth, $servicenet=true);
In Python you can do like this :
username='username' api_key='api_key' cnx = cloudfiles.get_connection(username, api_key, servicenet=True)