Monthly Archives: February 2014

Mediawiki-vagrant is tough to be tamed in your local machine

I am a newbie in php and my next task i have to build a mediawiki extension that will embed the datagrepper messages in wiki user profile. Even setting up the mediawiki environment became a tough job for me. But I have managed to do so and now i am going to share the installation steps.

How to install Mediawiki-vagrant?

1. Install git
2.  Get virtualbox

First install the dependencies:

$ sudo yum update

$ sudo yum install binutils qt gcc make patch libgomp glibc-headers glibc-devel kernel-headers kernel-devel dkms

Now, install VirtualBox:

$ sudo yum install VirtualBox-4.3

3. Download the latest version of vagrant.

4.  Get the code and create your machine:

$ git clone https://gerrit.wikimedia.org/r/mediawiki/vagrant
$ cd vagrant
$ vagrant up
[charul@localhost vagrant]$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Clearing any previously set forwarded ports...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 8080 (adapter 1)
[default] Running 'pre-boot' VM customizations...
[default] Booting VM...
[default] Waiting for machine to boot. This may take a few minutes...
[default] Machine booted and ready!
[default] Configuring proxy for Apt...
[default] Configuring proxy environment variables...
[default] Configuring proxy for PEAR...
GuestAdditions 4.3.6 running --- OK.
[default] Setting hostname...
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
[default] -- /vagrant/logs
[default] -- /tmp/vagrant-puppet-1/manifests
[default] -- /tmp/vagrant-puppet-1/modules-0
[default] VM already provisioned. Run `vagrant provision` or use `--provision` to force it

As there is a proxy behind my internet connection, i  had to install  vagrant-proxyconf plugin.

$ vagrant plugin install vagrant-proxyconf

Then i configured proxy by adding the following lines to $HOME/.vagrant.d/Vagrantfile (or to the project Vagrantfile)

Vagrant.configure('2') do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
    config.proxy.http     = "http://username:password@proxyhost:port/"
    config.proxy.https    = "http://username:password@proxyhost:port/"
    config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
end
# ... other stuff
end

After this,

$ vagrant provision

For the first time I got this output which wasn’t correct. 😦

[charul@localhost vagrant]$ vagrant provision
[default] Configuring proxy for Apt...
[default] Configuring proxy environment variables...
[default] Configuring proxy for PEAR...
[default] Running provisioner: puppet...
Running Puppet with site.pp...
info: Applying configuration version '1392325515.9dbe0e1'
info: mount[files]: allowing mediawiki-vagrant access
notice: /Stage[main]/Mediawiki/File[/vagrant/settings.d]/mode: mode changed '0775' to '0755'
err: /Stage[main]/Redis::Php/Package[php5-redis]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install php5-redis' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package php5-redis
err: /Stage[main]/Mediawiki::Phpsh/Package[phpsh]/ensure: change from absent to 1.3.3 failed: Could not update: Execution of '/usr/bin/pip install -q phpsh==1.3.3' returned 1:   Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement phpsh==1.3.3
No distributions at all found for phpsh==1.3.3
Storing complete log in /root/.pip/pip.log
at /tmp/vagrant-puppet-1/modules-0/mediawiki/manifests/phpsh.pp:14
notice: /Stage[main]/Mediawiki::Phpsh/File[/etc/phpsh/rc.php]: Dependency Package[phpsh] has failures: true
warning: /Stage[main]/Mediawiki::Phpsh/File[/etc/phpsh/rc.php]: Skipping because of failed dependencies
notice: /Stage[main]/Apache/Service[apache2]: Dependency Package[php5-redis] has failures: true
warning: /Stage[main]/Apache/Service[apache2]: Skipping because of failed dependencies
notice: /Stage[main]/Mediawiki/Exec[check settings]/returns: executed successfully
info: /Stage[main]/Mediawiki/Exec[check settings]: Scheduling refresh of Exec[mediawiki setup]
notice: /Stage[main]/Mediawiki/Exec[mediawiki setup]/returns: executed successfully
notice: /Stage[main]/Mediawiki/Exec[mediawiki setup]: Triggered 'refresh' from 1 events
notice: /Stage[main]/Mediawiki/Exec[configure phpunit]/returns: executed successfully
notice: /Stage[main]/Mediawiki/File[/usr/local/bin/run-mediawiki-tests]/ensure: defined content as '{md5}6b154f733a6f77b5728e480b2714fe72'
notice: /Stage[main]/Mediawiki/Exec[require extra settings]/returns: executed successfully
err: /Stage[main]/Git/Package[git-review]/ensure: change from absent to 1.23 failed: Could not update: Execution of '/usr/bin/pip install -q git-review==1.23' returned 1:   Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement git-review==1.23
No distributions at all found for git-review==1.23
Storing complete log in /root/.pip/pip.log
at /tmp/vagrant-puppet-1/modules-0/git/manifests/init.pp:32
notice: Finished catalog run in 69.08 seconds
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

FACTER_fqdn='mediawiki-vagrant.dev' FACTER_forwarded_port='8080' FACTER_shared_apt_cache='/vagrant/apt-cache/' FACTER_provider_name='virtualbox' FACTER_provider_version='4.3.6' puppet apply --templatedir /vagrant/puppet/templates --verbose --config_version /vagrant/puppet/extra/config-version --fileserverconfig /vagrant/puppet/extra/fileserver.conf --logdest /vagrant/logs/puppet/puppet.9dbe0e134.log --logdest console --modulepath '/tmp/vagrant-puppet-1/modules-0' --manifestdir /tmp/vagrant-puppet-1/manifests --detailed-exitcodes /tmp/vagrant-puppet-1/manifests/site.pp || [ $? -eq 2 ]

Stdout from the command:

info: Applying configuration version '1392325515.9dbe0e1'
info: mount[files]: allowing mediawiki-vagrant access
notice: /Stage[main]/Mediawiki/File[/vagrant/settings.d]/mode: mode changed '0775' to '0755'
err: /Stage[main]/Redis::Php/Package[php5-redis]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install php5-redis' returned 100: Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package php5-redis

err: /Stage[main]/Mediawiki::Phpsh/Package[phpsh]/ensure: change from absent to 1.3.3 failed: Could not update: Execution of '/usr/bin/pip install -q phpsh==1.3.3' returned 1:   Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement phpsh==1.3.3
No distributions at all found for phpsh==1.3.3
Storing complete log in /root/.pip/pip.log
at /tmp/vagrant-puppet-1/modules-0/mediawiki/manifests/phpsh.pp:14
notice: /Stage[main]/Mediawiki::Phpsh/File[/etc/phpsh/rc.php]: Dependency Package[phpsh] has failures: true
warning: /Stage[main]/Mediawiki::Phpsh/File[/etc/phpsh/rc.php]: Skipping because of failed dependencies
notice: /Stage[main]/Apache/Service[apache2]: Dependency Package[php5-redis] has failures: true
warning: /Stage[main]/Apache/Service[apache2]: Skipping because of failed dependencies
notice: /Stage[main]/Mediawiki/Exec[check settings]/returns: executed successfully
info: /Stage[main]/Mediawiki/Exec[check settings]: Scheduling refresh of Exec[mediawiki setup]
notice: /Stage[main]/Mediawiki/Exec[mediawiki setup]/returns: executed successfully
notice: /Stage[main]/Mediawiki/Exec[mediawiki setup]: Triggered 'refresh' from 1 events
notice: /Stage[main]/Mediawiki/Exec[configure phpunit]/returns: executed successfully
notice: /Stage[main]/Mediawiki/File[/usr/local/bin/run-mediawiki-tests]/ensure: defined content as '{md5}6b154f733a6f77b5728e480b2714fe72'
notice: /Stage[main]/Mediawiki/Exec[require extra settings]/returns: executed successfully
err: /Stage[main]/Git/Package[git-review]/ensure: change from absent to 1.23 failed: Could not update: Execution of '/usr/bin/pip install -q git-review==1.23' returned 1:   Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement git-review==1.23
No distributions at all found for git-review==1.23
Storing complete log in /root/.pip/pip.log
at /tmp/vagrant-puppet-1/modules-0/git/manifests/init.pp:32
notice: Finished catalog run in 69.08 seconds

Stderr from the command:

This was the time when i got really frustrated. Even after repeated number of trials i couldn’t succeed. This was mainly because of the proxy and also many websites are blocked in my college. It failed to download few dependencies like phpsh, php5-redis etc. I manually installed them and but ‘vagrant provision’ command gave me the same error everytime. So i was left with one option i.e to install them without proxy connection. I did it and it was successfully installed. This gave me a momentarily relief but the real problems were yet to arrive. Well, i will discuss about them in the next blog. For now I am feeling accomplished after installing this.

So, the correct result that should be displayed on terminal after ‘vagrant provision’ is:

[charul@localhost vagrant]$ vagrant provision
[default] Running provisioner: puppet...
Running Puppet with site.pp...
info: Applying configuration version '1392886401.15b24e4'
info: mount[files]: allowing mediawiki-vagrant access
notice: /Stage[main]/Mediawiki/File[/vagrant/settings.d]/mode: mode changed '0775' to '0755'
notice: Finished catalog run in 5.91 seconds

Now to go to mediawiki main page, go to http://127.0.0.1:8080/wiki/Main_Page.

Screenshot from 2014-02-20 14:34:36

In order to remotely login mediawiki-vagrant from terminal:

 $ vagrant ssh

Screenshot from 2014-02-14 02:47:23

I think this looks cool 🙂

Advertisements

Fedora-Packages: My new coding adventure world!

I have started working on the fedora packages App which is built on the top of the python-turbo gear framework. So this was a new framework to me but in past i had worked on Python-Flask and Rails that helped me to pick up turbogear in good pace.

