Python Incremental Backup Scripts

March 20, 2011

While interning at Honeywell, I found this small problem that I had to solve. We arent allowed to move flash drives around since they are quite a security risk to computers running Windows XP, and if you want to backup your files between a home computer and a work computer, there is really no better way than a flash drive. Given that we couldnt use them though, I had to come up with a clean solution to the probem. I tried taking differential backups with 7zip which does a pretty great job at this, bu the problem is that its “differential” is based on timestamps. The home computer runs Linux and the Office one Windows. For some weird reason, the timestamps on windows are of different precision than those on linux, so basically, the same file modified at the same time looks different to 7zip on a windows box and a linux box.

I had to come up with some kind of solution for this, so I wrote the following python scripts. One is for backing up a custom folder (say Project) and the other is for restoring the backup on another machine. These scripts take an md5 sum of the contents of the files, so timestamps dont matter.

backup.py

restore.py

The usage is simple. Just copy these scripts to the folder which contains the folder you want to backup. For example, If you want to backup D:\Games , just copy the scripts to D:\ . Now edit the scripts and change the line :-

dir_backup=”Directory” to

dir_backup=”Your Folder Name”

In the above example, that would be :-

dir_backup=”Games”

Now youre good to go. Just double click the scripts (in windows) or run the scripts from the terminal (in linux) to run the backup. When you first backup, some files will be created. Just take the scripts to some other computer and copy delta.7z and remove.txt to the same directory, and run the restore script on it. This would generate the folder you backed up in the same directory as the scripts.

From here on, you just need to run backup.py on one machine and copy the 2 mentioned files to the other and run restore.py. The scripts will make sure that everything is up to date between the folders.

As an example, suppose you have a home computer and an office computer and youre trying to backup the folder “Project”(assume we begin at home),

Run backup.py at home

Mail yourself the delta.7z and the remove.txt

Copy the scripts and the 2 files to some directory on the office comp.

Run restore.py on the office comp.

Make changes to the Project folder at office

Run backup.py at office

Mail delta.7z and remove.txt to home comp.

Copy (and replace) these files into the directory where the scripts are located.

Run restore.py

And so on…

Do comment if you have trouble understanding this!

Ministrel, your very own storyteller

December 23, 2010

Ministrel is a Qt app to read to read out story books.

Here is the github repository https://github.com/soumen08/Ministrel

The github repository has a README towards the bottom explaining the app’s usage and installation.

Get the source from here, and then follow the installation steps mentioned in the README.

If you’re interested in the latest code, you can clone the git code by doing –


git clone git://github.com/soumen08/Ministrel.git

cd Ministrel/

qmake

make

make install

Now to why I wrote the app. I love listening to my novels. It allows me to do other things while still reading the novel. I used to use espeak on the command-line before, but deleting the text till where I had read (so that I could carry on from there) is very annoying. When I learnt Qt, I figured one thing I could do with it is to simplify novel reading for myself and for the community.

Ministrel has evolved very much from how it began. The idea throughout has been to increase functionality while not compromising on efficiency. It would have been far simpler to implement Ministrel in python, but I chose C++ and stuck with it so as to get to the lightest fastest app I could.

Ministrel at this point only supports text files. People have observed that it would be better if it could also support pdfs and a few other common formats. I shall be working on that when I have the time. In the meantime, you can use any pdf reader to export the pdf to plain text. Also I recommend the Project Gutenberg website for a large collection of free books(very good ones) available in text form.

Have fun with it and drop me a line at soumen08 at gmail dot com for any queries or suggestions.

Merry Christmas!

BSNL 3G Modem (HUAWEI E156G) in Linux

December 26, 2009

Heres how to get your Bsnl 3g connection working in linux. Im going to outline a process which uses mandriva since it provides a GUI way of working through configuring an internet connection. You will however find all the relevant information you need to configure something like wvdial (a heuristic auto-dialer) to use this connection in case you want this to work on some other distribution.

First things first, ill describe the connection properties.

1) this is technically a dial up connection. there is a phone number your modem dials using the bsnl network, this is then followed by a authentication process, which results in an internet connection.

2) The phone number for BSNL east is *99# for other zones try plugging the thing into a windows computer and read the connection properties to find the telephone number.

3) The authentication protocol in use is CHAP, to know more http://en.wikipedia.org/wiki/Challenge-handshake_authentication_protocol

4) this renders a username and password inessential.

So here goes,

Right click on the network icon in the taskbar, and click configure network. When this is done, youll be promted for the root password. Enter it.

From the several types of connections you can choose select Analog Telephone modem.

This will present you with a choice of modems, select Manual Choice, then select port  /dev/ttyUSB0. In case this is not present, youre using too old a version of mandriva. The drivers for this ind of modem have been around since kernel version 2.6.20.xx so upgrade to a newer version of mandriva, 2010 is a beauty.

Now, it will present you with a choice of Telephone Number, Username, Password, and the Authentication protocol to be used. In telephone number, write *99# (or the number you read from the windows connection in case you are not in BSNL east)

Leave the username and password fields empty and select CHAP as the authentication protocol. Youre done!

