Rewriting a Python Program in Go, and Magento Migrations

September 13, 2018

Over the past week, I’ve been working on learning a few new things and applying that knowledge to current projects. I plan to post about once a week with updates on what I’ve learned, and what progress I’ve made on various projects.

Property Management Rewrite (and my attempt to learn Go)

My goal this week was to write a program in Go. The Property Management Call Log program I had written in Python had some bugs, and honestly the code was really messy, so I decided it would be a great candidate for my first Go project.

The program involves a very simple GUI containing two buttons. When a button is pressed, the user is prompted to select a .xlsx file containing a set of data for the month. The data is reformatted, a few operations are performed, and it’s returned to the user in a new file with better insights. In Python, I had used Tkinter and PyQT5 for the GUI. Originally, it had just been PyQT5, but adding the Open dialog caused an issue, so I used Tkinter for that part exclusively.

A function was required for each operation, one to initialize the GUI, and one for each button click. Of course, the init function was also required. All functions were kept in one file.

When rewriting in Go, I initially felt the urge to stick with QT5, but then decided to try something new. I began writing the program using go-gtk. While this has a few dependencies, it didn’t seem to be a problem. I had the main operations down pretty quickly in a file called callLogs.go, then began work on main.go, which would build the GUI and then call the functions in callLogs. It took a few tries for me to fully understand how to work with GTK, but everything worked pretty well. That is, until I tried to cross-compile for Windows.

I’m still not exactly sure what the problems I was running into while cross-compiling were. After a couple hours of frustration, I decided to simply compile the program on Windows. Of course, that’s not as simple as it should be. The dependencies were to be installed via MSys. This led to adding environment variables (that Windows was very picky about) and even after I had all dependencies installed, it appeared that multiple versions of some of the dependencies existed in PATH, and the program wouldn’t compile.

After stepping away from the program for a while, I decided to use a different GUI framework. I looked through a list of a few, and settled on walk. There isn’t a lot of documentation, but it looked like it handled everything I wanted in a pretty straightforward way. The most difficult thing I ran into was figuring out how to create a Save dialog. Beyond that, everything went pretty smoothly.

The program is running now, and while I haven’t added error handling yet, the Call Log operation works beautifully. Eventually I expect to add the other operation that the original program was doing, but as file formats changed, I’m not able to tackle that problem just yet.

Dinosaurs of EMS Migration

Migrating the Dinosaurs of EMS site from Magento 1 to Magento 2 has been an issue for quite some time. Having the site hosted on SiteGround, and using a theme and some modules that don’t convert easily to Magneto 2, there are plenty of traps to fall into. I’ve tried on at least 5 occasions to make this switch, and each time I run into something that stops me. This attempt was no different, but at least I ran into a different problem than I’m used to.

I created a backup of the original site, made a subdomain to host the new Magento 2 instance, and SSHed into the server. The first issue was one I recalled – SiteGround uses PHP 5 on the command line, whereas Magento 2 wants 7. I was able to quickly identify the path to the PHP 7 binary, created an alias for it, and got to work. It wasn’t long before I ran into the next (new) issue. When I used composer to attempt to download the migration tool, I got an out of memory error. I don’t remember this happening in the past, and I don’t see any indication on SiteGround that I’d be running out of memory. I’m likely going to have to contact their support to help me through this one, as I’m just not sure how to handle it on my own.

End of Week Tasks

I’ve been working my way through an Applied Text Analysis book, after realizing during my Google interview that it was an area I have a deep interest in and not a high understanding of. I expect the book to take another week or two to get through, but so far it’s kept my interest and I hope to create a project to apply the knowledge to shortly.

I also hope to get some work done on my Android File Manager today and tomorrow. My goal is to have a minimal working version ready on Monday, though it won’t surprise me if I don’t meet that deadline. Android development has been hard to jump into, and I’ll likely end up working through a few more tutorials before this file manager really takes off.