[ Home | RSS 2.0 | ATOM 1.0 ]
Simple script to get the current exchange rates from the bank of canada:
import requests r = requests.get('http://www.bankofcanada.ca/valet/observations/group/FX_RATES_DAILY/json') rates = r.json() date = rates['observations'][-1]['d'] rate = rates['observations'][-1]['FXUSDCAD']['v']
I recently setup a Roundup tracker and wanted to host it through mod_wsgi. There is an example in the installation document, but it didn't work for me, so here is what I ended up doing.
Setup my apache2 virtualhost:
<VirtualHost *> ServerAdmin email@example.com ServerName roundup.domain.com DocumentRoot /opt/roundup/site/html AddDefaultCharset utf-8 WSGIScriptAlias / /opt/roundup/site.wsgi # create some wsgi daemons - use these parameters for a simple setup WSGIDaemonProcess site-roundup user=useraccount group=useracounnt processes=5 threads=10 maximum-requests=200 umask=0007 # use the daemons we defined above to process requests! WSGIProcessGroup site-roundup LogLevel warn ErrorLog /opt/logs/roundup.domain.com-error.log CustomLog /opt/logs/roundup.domain.com-access.log combined ServerSignature Off </VirtualHost>
Set web = directive in my roundup config.ini to http://roundup.domain.com/
Created my site.wsgi file:
from roundup.cgi.wsgi_handler import RequestDispatcher tracker_home = '/opt/roundup/site' application = RequestDispatcher(tracker_home)
And that seemed to do the trick.
I needed to generate a XML file required to submit T4 income tax information to the government, and figured I'd share it incase anyone else was looking for a solution to the same problem. The XML spec isn't that complicated, but the naming convention used by CRA is rather painful to deal with. The script isn't anything special but it should do the trick and can always be easily modified. It also does the schema verification so it will warn you if there are any errors in the xml structure or data.
Here is a copy of the code, see the source file for more information.
And here is a link to the governments site with more information about filing electronically:
#!/usr/bin/env python import PythonMagick pdf = 'doc.pdf' p = PythonMagick.Image() p.density('600') p.read(pdf) p.write('doc.jpg')This sets the density value (default is 72) that the pdf is read at, so that you can get a higher resolution image from the PDF, and then simply writes it to a jpg file.