First question would be why python-turbogear? I would like to give the answer from the official documentation and will help some of it which i have found quite interesting: because

  • Real multi-database support
  • Support for Horizontal data partitioning (aka, sharding)
  • Support for a variety of JavaScript toolkits, and new widget system to make building ajax heavy apps easier
  • Support for multiple data-exchange formats
  • Built in extensibility via standard WSGI components
  • Programmer friendly template system that also works for designers

The task was to “Embed the Datagrepper html messages into the fedora-packages overview tab”. Initially when i was looking through the project and found that it would be challenging to do the task as i was a newbie to the framework and also didn’t have any idea where to start from. So with my past experience i started with small means followed the documentation and built a “hello world” sample App. I started tweaking things into it and finally after 6 hours of struggle i got the turbogear things into my head.

Now i started working on the fedora packages app and added the link to the message card in the search result. When i showed this to my mentor he suggested me to link it into the overview tab of a package and the file which needed to be changes was search_results.mak, overview.py and details.mak.

I have added these lines of code.

  •  details.mak
<div class="history-block">
    <h3>History</h3>
    <div class="history-cards">
    <a href="${w.history | n}"> Message Cards </a>
    </div>
</div>
  • overview.py
@property
def history(self):
    # html cards link of datagrepper
    datagrepper_link = "http://localhost:5000/raw?order=desc&rows_per_page=5&package="
    pkg_name = self.kwds['package_name']
    return str(datagrepper_link + pkg_name)

Then instead of the link to messages i had to embed the messages in the overview tab.

These were the final changes i made

  • overview.py
@property
def history(self):
    url = tg.config.get('datagrepper_url')
    package = str(self.kwds['package_name'])
    headers = dict(accept='text/html')
    params = dict(order='desc', rows_per_page=5, package=package, chrome='false')
    response = requests.get(url, headers=headers, params=params)
    return {'status_code':response.status_code, 'headers': response.headers, 'text': response.text}

The History messages were supposed to look like the Recent events on this link.Also we need to make things look better and So i have worked on CSS to improve that.

I added the following css

/* history cards */

.message-card {
min-height: 52px;
}

.history-cards img {
height: 25px;
width: 20px;
margin: 2px auto;
}

.history-cards p {
display: inline;
}

Finally the apps looked like this.

Screenshot from 2014-02-06 17:32:00

Fun with kids at Webmakers Kitchen Party

Last month, I attended Webmaker Kitchen Party organized by one of the Mozilla ReMo Shahid Farooqui at his home in Allahabad. I enjoyed it mainly because it was organized for school kids, so everything was like fun doing. The main objective of this event was to make these kids aware about various products of Mozilla, how they can use them and how they can contribute to the community.
The event began with the introduction given by Shahid Farooqui. He told about his role in the community, various events organized by Mozilla and also gave brief introduction about various mozilla products like Webmaker, Firefox, Persona, Firefox add-ons(firebug) and also Firefox OS mobile phone. Then RMA Rahul Ranjan told about FSA program and how to join Mozilla community. After this we volunteers gave small introduction about computer, its parts, uses, internet and e-mail. 12037034126_b54ae2baa9_o

Then comes the best part: drawing making competition because the kids participated so enthusiastically and drew beautiful logos of Firefox and webmaker. The best two drawings were awarded with prizes. It was also a great meeting with Shahid Farooqui as i get to know lot about FOSS, conferences, Mozilla, FSA and WOMOS program.
I also got cool Mozilla stickers and Mozilla t-shirt. 😀

WP_20140206_003

Group pic
12036949016_03d79b0db5_o

Overall it was a wonderful day!!

Git branch is as cool as tree branch

While working on my next task that was to integrate messages from datagrepper into fedora packages, I learnt few cool stuff about github. I had to change the styling of the datagrepper messages. So, Ralph asked me to make changes and commits in a new branch rather than the develop branch in which I was working before.
If we do not want to make any changes in our master branch (i.e. develop), we can create a new branch that will be a copy of the master branch, then make changes to it and create pull request on this branch. Also for the services that are already working in production, we work on branches only.

How to create a new branch?

I created a branch named fedpkg

Create a new branch on your local machine:

$ git branch fedpkg

Push the branch on github:

$ git push origin fedpkg

Then switch to your new branch:

$ git checkout fedpkg

To see all the branches that have been created:

[charul@localhost datagrepper]$ git branch
* develop
  fedpkg

To remove a local branch from your machine:

$ git branch -d the_local_branch

To delete the branch on github:

$ git push origin :fedpkg

To add a new remote to your branch:
(I have added a new remote named upstream)

$ git remote add upstream https://github.com/fedora-infra/datagrepper

To update the local repository with the github repository:

$ git fetch upstream
$ git merge upstream/master

Push changes from your commit into your branch:

$ git push origin upstream

To check the remotes you have:

(datagrepper)[charul@localhost datagrepper]$ git remote -v
origin    https://github.com/charulagrl/datagrepper (fetch)
origin    https://github.com/charulagrl/datagrepper (push)
upstream    https://github.com/fedora-infra/datagrepper (fetch)
upstream    https://github.com/fedora-infra/datagrepper (push)