Tag Archives: python

Update PIP on Ubuntu

From SO answer

Your pip may be outdated. Even in Ubuntu 14.04 LTS, the pip version it installed using apt-get install python-pip was 1.5.4. Try updating pip manually, and possibly the new packages again as well.

pip --version # 1.5.4
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
hash -r # reset bash cache
pip --version # 6.0.8

The hash -r line is essential!

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

Similar Posts:

Tagged , , , ,

RimuDNS python module

I wrote previously about building dns zone files mostly by querying DNS and saving the results to a file.

The method is not perfect, and it will not be possible to get all the records. In fact, you could get all the records incorporated in the result file if you already have a list and feed it to your code.

I wrote a python module to manage DNS records using the RimuHosting DNS API. The code is hosted at GitHub.

I also added a guessing feature.

Similar Posts:

Tagged , , , ,

Django-TimelineJS Pluggable App

I like VeriteCo’s TimelineJS. It’s elegant, easy to use and very useful. I don’t like editing Google a google spreadsheet every time I want to update the timeline although it might be easier for some people. So, I wrote a small pluggable app for django to embed a timeline in django templates.

The code is loosely based on the code for the WordPress plugin. And I’ll try to copy over more code and fixes from that soon.

For now, it’s a working app with an admin backend to enter the timeline information and events, and to edit the options. It’s also a custom template tag that you can use to embed the timeline in your own templates.

Should be easy enough to use it.

pip install django-timelinejs

then include it in your INSTALLED_APPS and ./manage.py syncdb

Drop me a note if you find a bug or want some help. You can use the issues in GitHub for that.

Similar Posts:

Tagged , , , ,

Building DNS Zone Files

The only way to get a full listing of a DNS zone is to use AXFR to request a zone transfer. But that’s usually locked and not available. So building the zone file for a domain is basically guesswork or manual labour at best.

For some background information check out these questions on SO
Here’s a script I wrote to try and automate that as much as possible. Still in beta. Suggestions welcome.

Note: I use DNSPython

Next on my list is using the RimuHosting/Zonomi API to create/import the DNS zone.

Similar Posts:

Tagged , , , , , , , ,

NatGeo Wallpaper Downloader & Desktop Changer for Gnome Shell

I saw a couple of National Geographic wallpapers and those are pretty nice. I did not find an API on their site to download those on a regular basis, but it seemd pretty simple to just download them.

I just uploaded my code as a gist per https://gist.github.com/3002699 (the gist code should be more up to date than the following code)
And I added the script in my crontab:

@daily	/home/abdallah/Code/scripts/natgeowallpaper.py

Let me know if you have any notes/comments/changes
Here’s the code

Similar Posts:

Tagged , , , , ,

Django uWSGI and Nginx on Ubuntu 11.10

I’m working my way through installing my simple django app on a new Ubuntu machine using the components mentioned above.

So far, here’s what I’ve done:

  • apt-get install nginx-full
  • apt-get install uwsgi uwsgi-plugin-python
  • installed django from svn described in the docs

The nginx configuration can be found in /etc/nginx/sites-available/default. Of course, it’s best to make a copy of that file and edit it for the site/app I’m working on. Here’s what I put in it:

server {
    listen   80;
    server_name sss.grat.in;
    access_log /var/log/nginx/sss.grat.in-access.log;
    location /media {
        alias /home/sss/app/media/;
    }
    location /static {
        alias /home/sss/app/static/;
    }
    location / {
        uwsgi_pass unix:///var/run/sss.grat.in.sock;
        include uwsgi_params;
    }
}

Now for the uWSGI configuration file. I created the file /etc/uwsgi/apps-available/sss.ini and added the following lines:

[uwsgi]
chdir = /home/sss/app
pythonpath = /home/sss
env = DJANGO_SETTINGS_MODULE=app.settings
# load django
module = django.core.handlers.wsgi:WSGIHandler()

it’s really just that. What took me so long was to figure out that in Debian/Ubuntu you have to install uwsgi-plugin-python, otherwise you’ll keep on getting weird error messages. Also, the default ini file has most of the settings (in /etc/default/uwsgi) so you should either read or edit that to make sure you’re getting all the right values.

Similar Posts:

Tagged , , , ,

Site ScreenShot Part 2 – Planning

I was having a little conversation with my friend Ghassan from LebanonDesign and he mentioned his company was actually using something similar to SiteScreenShot to generate thumbnails for their different websites. So I thought I could scale my code to do the same. Of course, plenty of changes should be considered:

  • Snapshot generation currently takes 3-5 seconds to complete. So I need to do 2 things:
    • Tell the user that the app is actually working on generating the snapshot
    • Provide a way to retrieve the pic once the snapshot is generated
    • Make things go faster if possible
  • Getting more users means more load on the server, what should we use?
    • Replace Apache with Nginx for faster static file delivery
    • Use a queue manager like Celery/RabbitQM to distribute the load

I’m currently testing some code with django-celery and I’ll try to post more information here (so I can remember what I’m doing)

Also on my list is making the site accessible via a simple API.

I also need to research a better way to take the screenshots on a headless server.

[adsenseyu3]

Similar Posts:

Tagged , , , , , ,

Site Screen Shot

Last week my friend Fernando Duran posted a note about his Site2Pic weekend app. It sounded like a great idea, so I asked Paypouy to cook up a simple design and wrote my own version using django and a few other open source libraries.

[adsenseyu2]

My app now lives at SSS.GRAT.IN

Take it for a spin, and tweet me @abdallahdeeb if you like it 🙂

Similar Posts:

Tagged , , ,