press next and youre presented with DNS, etc settings, leave all of them at the default (automatic) and press finish. You might want to select allow users to manage this connection on the way.

Your network should now be connected. Enjoy!

EDIT- I had initially tried this  with mandriva 2008.1 and since ppp etc is preinstalled there, there was no problem, on 2010 however youll have some trouble since ppp etc isnt installed.

just download these and install them serially

kppp-provider-4.3.2-1mdv2010.0.i586.rpm

ppp-2.4.4-10mdv2010.0.i586.rpm

kppp-4.3.2-1mdv2010.0.i586.rpm

just do a google search for these and download them. Follow that by double clicking them, which should install them. Now you can follow the instructions starting from “Configure Network” and it’ll work.

Why I Like Flock

May 17, 2009

Okay, so ive done the thing…. Switched browsers….. As it happens, moving from firefox to flock isnt very complicated, since its really one and the same thing. Here are some of my reasons:-
1) As far as i have seen, flock seems to take as much as 100 Mb less than firefox 3.0.10
2) The default interface is cute, and the colours used are quite beautiful. In particular, i like the use of    orange. Reminds me of those days when I used to use ubuntu.
3) The Blog Editor:- Ive been considering seriously blogging again, and waiting for wordpress’s slow web interface to load isnt the best wake up call to the sleeping blogger in me.
4) My World:- While it is possible to make up for it in this that and the other way in firefox itself, I really like the integration of everything into one good page. Bravo!

Some Glitches:-
1) I have seen that the Twitter client is really minimalistic. So far as i can see, it does not have a quick way of issuing replies or directs. Does not bother me much since i use TwitterGadget inside gmail using Labs, but i can picture a few people lifting their eyebrows on the matter.
2) The default search is yahoo, and while ive tried some things, but having changed the default search engine to Google, on typing in the address bar, it still uses Yahoo! I wonder why this glitch exists? Is there a secret that the best search engine on the internet is Google?

Overall:-
Extremely Satisfactory (9/10)
Comparison
Firefox(8.5/10)
Opera(8/10)

XMMS REVIVED……

May 16, 2009

Its been a long time since Amarok has been touted as the single best media player of all time. People have gone for other things as well and it was when i saw one of my friends trying to run Winamp through Wine on Linux when i realized it was time to do something about the situation. While Amarok is one of the best media players of all time, fully featured and the like, i have never cared for it very much. Infact, while i use Mandriva Linux 2008.1 and it ships with Amarok by default and its KDE integration is fantastic,i personally prefer to use XMMS.
So some reasons:-
1) XMMS has some of the best plugins available for it. We will be going into the details of two of my favourite plugins later
2) It is low on memory use.
3) It implements completely glitch free audio, and im yet to see codecs of such quality elsewhere.

Essentially, when you begin to use XMMS, it looks and feels a bit less intuitive than Amarok’s clever and beautiful interface. The focus of this article is to customize XMMS so that it can be quite as rewarding as any other media player, maybe more. Going Stepwise:-
1) Surround Sound:
a) OSS 3D:- I had to hunt around for this plugin quite a bit and the hunt was very rewarding. It is one of the most important reasns I use XMMS.
b) Get it here:
http://www.4shared.com/file/105044469/c3cb1d9d/libxmoss3d.html
c) You need to put this in
/usr/lib/xmms/Effect/

After you have done this, close and restart XMMS, and then go to preferences (Ctrl +P) and then go to the effect tab, enable OSS 3D and click configure. Here you can set up a lot of things. While this is the demo version (no illegal stuff), its still quite good.
2) Intelligent Choices:
a) IMMS:- This is the intelligent media shuffle for XMMS. It behaves like a mind reader. Within a week, itll be playing out to you the stuff you want to listen to and the order in which you like them. It stores your choice of songs, and depending on your mood (which it senses from the kinds of songs you skip), it will put the best ones in.
b) Get it here:
http://imms.googlecode.com/files/imms-3.1.0-rc8.tar.bz2
c) No config is required, just go to the General Tab in the Preferences and enable it
3) Keyboard Shortcuts:-
a) xmms next
xmms has a CLI, meaning that it takes commands like “xmms -t” or “xmms –rev” etc to do somethings. Type man xmms to get a full idea of these things.
Then on GNOME, you can use xbindkeys (a program) to make it bind certain key combos to the player applications like next prev etc.
On KDE, simly use the menu editor to define new aplications with these commands and give them global shortcuts.
b) xmms windows:
now, xmms has a very good media library, something which with very few keypresses allows you to queue songs and search for them. This is initiated by Alt+Q. This only works when the Playlist window is active. Now, we can easily do this in KDE by specifying a window shortcut. Stepwise:
a) Preferences
b) Options Tab
c) Show Window Manager Decorations
d) Select the playlist window, press Alt+F3, select Advanced>Window Shortcut. Maybe Put in Alt+A
e) this means that coming from another desktop, you have to press Alt+(A and Q in that sequence) to get the media llibrary. Its actually quite simple. Switch desktops, hold down Alt, press A, release it and then press Q. This is just mmy personal way of doing things.
On GNOME, you cant do the window shortcut thing. Not to my Knowledge. an option is closing all windows but the playlist and then doing alt+tab when on this desktop.
That generally is all i use for xmms. If you have any questions, post back and ill be glad to share with you.

