Heartfelt Thanks to my family, mentors and friends I have come across so far!
Definitely a moment that I would love to cherish for lifelong :).
Heartfelt Thanks to my family, mentors and friends I have come across so far!
Definitely a moment that I would love to cherish for lifelong :).
Few days ago I was asked to take the first guest session at DGPLUG summer training 2016 about my journey in FOSS, Python and DGPLUG. I became super excited after hearing that and also it was the first guest session of DGPLUG summer training 2016. It was really unexpected :). The next day I took the session at 18:30 IST on #dgplug channel on IRC.
I started with little introduction about me and let the participants ask Questions after that. The whole session went really interactive. They asked smart questions despite being newbies :).
The mostly asked Questions were How I started my first upstream contribution, How did I select the project I worked on for the first time, What do I do when I am stuck at an issue, How do I manage time to contribute along with my studies, How FOSS helps in career, Steps to contribute in a better way and all.
I really enjoyed answering all kind of Questions those were asked.
You can join the summer training still now. Join #dgplug channel on IRC and the Mailing list. Fill up the form and ping Kushal Das. Feel free to ask if you have any query on IRC or Mailing list. You get this golden opportunity only once a year, so don’t miss it.
The IRC logs are uploaded here. You will find all the conversations here https://dgplug.org/irclogs/2016/Logs-2016-07-01-15-00-trishna.txt.
It feels amazing to be a part of such a great community :).
If you can’t reproduce the bug you would never know where the bug is!
I realized exactly the same when I have been working on a bug of Bodhi. We were pretty clueless about why the bug has arrived. After working on it for long I now believe that I am able to figure out where the bug is, Though the work is still going on. But we are pretty closer to it now. The current state is https://github.com/fedora-infra/bodhi/issues/855.
If we were not be able to reproduce to the bug we would never know why the bug had arrived and believe me it was not really identifiable this time! So before working on patch for a bug we should always try to reproduce it first.
Why Reproduce Bugs?
If you can’t reproduce the bug you would never know where the bug is. Patch doesn’t work just on guess. You are expected to be failed to create a patch if you fail to reproduce the bug.
If you don’t go through the steps when the bug is arrived it is technically impossible to create a patch. After you know why the bug has arrived it is possible for you to fix it as well. If you can’t reproduce the bug you need to create a patch just guessing the issue and you are not sure whether it is going to work or not! So it is not considered as a good practice. Make sure you are not wasting your time on creating patch about which you are not sure.
Good Bug Reporting: Generally a good bug report contains all required info like when the bug has arrived, what was expected to happen and what has actually happened.
There are bugs about what we have no idea why they have occurred neither the users nor the developers. But the developers can always figure it out by reproducing the bug i.e, creating the same situation(In non-technical word). We will now see How Can We Reproduce Bugs.
How To Reproduce Bugs?
Unittest is one of the certain ways in order to reproduce bugs. I will show a simple demo.
We will write a simple program to check whether a number is odd or even.
Write the code:
Write the test:
Test is supposed to fail since 6 is an even number. Now we will see what happens:
Now we know why the error has occurred. In order to reproduce bugs we always want our test to fail.
This is just the fundamental of unitesting on reproducing bugs. You will know more when working on real world projects.
We can use Pdb also. Check this to see how you can use it.
For Bodhi I have used unittest and mock testing. Here is the testcase I wrote to reproduce the bug I mentioned above: https://paste.fedoraproject.org/386958.
First of all I want to convey my thanks to Shakthi Kannan(mbuf) for such an amazing book. It’s undoubtedly a perfect and great guide if anyone wants to get started with open source contribution and its workflow.
It all started when I was writing testcases for Fedora Cloud Image(tunirtests). I was having discussion with DGPLUG folks since I was facing problem to set up a testcase and mbuf suggested me to take a look at the testcases given in his book i want 2 do project. tell me wat 2 do. I ordered the book the very next day.
The book is divided into ten chapters where each and every chapter is divided into some subsections. When a beginner wants to get started with open source contribution Internet provides him/her with top links for getting started with open source contribution which generally contains upstream links and procedure of how to contribute. But open source/FOSS projects have its own workflow, own communication guidelines, own development guidelines, important tools used and all which a beginner is not usually aware of. And the beginners generally face problems to get started with these things at their first phase. So this is the book that covers everything from mailing list guidelines to project communication & its guidelines, development procedure & methodology of work, how to submit patches to upstream projects, how to talk or represent an issue you are stuck at to your mentor or people on IRC or mailing lists, tools used in FOSS, presentations and so on.
This book introduces us to all the terminologies related to FOSS. It beautifully explains what to do and wat not 2 do in the world of Internet and FOSS. I would like to suggest you to carry this book with you where ever you are, because it has answers to all your questions/queries when you are working on an open source project. You need it all the time 😉 .
I have learned about a lot things and terminologies after reading the book. This book has helped me a lot and will continue to do so. Thank You mbuf for such a great book 🙂 .
Why is writing tests for your code as important as writing code for your product?
We write Tests to check/test:
So it’s better to catch the bugs of your code before it reaches to others 😉 .
I was working on fedora-bodhi for last few days and I chose an issue from there to work on. Though it looked simple enough but it really needed some tricks to solve the bug. The interesting thing is that it was not clearly visible that we have to apply some tricks to solve the issue. And I came to know that I had to apply some tricks after I wrote tests for the code I added.
- When an update of a build in bodhi is ‘pending’ and it requests for ‘testing’ and if that request is revoked, the status of that build should be set to ‘unpushed’.
- When an update of a build in bodhi is ‘testing’ and it requests for ‘stable’ and if that request is revoked, the status of that build should be set to ‘testing’.
I pushed a patch for it accordingly and received positive comment from threebean 🙂 . Then threebean and lmacken told me to write test for it, because “Sometimes what we see is not the truth!!” . If you look at the patch it really seemed to work. But when I wrote test for the code I added, the test was failing. As pingou suggested I tried printing some debugging statements to make sure if the test is exercising the code I added. Hence I came to know that the test is not going through the code :|. After struggling for a day I catched that my code was conflicting here which also has action ‘revoke’.
Now I strongly feel why writing test is as important as writing code and testing makes you write better code as well 🙂 . The earlier patch was not behaving the way it was expected to behave. I wouldn’t realize that my earlier patch would fall if I didn’t write tests for it and if that patch would be merged the bug would be realized after it reached to masses. So isn’t it a smart practice to catch bug of your code by writing tests before it reaches to masses? 😉
AutoShare automates sharing of video url with its title on facebook wall when the video is uploaded on YouTube. It took me about a couple of days to make AutoShare finally work. I have used Python 3. You might be wondering that how the idea came to my mind. Let me share the story with you 😉
My mom has her own channel on YouTube. So she has to share the videos on social networking platform like facebook and others everytime she uploads them on Youtube. So I thought of a way if I can automate the task! Life is awesome when we can automate almost everything, atleast for me 😛 so why not this 😉 .
AutoShare is really easy to use. You just have to get your PlaylistId from Youtube channel list and your google API key from console developer google. Check Youtube-settings for AutoShare to know in details. Then obtain your Access token from facebook api explorer. Check Facebook-settings for AutoShare to know in details. After obtaining the google API key, youtube PlaylistId and facebook Access token, fill them in settings.py. Make sure you have requests module installed and run the app with
Check the installation procedure here.
I have used requests and json modules to make AutoShare work. Using get method I have retrieved the data regarding the latest video uploaded and generated the url and title of the video which you will find in youtube_url_generator.py. You will find the code regarding posting in autoshare.py. I have retrieved the posts of facebook wall and run a check to make sure whether the post has already been shared or not. This will prevent you making duplicate posts on facebook wall. And if there is no such post on your facebook wall AutoShare posts the video title along with the url on your wall.
So this way we can easily automate the sharing of video on facebook wall when uploaded on Youtube. Test cases for the application are in progress. Then I’ll cut a new release :). Please do let me know if you get any issue or have any new idea. Feel free to open issues here and you can also come up with pull requests for modifications. Thank you 🙂
This post not only explains how I got started with Tunir but also how I got started with unittest. My first unittest cases started with fedora cloud images.
It was a nice evening before Diwali. Kushal told on #dgplug that he needed new volunteers for Fedora Cloud SIG. Though I was totally clueless about cloud but I showed interest to join in because I would be able to learn something new and exciting. Next day, I and Farhaan had discussion with Kushal and he showed us how to write Python 3 unittest for Fedora cloud images (including atomic images).
Let me tell you about Tunir first. Tunir is a simple continuous integration system that helps us run automated test for cloud images. I would want you to visit Life Of Tunir which amazingly explains why we need Tunir and how it works.
So the aim is to convert manual testing into automated testing. Kushal gave us some shell commands and we convert them into Python 3 unittests. I have currently worked on NonGatingtests for cloud images. And this way I learned how to write unittest. I can run test for qcow2 cloud base image and atomic image. I have the images in my local machine. I just have to start the local server and follow the required steps to test the images. Whenever I got stuck at any test case Kushal and Rtnpro helped me a lot, Thanks to them 🙂 .
My code runs. But I didn’t ever think to care about whether it is clean or not. You might be wondering that why suddenly I have decided to write on this topic. Let me explain you the story.
I was going through badges of fedora and logged in to my account. And when I tried to view my profile as RDF it raised an Internal Server error. So I pinged Pingou on #fedora-apps about the issue and he told that the issue has already been reported. Since it was an internal server error I decided to run tahrir from my local host to know the reason behind the error(Though Ralph Bean has already commented the traceback on the issue later). And I followed README of tahrir to install tahrir for development purpose. There also I found some bugs, thus I sent a PR which was later merged. While initializing tahrir
$ initialize_tahrir_db tahrir.ini
I started getting traceback from dependencies. There was around 15 dependencies which threw traceback and I was like tahrir would not be working on my local machine 😛 . I finally installed all the dependencies with
$ pip install
$ pip freeze > requirements.txt
and sent a PR and asked Pingou & Threebean to review it. Pingou told me that requirements.txt contains all the dependencies those were installed on my virtualenv during setting up tahrir. It is not like tahrir requires all the dependencies listed in the requirements.txt to be installed on your virtualenv rather it needs only few of them. Well it can be explained like this
” If tahrir requires dependency A and installing A requires dependency B , then you do not need to include B as requirement. It will be dragged automatically while installing the dependency what you actually depend on which is A” — Pingou
Awesome lesson learnt! Hence I only needed to add requests and set an upper bound to rdflib. Thus I closed my PR and sent another PR to fix traceback. Though we were still getting traceback from twisted. As discussed with Pingou and Threebean on irc we realized it was an moksha.wsgi issue which was later fixed by Threebean. And now we won’t be getting any traceback when hacking tahrir.
And I learned that we really don’t need to include unnecessary things in code that makes it look bad. Not only running our code successfully but we should also care about keeping it clean and good. Thanks to Pingou and Ralph Bean for giving me such a wonderful lesson. You people really made my day 🙂 . My day ended with earning a developer badge from fedora. Now I am trying to work on the issue and reading the codebase of rdflib. Because for the version of rdflib<4.x there was no internal server error. Only for rdflib>4.x there comes an internal server error. So there must be some change in rdflib source code which is raising the Assertion error in tahrir . Wish me good luck friends 😉
Anyway enough of talking. I should stop writing now 😛 See ya!
I have recently fixed an issue of bodhi(python-fedora) of fedora-infra. This is my first bug fix in fedora. fedora-infra consists of infrastructure applications, building tools, utilities and creating new applications to make fedora development a smoother process. kushal told us to open a FAS account to contribute for fedora and provided some links including an easyfix link for beginner. So thanks to kushal and dgplug for making it my first fedora contribution ^_^ . whatcanidoforfedora has lots of options to get started with fedora contribution. The channel #fedora-apps is a perfect channel to get started with fedora-infra contribution.
Looking forward to contribute more to fedora :).
Keep an eye on mygithub to stay updated with my open source contributions ;).
I am pretty sure that you are wondering why such a title!
Tell-me-more is a command line tool built using Python3 that provides information about the linux user and the system. The tool displays the users of the system, the current user who is logged in the system, and the memory information.
To run the tool follow README .
git clone https://github.com/trishnaguha/Tell-me-more.git
python3 main.pywith argument
python3 main.py -hfor help
Finds the users
def bash_users(): with open('/etc/passwd', 'r') as fobj: f = fobj.readlines() pattern = '/bash' for i in f: m = re.search(pattern, i) #searches if the given pattern is in i if m: print("%s" % i.split(':')) else: pass
Finds details of the memory of your system
def memory_details(): with open('/proc/meminfo', 'r') as fobj: f = fobj.readlines() pattern = '^Mem' #All the strings starting with Mem for i in f: m = re.search(pattern, i) #searches if the pattern is in i if m: print("%s: %d MB" % (i.split(':'), int(i.split())/1024)) #Displays the memory in unit MB else: pass