# ankursinha.in/blog

neuroscience/fedora/musings

Tue 19 April 2011

# Automating creation of free-media envelopes

Posted by ankur in Tech (437 words, approximately a 2 minute read)

I've accepted a lot of requests this month. It's because Rahul sent me 100 fedora 14 DVDs which I could use! (Thanks Rahul!!)

I'm lazy, and I really didn't want to write out the addresses by hand, so I ran around looking for ways to automate it. I've come up with something. It isn't anywhere near perfect, but it works, and generates the free-media mailer envelopes for you with addresses, so you can print them, cut them, insert the dvd, and send them! (I haven't come up with an idea to automate the cutting/folding/inserting/sending yet, got any ideas ? 3:) )

Here goes:

1. Log on to http://fedorahosted.org/free-media with your credentials.
2. Go to "view tickets > custom query". The custom query by default shows tickets owned by you. Check the "Show full description under each result" and "update" the page. It will now show your tickets with their addresses.
3. Go to the bottom of the page and download the RSS-feed. (Is there a process of automating this portion? If you have something, let us know!!)
4. Download it to a known location. Preferably make a new directory for this work.
6. Run the script on the downloaded xml file (./script.sh query.xml) . You will get a file with the extracted addresses called adds.txt
7. Manually check the formatting of the addresses. (There are some lines that are pretty long, and go off the front of the envelope. This can be automated too, maybe later.)
8. Download this cpp file, compile it so : ( g++ free-media.cpp -Wall -Wextra -W -pedantic -O2  -o free-media)
10. Run the programme: ./free-media png file> adds.txt
11. You would now have different pngs filled up with both the sender's and receiver's address!

It looks huge doesn't it? 11 steps is a lot of work. What you need to notice is that most of these are one time steps. From the next month, all you need to do is download the RSS feed and run the script and the program (ONLY!)

Points to note: You need to have the "convert" command on your system. It's in the "ImageMagick" package.

If this doesn't work for you, please drop me a mail at ankursinha AT fp.o or find me on the IRC at #fedora, #fedora-ambassadors, and I'll help you out!

Have fun. Remember to send your two media a month :)

EDIT:

So a src file that says:

Ankur Sinha
I live in this street,
I live in this town,
PIN 0000000
This is the country.
=
Will give you this envelope!