The Best Free Python IDE for Linux?

May 11, 2009

For a while, ive been using python, and since i only use Linux, ive been using it on my OS of Choice. Now, python code can be written in anything from minimalistic editors like nano, to full fledged IDEs. I prefer the functionality of an IDE over the resource friendliness of the nano like stuff. I have tried the following IDEs:

1) IDLE:- Bundled in with most python distributions on Linux, or can be easily installed from the package tool of the Distro. Simple and does the job, but i miss a lot of things in it. Code completion is at best silly, there is no class browser (AFAIKS) and running GUI apps can become troublesome, with crashes and glitches

2) SPE: Perhaps the best free one around, it has extensive integration with wxPython Related tools. Menu shortcuts for wxGlade, and good code intellisense. One of the problems i had with this IDE was that i couldnt find a python 2.6 intellisense plugin. Maybe one exists but i didnt find it.

3) KOMODO EDIT:- Komodo is a full fledged development Environment, and komodo edit is its free version. YOu can get it from the activestate website. http://www.activestate.com/komodo_edit/

and by default it has support only till python 2.5. To add support for 2.6 visit this webpage and follow the instructions

http://community.activestate.com/forum/support-python-26-and-30-eventually-auto-complete

Now you will have komodo edit and autocomplete as well. If you want to run a written program, you can press Ctrl+R and then set the path accordingly. In general write

python %F

Hope you have a good time editing with komodo edit

Comments are welcome

Bye!

Fingerprint sensor in linux(debian and such like) (HP6515b)

June 14, 2008

this is it- the fingerprint sensor on my linux is working (and it will work on urs too if it is a debian based system)

I followed this walkthrough:
http://blog.irwan.name/?p=471

There still are some issues i outline them for others to solve (i’m also working on them)

1) Segmentaion fault:- Occurs on multiple sudos. after logging on open a terminal and write

sudo gedit

it says

scan yur finger

do it

It opens gedit as root(u can save a text file in gedit or edit the config files in /etc)

now close the gedit window

and type again

sudo gedit

it should say

scan ur finger

but it says

segmentation fault

2)gksu (no visuals) again after logging on open synaptic through the menus and …..

(Nothing happens)

u just see a revolving cursor now just scan ur finger..

u see

Synaptic

So thats the point no visual prompt

Also a suggestion some login themes are incmplete that is they have no message boards so i suggest using happy gnome with browser so u wont have to keep typing the username plus u can see what is happening.

happy swiping and feel free to post comments…..

Walkthroughs for Hardy on HP6515b Laptops

April 27, 2008

Anyone who has used linux for any length of time knows that the two things which are often difficult to set up are networking and (well….) 3d effects.

This is a step by step guide to getting it all working on the box i call my computer:

WiFi

We are going to use ndiswrapper to configure the Windows XP driver for the Broadcom BCM4312 chip we have on this computer. so we need the windows XP drivers bcmwl5.inf and ndiswrapper (both are available freely just google) once you have these here’s what to do:

1) install ndiswrapper and ndiswrapper utilities from the .deb packages u have

2) fire up a terminal and navigate to the directory where u have the driver.

3) Type

sudo ndiswrapper -i bcmwl5.inf

4) and then type

sudo ndiswrapper -m

5) this would say that it is writing ndiswrapper to module alias wlan0.

6) now in a terminal type

sudo gedit /etc/rc.local

before the exit 0 line in this file, put the following 2 lines-

rmmod ssb

modprobe ndiswrapper

7) save and quit.

8) restart the comp. and u will find wifi working.

3d effects

1) I assume u have internet on the box if u have followed the last steps u should have it by now.

2) Open Synaptic Package Manager from System >Administration

3) Click reload if u haven’t already done so after the install. This can take some time and u must be online for this to complete.

4) Once the repositories are refreshed, find the package xorg-driver-fglrx in the list and install it.this can again take some time.

5) Once this is installed go to Syt=system>ADministration and click hardware drivers. Now click on Enable to enable the ATI Graphics driver. Close the window and restart the comp.

6) After this is done open system preferences appearance and click on visual effects

7) Click Extra.

8) 3d effects are working! Now u need compiz so open synaptic and find a package called compizconfig-settings-manager

9) Install this and u can now configure the kind of effects u want from system preferences and Advanced Desktop Effects.

My Setup

April 27, 2008

Hello! I tink it is time to Update on my setup. I have an HP6515b Laptop and very few brains… With these limited resources i spend time having fun with my computer and enjoying life in general. My comp. is a real problem though.. Half the things on it were not supported on Linux, my favorite OS until recently leading to myself spending a lot of time thinking of workarounds to get simple stuff like internet working… All that has changed with the latest and (arguably) best from linux’s stable of OSes Hardy Heron. It brings integrated hardware support to my computer making it easy to setup and fun to use.

The First Post

April 27, 2008

Welcome to my blog, I am Soumen Banerjee. This blog is primarily going to be technical and based on computers and i plan to have a good time with it. I hope you like it in the days to come….