Sunday, January 11, 2015

Fixing problems with a black box application, strace

If you don't know about this command you should:

strace  - trace system calls and signals

You can see which files a specific program touches and a lot, lot more.

Here is a blog that goes into more than sufficient detail about the topic:
http://chadfowler.com/blog/2014/01/26/the-magic-of-strace/

I was trying to get Crayon Physics to work on a Linux box and the error messages were less than helpful, but I was able to make forward progress thanks to this program.

Monday, January 5, 2015

Getting Scrapy, a web crawler framework, working on Windows 8.1

First get setuptools installed to use PyPi:
https://pypi.python.org/pypi/setuptools#windows-powershell-3-or-later

This assumes you have python aliased to your instance of python in your environment:
(Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python -

https://pip.pypa.io/en/latest/installing.html

python.exe .\get-pip.py

How can I tell that I have python setup properly in my environment?
(Get-ChildItem -Path env:* | Where-Object -Property Name -Contains -Value "Python").Length -gt 0
What does this return?
How about this:
(Get-ChildItem -Path env:Path).Value.Contains("Python")

If one doesn't return true then you might need to setup python.

https://docs.python.org/2/using/windows.html


Adding to Environment:
C:\Windows\System32\SystemPropertiesAdvanced.exe

Edit Path variable and add a semicolon and your path to Python.

Running the first command is going to fail because your system probably isn't setup to run scripts from the Internet. This is probably a good thing. You can download and save the script before executing it, or change your execution policy to allow scripts from unknown sources. That last option is a mite dangerous.

You'll need to unzip it so if you've got 7zip installed you can probably do something like this:
& 'C:\Program Files\7-Zip\7z.exe' "X" .\setuptools-11.3.zip

Keeping modules in order might require something like Virtual Environments.
pip install virtualenv

http://docs.python-guide.org/en/latest/dev/virtualenvs/

pip install scrapy

if you haven't installed it already you will need PyWin32

http://sourceforge.net/projects/pywin32/