strife's devLog

SVN Log Generator based on user history

I faced with the problem of writing reports. Most of cases what I do at work is the same as what I pushed to the repository. If you still use SVN (no idea why though) then you can use this script to show all your comments in svn log in this week. It shows logs only in current week.

log-generator.py

Usage:

Example Output:

Share

Gitlab upgrading from 6.6 to 7.7 – column does not exist

Recently I was struggling with upgrading Gitlab to the most recent version.
When I did everything what they wanted, even using database migrating command.

I still could not open projects tab because of Critical Error which says.

So to fix this I just added this column manually executing following command in pgsql console.

Share

300px-Python-logo-notext.svgConverting Large XLS, XLSX files to CSV using Python

I was in troubles to convert big xlsx files in PHP because there is no such a library that could make it as good as possible. What I’ve found out were libraries that could manage xls / xlsx files but it took a lot of time and performance was horrible.

So, not spending too much time to think about it I’ve figured out to leave PHP and try to make it in Python. What I wanted to achive was converting xls files into csv and handle it in PHP.

In Python we got xlrd library that enables us to make this “crazy” thing. Here it is: https://pypi.python.org/pypi/xlrd. You can install it using pip, such like:

But for my case it was better to use VirtualENV which is better solution when someday you’d like to move your software somewhere and you forgot about installing all those stuff. However, each way you chose would be fine till it’s working.

After installing required items all you need is to run the script that converts xls into csv. I have already written simple script that can make it. Please find code below and save it to your local system setting the proper permissions right (chmod +x filename).

convert_xls.py

If you have a python script created in your local filesystem the next step would be manage it from PHP. And this is most simplest solution. Using exec, system, or shell_exec solves the problem.

OR in command line.

I know that solution is not really clean but it works. To have it more elegant I would suggest to create some kind of service in Python that handles it in a good way. I will think about it …

Note: I have also fixed issue with Long numbers in XLS.

Update
If you need to parse big XLS, XLSX files I would suggest not to make in in PHP. Just parse this using JAVA where PHP would be used only for UI.

Any questions, let me know. Please find comment form below.

Share

prestashop-logo[Prestashop] How to Debug Prestashop API?

There are severals ways to make it right. Below I described my way of testing Prestashop API using cURL as the tool that checkes all dependencies. After enabling Prestashop API in your administration panel, save the API Key.

Depends what you want to check your xml files would be different. All possibilites you can find in the Prestashop API documentation, for instance: http://doc.prestashop.com/display/PS14/Chapter+4+-+Retrieve+Data+-+Retrieving+a+Client. Most important thing here is the XML file.

In our example we will add a new product to the Prestashop API. Here is ours XML file with data.

product.xml

Save it and execute command below.

Pretashop has RESTful API so it depends on the http methods that you would be able to add / edit or remove products.

Share

prestashop-logo[Prestashop] Adding Product Thumbnail to the Order Email

Find and open PaymentModule (directory classes).
There will be line similar to this (line 381).

We are adding the new cell to this table by getting product image from the database. Below you will the code.

Share