Thursday, September 21, 2017

Drupal 7.x Search and CSS feed bugs due to extra lines

I recently noticed that the automatic css feeds that Drupal generate and the site search tool were not working on my Drupal 7 site.  After a little digging courtesy of Google this pretty old post on the Drupal community site helped me solve both problems at once.

The search function was returning an error when I searched on any term.  While the CSS link would prompt me to save or open the file in firefox rather than render a CSS page automatically.  When checking the downloaded file you could see the first line in the file was blank followed by the expected xml tags and script befinning on line 2.

Basically both bugs appear to be caused by blank lines before the opening or after closing PHP tags ( and ?>) in the module files..  In fact as best practice developers are encouraged not to include the PHP ending tag in their module files as it is so easy to save a file with one or two blank lines at the end to the file which causes errors.

A number of solutions and quick fixes are aoutlined in the linked post.  I basically dragged all my module files into my favourite text editor and visually checked for blank lines before the opening PHP tags.  Then continued to check visually that all the module files which did have closing PHP tags "?>" did not have any trailing blank lines or spaces after the tag.  In my case I found only two modules with closing PHP tags and both had blank lines after the tags.  After deleting these the bugs were solved.

To locate the module files which need to be checked they are found in the sites/all/modules/ directory.  Within each module folder check the file with the .module suffix for blank lines as described above.

Wednesday, June 12, 2013

Django, Windows7, Virtualenv, TCC/LE

Today I have been Wrestling to set up a development environment for Django 1.5.1 on Windows7 using Virtual environment.  As normal in real life there were a number of complications such as:

  • I have a number programs on my laptop which install and run different versions of Python (such as ArGIS and SPSS)
  • I had previously installed an older version of Django in one of the python installs.
These complications were compounded by the fact Virtualenv keeps loading global site packages on Windows as described here.  After a morning of searching google and stackoverflow and trying out different suggestions I found this very easy to follow guide by Jtiai which solved all my problems.

The key section that solved my conflicting python issues under virtualenv was the following configuration of TCC/LE command shell. (I wonder if you can configure cmd.exe in a similar way?).

Under working directory create subdirectory config. In this directory create startup file for TCC/LE called tcstart.btm
@echo off
rem Override system python binding to handle virtualenvironments
set .py;.pyc=python.exe
Now create (copy) TCC/LE shortcut on desktop and rename it appropriately. Open Properties for shortcut and add to Target “C:\django\config\tcstart.btm”. You probably want to set Start in to something useful, like C:\django
For the record the environment I have now installed comprises of:
  • Python 2.7
  • Django 1.5.1
  • virtualenv 1.9.1
  • TCC LE 13.0

Tuesday, August 30, 2011

How to Add Google Maps (Bing, Yahoo and Open Street Map too!) as a background in QGIS In 10 Easy Steps

Last week I wrote a short how-to tutorial outlining how to add google map satellite imagery or map layers as a background in Opensource GIS software package QGIS.  Infact the OpenLayers Plugin allows you to add data from all the major online map players, Bing Maps, Yahoo Maps and Open Street Map (OSM).

The guide was originally written for the members of the EDENext FP7 project, but is available to all, and downloadable from the EDENext Data Portal GIS Resources page.

I hope it is useful, please leave any feedback in the comments.

Tuesday, September 21, 2010

Delicious Links of the day...

Posted: 20 Sep 2010 09:21 AM PDT
Powerful data analysis from inside your favorite application. The DCOM application is a dependency for Spatial Ecologies Heospatial Modelling Environment
Posted: 20 Sep 2010 08:56 AM PDT
The replacement for the excelent Hawths Tools

Friday, August 6, 2010

My favourite thing about MyISAM MySQL tables!

One important feature that distinguish MyISAM from InnoDB is that MyISAM tables are generally binary portable. If you need to move a table from one MySQL server to the other, just copy the files from first server to the second server and you are ready to go. In some instances it’s a lot handier than using say mysqldump.
I found out my recent MYSQL backups were currupted... Only after our server had been compromised!  So I spent half a day reading up on how to try and recover data from an old MySQL  Data Folder.  Untill I stumbled across this quote hidden in one of the comments on this page: MySQL: the Pros and Cons of MyISAM Tables.

So for MyISAM tables it is possible to copy the folder containing the database table files (by default found in your MYSQL data directory eg. MySQL\MySQL Server 5.0\data\nameofschema) and paste it into the equivilent data folder of a different MtSQL installation.  of course this will work best if the installation is a similar version to the original.

Very useful to know if like me your MySQL dumps were currupted or you are foolish enough not to back up your data with a sqldump in the first place.

Thursday, August 5, 2010

How to import a Mapinfo Interchange Format .MIF to a shapefile

I downloaded some species distributions from AgroAtlas earlier which were in MapInfo MIF/MID format.  It had been years since I had to import this format to .shp to view in ESRI ArcGIS and it took a little digging to figure out how.  So I thought I would blog it so I would have it documented for next time.

First of all I checked ArcGIS for a quick win, and was disapointed.  Apparently there are two options.

  1. The first is to use the MIF to shapefile utility found in the ArcGIS8.x toolbar as documented here.  However this didn't work for me.  I got an error stating "Unable to finish conversion" and the tool only created a .shp and a .shx, with no .dbf or .prj for that matter.
  2. The second ESRI method was to buy the ArcGIS Data Interoperability Extension which seemed a little xtreme just to check out a couple of small datasets.
So I got onto google and found a third non-ESRI solution using the GDAL/OGR Simple Feature Library in FWToolsFWTools is a set of Open Source GIS binaries for windows or linux including the GDAL/OGR command line libraries.  FWTools is the easiest way to install the GDAL libraries onto windows and can be done via an installer .exe file downloadable here. Simply double click the exe file and follow the on screen installation instructions.  Once installed open up the FWTools Shell from either the start menu>programs or the desktop short cut then enter the following command:

ogr2ogr -f "ESRI Shapefile" c:\output-path-to-shapefile\mydata.shp c:\path-to-mif-mid-files\mydata.mif

That was the simple how-to example,ogr2ogr has many other parameters that can be specified click here for full ogr2ogr usage documentation.

Ogr supports multiple data formats including: ESRI Shapefile, MapInfo Tab file, TIGER, s57, DGN, CSV, DBF, GML, KML, Interlis, SQLite, ODBC, ESRI GeoDatabase (MDB format), PostGIS/PostgreSQL, MySQL.

Other references used in researching this article: