Tuesday, July 31, 2018

Downloading files that were previously uploaded using dropzonejs

Dropzonejs (https://www.dropzonejs.com) is a plugin that allows users to upload files to your website. However, it does not appear to support the downloading of files. Thankfully, adding support to download files by clicking on the preview button is not too difficult:

                $(mockFile.previewElement).on("click",
                    (function (uri) {
                        return function () {
                            window.open(uri, "_blank");
                        }
                    })(uri));


Saturday, March 24, 2018

Windows 10 WHEA_UNCORRECTABLE_ERROR on first boot

Having installed the latest Windows 10 updates, my rather dated (10 year old) machine has been crashing on the first boot with the not-too-informative WHEA_UNCORRECTABLE_ERROR. Subsequently, it would remain stable till the next time the machine was shutdown and started. This led me to suspect that perhaps my machine's drivers which are no longer updated by the manufacturers are having compatibility issues with Windows 10. In particular, the Fast Startup feature may be causing this error. After disabling the feature, the error has not occurred. Hopefully, these steps will help you too:
  1. Click on the Start button.
  2. Type power.
  3. Click "Power & sleep".
  4. Click "Additional power settings".
  5. Click "Choose what the power buttons do".
  6. Click "Change settings that are currently unavailable".
  7. Uncheck "Turn on fast startup (recommended)".

Wednesday, February 17, 2016

Continuous integration with Python on TeamCity

Here is how we can configure TeamCity 9.1.3 (build 37176) to perform continuous integration on Python 2 projects. I assume that you have already installed Python 2 (2.6 and above), virtual-env, TeamCity, and have access to your code in a version control system. Unit tests written in Nose seem to work well in TeamCity.

  1. Create a virtual-env on the server hosting your TeamCity installation. 
  2. Install teamcity-messages in your virtual-env.
  3. Create a new project in TeamCity. See this page for more details.
  4. Setup your VCS root(s). This may not be the best approach, but for dependent Python projects, I create VCS roots for every dependent projects so that all dependencies are satisfied within the project. You may have to define VCS roots in a parent TeamCity project if they are shared among several dependent projects.
  5. Create a build configuration.
  6. Attach relevant VCS roots in the "Version Control Settings" page.
  7. Create a new build step with "Command Line" as the runner type.
  8. Enter the script content so that you invoke your virtual-env's nosetests.exe.
  9. Add a new trigger in the Triggers page.
  10. You can manually schedule a build now or wait for TeamCity to build automatically.

Thursday, February 4, 2016

Setting up a Python development environment for ArcGIS


I use Intellij IDEA 15.0.3 with its Python plugin to development spatial analysis platforms using ESRI ArcGIS libraries. Although the ESRI licenses are not free, I have found them to be good investments given the ease of performing spatial analysis and managing GIS datasets. For this tutorial, I will use PyCharm Community Edition instead of the full-fledged Intellij IDEA. You will need to have ArcGIS installed already. If you wish, you can also install the separate 64-bit geoprocessing package. ArcGIS 10.3 uses Python 2.7.
  1. Download PyCharm IDE.
  2. Install PyCharm IDE.
  3. Start PyCharm IDE.
  4. Create New Project. If you have existing interpreters, choose the one that was installed by ArcGIS.
  5. Open File-Settings (or Ctrl+Alt+S).
  6. Click on Project Interpreter.
  7. Click on the gear icon (near the top right corner of the window).
  8. Select "Create VirtualEnv". This will give you a separate Python environment for each project.
  9. Give the virtual environment a name and location.
  10. Check "Inherit global site-packages".
  11. Click OK to clear the Settings windows.
  12. Go to the Project window.
  13. Right-click on "MyFirstArcpyProject".
  14. Select New-Python File.
  15. Call the new Python file "ExtractSpatialData.py".
  16. Go to your ArcMap or ArcCatalog's geoprocessing results frame.
  17. Right-click on the operation that you want to reuse.
  18. Click on "Copy As Python Snippet".
  19. Go to the PyCharm window.
  20. Paste the clipboard contents in ExtractSpatialData.py.
  21. Go to the top of the file.
  22. Add the line "import arcpy".
  23. Add the line "arcpy.env.workspace = <path to your datasets>".
  24. Run ExtractSpatialData.py (Ctrl+Shift+F10).
Instead of setting arcpy.env.workspace, you can also use the full path name to your input, clip, and output feature classes. If you are using extensions such as spatial analysis, you will need to checkout the license, e.g. arcpy.CheckOutExtension("Spatial"). See checkoutextension for more details.

Sunday, January 17, 2016

Deploying Bonobo GIT Server on Windows Server 2008 R2

Moving from SVN to GIT, the first thing that I wanted to do was to set up a GIT server on my Windows Server 2008 R2 machine. I chose to use Bonobo GIT which is currently a free and open-source project. Given that Bonobo GIT's installation guide worked well generally, I will only highlight the missing bits in the tutorial, i.e. things which I had to do differently to get things working.

Prerequisites

Before deploying Bonobo GIT Server, the following three components are required:

  1. IIS 7
  2. Microsoft .NET Framework 4.6. I did not have to uninstall my existing .NET framework 3.5.1. On the other hand, .NET Framework 4.5 complained that it or a later update was already installed (even though it was not). Version 4.6 worked fine.
  3. ASP.NET MVC 4. After installation, open a command prompt window as an administrator to run the following command: %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -ir


Changing ports

If you need to the default IIS web site to listen on a port other than 80:

  1. Right-click on "Default Web Site".
  2. Choose "Edit Bindings".
  3. Click on the row with http type.
  4. Click on the "Edit..." button.
  5. Enter your preferred port number, e.g. 8080.



Installation


  1. Unzip the downloaded Bonobo GIT Server file into your IIS directory, e.g. C:\inetpub\wwwroot.
  2. Give your IIS_IUSRS group permissions to Modify and Write to C:\inetpub\wwwroot\Bonobo.Git.Server\App_Data folder.
  3. Convert Bonobo.Git.Server to Application:
  4. Set the Application Pool to ASP.NET v4.0:
  5. Click on the Test Settings button. You will see the following error:
  6. That error message can be ignored. If you really want to remove that error, you can create a user in the Administrator group and connect as that user. However, I avoided that because it grants unnecessary administrative access.
  7. Instead, go to IIS-Authentication:
  8. Double-click on Authentication:
  9. Click the "Edit ..." link on the right:
  10. Choose Application pool identity and click OK.
  11. Test your deployed GIT server by visiting its home page, e.g. http://localhost/Bonobo.Git.Server/. You may need to append the port number, e.g. http://localhost:8080/Bonobo.Git.Server/
  12. Change your admin password. The default username and password are both admin.