Friday, July 06, 2018

A new home for my projects and a project update

New Home

I know that there is always an expectation that, if you are a developer of some sort, you store your code into Github (at least that is the first one that comes to people's mind).  I have a Github acct, but, because their private repos are not free, I haven't truly used them for storing my repos.  And considering that Microsoft now owns them, I really won't be using them for my code.

Up until now, I have relied on Bitbucket (currently owned by Atlassian), as it offers unlimited free private and public repos.  We have both Bitbucket and Gitlab at my work (local installs for both).  After all of the increased fanfare for Gitlab (after the Microsoft purchase of Github) and my exposuer to it at work, I have made the switch to store my repos there as well.  Unless they change their policies, I will probably be with them quite a while.  


Project Update:

I did want to say that I have migrated my 'pyblueprint' project over to Gitlab.  Thankfully Gitlab makes the migration to them painless, and it was just a click of a couple of buttons to get the repo moved over.  The 'hard part', if you will (although not really), was fixing my git remote to point to the new repository location.  

I do want to say that I have added support to the project for creating a repository up in Gitlab.  Seeing as how I am now using it, why not.  :)  While testing out the application to ensure everything was still working afterwards, I discovered that my checks were not working.  Why?  Because the maintainers of 'pip' decided that, as of pip 10.0.0, they no longer support pip bing used programatically.  If you drop into IDLE, do an 'import pip' and then do a 'dir(pip)', you will now notice that there are no methods associated (aside from the underscore methods).  This completely broke my checks as I had relied on that useful bit.  No worries though, the checks are fixed and functioning as expected.  

Also, if anyone is using this application (don't know if anyone is) and they would like support for an alternative code repository, please feel free to open an enhancement ticket and I will see about adding support for it.  

That's it for now, happy coding!

Saturday, June 30, 2018

Setting up MELPA for Emacs packages

In my journey to learn emacs, one of the first things that I wanted to do was change the theme so that it was more pleasing to the eye.  Anyone who uses a tool enough knows that if you can personalize it for you, you personalize it. 

So in researching themes ( see the emacs themes site ), I kept seeing references to MELPA, which is an emacs package manager.  Sweet!  Unfortunately, my quest to install the theme I wanted was met with the fact that it is NOT configured to use MELPA by default.  Thus, the reason for this write-up. 

In order to configure emacs to see the MELPA packages, you need to edit your .emacs file in your home directory.  If you have at least opened emacs, this file should exist.  If not, just create it and open it for editing.

To correctly enable MELPA, you will need the following as the first section of the file:

;; load emacs 24's package system. Add MELPA repository.
(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   ;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
   '("melpa" . "http://melpa.milkbox.net/packages/")
   t))
 After you save the .emacs file, you will need to restart emacs if it is already running.  If not, start it up.  Once running, you will need to his what in the emacs world is referred to as M-x.  On a mac, that is Option + the 'x' key.  I don't run Windows, so I really couldn't begin to tell you what it is on there. 

That will drop you into the M-x mini buffer.  There, type 'list-packages'.  In the main window, a columned list should appear.  The 4th column is 'archive' and should have packages that say 'melpa' (as well as 'gnu').  If so, you are good to install the theme you found. 

To install a melpa package, drop back into the M-x mini buffer and type 'package-install'.  This will change the prompt to "Install package: " which will wait for a package name.  The nice thing is that tab-complete works in emacs.  So start typing a package name and hit tab, and a list will appear in the are right above the mini buffer. Once you complete installing the packages you need, go ahead and restart emacs. 

I certainly hope this makes your emacs package installation easier.  :)

Straddling the line between editors

Since I started in Unix/Linux about 20 years ago, I have been a staunch user and supporter of vi.  I have known plenty of people that were emacs aficionados, but haven't really taken the time to learn it to the point of being proficient.  I did look at it a few years ago after starting my current job, but with all of the new things I was learning, I forwent it in favor of the things I actually needed to learn at my job.

Now, 5 1/2 year later, I have decided that I am at a point where I finally have time to learn it.  I know what vi lovers are thinking, "hell no!", and I get that.  I was like that for years.  But, after getting to work for the last 5 1/2 years with a friend that I have now known for 16 years, I have seen him operate pretty seemlessly in emacs, without needing to go to the shell that often.  I have seen some pretty cool features that nicely streamlined his workflow.

Its never easy picking up a new tool, that's for sure, especially when you like the features of your current tool, but sometimes you have to make concessions to go farther.  All that said, don't be surprised if you see emacs related posts here, as I am wanting to share what I am learning.

In closing I will provide the two initial links that I am using to start my journey down the emacs path:

Absolute Beginner's Guide To Emacs
Practical Emacs Tutorial


Hopefully, if you decide to also venture down this road, those will help you as well.  I will say that so far, the Absolute Beginner's Guide has been awesome!!


Saturday, May 05, 2018

Setup WiFi to auto-connect regardless of logged in state (UPDATED)

There are plenty of times where I would like to start up my desktop machine (running Ubuntu 16.04 LTS) and just have it boot and me log into it via SSH so that I can get some work done.  Well, in order to achieve that wish, you need to have your wifi connection auto-connnect at boot time.

To do this, there are some things you need to do:

1.  Go to your wifi connection in the upper right of your screen and click on "Edit Connections".
2.  Once in there, you need to click on your connected wifi ssid and select "Edit".
3.  Go to the "General" tab and select "All users may connect to this network".  (without this, the rest of this is moot and it will not work)

Ok, that is the only gui portion of this setup.  Next:

4.  Create the file /etc/wpa_supplicant.conf and add the content that follows:

ctrl_interface=DIR=/var/run/wpa_supplicant group=wheel
network={
  ssid="your_connection_ssid"
  scan_ssid=1
  key_mgmt=WPA-PSK
  psk="password"
}
In the above code, you will input your ssid that you would like to connect to and also enter your password for the connection.  If you are using an encryption method other than WPA/WPA2, then you will need to reference the man page for wpa_supplicant.conf.  There are plenty of examples to help you out. 

After you have that file all setup, save it.

5.  Issue the following command on the command line, as root or with sudo:

wpa_supplicant -B -i wlp4s0 -c /etc/wpa_supplicant.conf

You should see a message that says something to the effect that wpa_supplicant initialization was successful.

After you have completed those steps, go ahead and reboot the machine and watch the login screen.  If all is correct and right with the configuration, you should see the wifi connection show as connected.  You can test this by ssh'ing to the machine.  Enjoy!


UPDATE:  I took the opportunity to reinstall my Linux system to go from Ubuntu 16.04 LTS to Ubuntu 18.04.  I know its a bit extreme to do a full re-install, but:

1.  An distribution upgrade wasn't yet available
2.  There wasn't anything I couldn't re-setup on the machine
3.  Ubuntu moved away from Unity to the Gnome desktop, so I wanted everything clean and fresh.

I will say this though, auto-connection of the wifi (seeing as how you tell it how to connect during installation) just WORKS with Ubuntu 18.04.  You just have to make sure to install the openssh-server package.

Tuesday, May 01, 2018

How to list available versions of a Pypi package

While working on requirements that someone had for a pypi package, I found myself needing to list out the versions of the package that were available.  I didn't want to have to go to the pypi website, navigate to the package and then figure out how to see the available versions.  So, to the Googles I went.

In order to install a specific version of a package, you would run:

pip install =1.0.0

in order to install version 1.0.0 of said package.  But, if you provide nonsense as the option, like so:

pip install =blah

then what you get back is an error listing all of the available versions for that package:


> pip install mod_wsgi==blah
Collecting mod_wsgi==blah
Could not find a version that satisfies the requirement mod_wsgi==blah (from versions: 4.1.0, 4.1.1, 4.1.2, 4.1.3, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.2.5, 4.2.6, 4.2.7, 4.2.8, 4.3.0, 4.3.1, 4.3.2, 4.4.0, 4.4.1, 4.4.2, 4.4.3, 4.4.4, 4.4.5, 4.4.6, 4.4.7, 4.4.8, 4.4.9, 4.4.10, 4.4.11, 4.4.12, 4.4.13, 4.4.14, 4.4.15, 4.4.16, 4.4.17, 4.4.18, 4.4.19, 4.4.20, 4.4.21, 4.4.22, 4.4.23, 4.5.0, 4.5.1, 4.5.2, 4.5.3, 4.5.4, 4.5.5, 4.5.6, 4.5.7, 4.5.8, 4.5.9, 4.5.10, 4.5.11, 4.5.12, 4.5.13, 4.5.14, 4.5.15, 4.5.16, 4.5.17, 4.5.18, 4.5.19, 4.5.20, 4.5.21, 4.5.22, 4.5.23, 4.5.24, 4.6.0, 4.6.1, 4.6.2, 4.6.3, 4.6.4)
No matching distribution found for mod_wsgi==blah

Good to know its that easy.

Sunday, April 29, 2018

python pip throwing SSL: TLSV1 alert (SOLUTION)

I recently ran into an issue with Python pip, where I attempted to run a 'pip install' of a module and was presented with the following error:
> pip install pymongo
Collecting pymongo
Could not fetch URL https://pypi.python.org/simple/pymongo/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) - skipping
Could not find a version that satisfies the requirement pymongo (from versions: )
No matching distribution found for pymongo

No matter what I did (install, update and even just search the pip repository) I was presented with this same error.  It was certainly a hard, fast stop to whatever I was attempting to do.

But, after some googling and reading of many people's accounts of their trials and tribulations attempting to solve it, I finally found a solution that works.  I happened upon the this posting on StackOverflow, which leads you to the fact that you have to upgrade pip.  Unfortunately, attempting to upgrade it with itself will fail as above.  But, you should instead run the following:

curl https://bootstrap.pypa.io/get-pip.py | python

That upgraded pip directly from the website using its install script.  It is a work around, yes, but one that seems to have worked for me (and apparently others).  Hopefully this solves your issue(s) as well.

**UPDATE: You will need to run the curl command in each virtualenv environment that you have, as each one will have its own installation of python.
 
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.