Go Open Source...

Go Open Source...
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Saturday, March 28, 2015

[Solved] Python Pynotify- gio.Error: The connection is closed

Posted By: Saurabh Deochake - 8:47:00 PM



Pynotify:

Pynotify is a Python package providing tools for implementing Observer programming pattern. These tools include signals, conditions and variables. Pynotify comes handy when one wants to write a script which outputs some "notification" pop-up on the desktop. Pynotify relies on Dbus IPC bus and problem occurred in Dbus may cause Pynotify to break. There is a well-known problem that usually occurs while using Pynotify. We discuss the problem below and solution to overcome the problem.




Problem:  

Whenever we use show() method of pynotify to show the message in pop-up window, it gives you error in the following format: 
Traceback (most recent call last):
  File "NotifyMe.py", line 14, in <module>
    notifications.show()
gio.Error: Connection Closed
The gio.Error is related to Dbus suggesting that the connection to Dbus is closed. 

Cause:

I was working on one project which uses Pynotify and I encountered the same problem. After a lot of research I found out that I was calling my script with root user. If you are also running your script with root user, then it may be the problem. The problem is that root does not have a dbus session running. I found out that it does not even own XScreen. I assume we want to use Dbus session that belongs to the logged in user.

Solution:


There are two or three workarounds to tackle the problem and get your pynotify script working. We discuss those solutions below:



  1. Quit Root User Session: Most probably current Dbus session belongs to normal user which is currently logged in. So, better and simple way to avoid above problem is to quit root user session using "ctrl+d" and run the script again. 
  2. Use GKsu: GKSu is a library that provides a Gtk+ frontend to su and sudo. GUI applications should be started with gksu, not su or sudo.
  3. Add "root" User to Dbus Group: A simple workaround can be adding the "root" user to Dbus group to give it the permission to connect to Dbus. I have not verified this step. So, if it works for you, please let me know in the comments section.
  4. Exporting Display Variable: Another workaround that MAY help in solving the problem is exporting display variable. Add following lines of code to start of your python script and see if it helps.

import os
os.environ['DISPLAY'] = ':0.0'


I hope above solutions will work for you and you'd be able to work with pynotify in your projects. Any alternate suggestions to solve the problem? Do let us know in comments section below.

Monday, January 12, 2015

Top 5 Less Known Features of VLC Media Player

Posted By: Saurabh Deochake - 9:43:00 PM


Now, if you ask anybody which media player would they prefer to play their multimedia files, a majority of answers would be VLC Media Player. VLC is one of the most widely used multimedia player worldwide. It is a portable, cross-platform and (thankfully!) a free open-source software released by VideoLAN. Although VLC is used on millions of devices across the world, there are a few less known and less used features of VLC. Here, in this post we give you top 5 less known features of VLC Media Player. 

1) VLC as a YouTube Video Downloader

We all know that VLC Media Player can be used to stream the videos using Open Network Stream option. Sometimes we want to download YouTube videos but we cannot, of course unless we have a YouTube downloader software installed on the device. Surprisingly, VLC can also be used as a YouTube video downloader eliminating the need to download all those one-click video downloader and browser extensions to download our favorite YouTube videos. 

Follow the steps to download YouTube videos using VLC:
  1. Go to Media -> Open Network Stream and paste the URL of the YouTube video that you intend to download.

  2. Click Play and when VLC starts playing the video, go to Tools ->Codec Information and copy the Location URL and paste the URL in your browser.

  3. Click Play to play the video in browser. Once the video starts playing, right click on the video and Click Save As to download the video.

2) VLC as a File Converter 

Yes! You've read VLC as a file converter! We can use VLC media player as a tool to convert multimedia files from one format to another. Gone are those days when we had to download multimedia file converter software. 

Follow the steps to convert files using VLC:
  1. Go to Media -> Convert / Save.
  2. In Open Media prompt, click on Add to add the files that you need to convert.

  3. Click on Convert / Save. In Convert pop up window, select the file type your original file to be converted from wide range of options in Profile.
  4. Write the location of the destination file and click Start. After the conversion process is finished. You can check your converted file at the "destination location".

3) VLC as an Online Video Chat Recorder

Apart from playing multimedia files, another awesome use of VLC media player is to record your online video chats. 

Follow the steps to record your online video chat sessions using VLC:
  1. Go to Media -> Open Capture Device

  2. On Open Media pop up window, select Webcam option and Microphone option from Video device name and Audio device name drop down boxes, respectively.
  3. Drop down the Play button which opens the Convert pop up window where you can select the Destination file, click on the Browse button to select video file location, name and format.

4) VLC as an Audio Normalizer

When you are playing audio and video files and a sudden increase in the volume jars your ears, it’s a feature to keep in mind. In case of video, you have to restart the video for it to take effect. Go to Preferences -> Audio and select normalization levels from Normalize volume to option.

5) VLC as a Tool to Play Videos in ASCII Art

Another cool feature which is less common feature is playing videos in ASCII art. Yes! You can use VLC player to play videos in ASCII text. To play videos in cool ASCII text, go to Preferences -> Video and select Color ASCII art video output from Output drop down menu.



Now, play any video file and enjoy it watching in cool ASCII text.

Got any more lesser known features of awesome VLC Media Player that are not listed here? Please share them in comments below.

Wednesday, January 7, 2015

Top 5 Free Alternatives to Adobe Photoshop

Posted By: Saurabh Deochake - 9:49:00 PM


Adobe Photoshop has been one of the most widely known picture editing software for some years now. It has become so dominant that we use its name as verb. If you want to get your hands on Photoshop, you will have to spend around $50 for complete package. The best thing about Open Source Software Communities is that many people work hard to build free alternatives to expensive commercial products. In this post, we give you top 5 alternatives to Adobe Photoshop which are absolutely free.

1. GIMP (Win/Linux/OS X)

Whenever we hear about an alternative to Photoshop, one program that comes to our mind is GIMP. GIMP (GNU Image Manipulation Program) is a freely distributed image editing software used for tasks such as photo retouching, image composition and image authoring. It can be used as a simple paint program, an expert quality photo retouching program, an online batch processing system, a mass production image renderer, an image format converter, etc. GIMP is designed to be augmented with various plug-ins and extensions to carry out everything from the simplest task to the most complex tasks.
GIMP Linux Distribution
One can be a little bit bewildered with a lot of features and tools that come shipped with GIMP. Fortunately enough, it does not take a long for a newbie to get familiar with GIMP and its features. Additionally, there is a multitude of tutorials of GIMP to make you more familiar with the software.

How to get it?

GIMP is available on both Windows and Linux. One important thing to note is GIMP does not work on all the Windows operating system before Windows XP. You can download GIMP here.

2. Pixlr Express (Web/Android)

Now, Pixlr Express is one of the most impressive photo editing software launched by Autodesk Inc. Pixlr is a web-based online photo editing service which is now made available on the Windows desktop and Mac computers. The software comes with a plethora of cool features like Blur, Liquify, Heal, Smooth and Focal Blur. One can always customize the image with advanced features like adding the border, stickers and text with some impressive font styles. Pixlr Express is not just one of the best online image editors, but one of the best Web-based and Android applicatons.

Pixlr Express Effects Panel

How to get it?

Best thing of Pixlr Express is that it is available on Windows, Mac and Android platforms making it one of the most popular applications in the market of image processing. Check your platform and see where can you get Pixlr Express from:
  • Windows and Mac: Get Pixlr Express from here.
  • Android: Get Pixlr Express app on Google Play Store from here.

3. Paint.Net (Windows)

Another freely distributed image processing software, Paint.Net is widely acclaimed by popular websites like CNET, Lifehacker and PC World. It started as an undergraduate college design project which eventually became one the most popular free picture editing software. Paint.Net features layer support, and a useful list of effects which can be used to accomplish wide range of picture manipulations from simple picture editing to a complex rendering tasks. Paint.Net also supports a wide range of plug-ins created by community to carry out specific advanced tasks.
Paint.Net Editing Tools Screenshot
With a simple menu and tool box, it's certainly one of the most human-friendly Photoshop alternatives available. An advanced user seeking to get his hands on Paint.Net may get disappointed as it doesn't have too many top-end features.

How to get it?

One disadvantage of Paint.Net is that it is made to work only on Windows platform (sorry Mac and Linux users!). To add to that minimum system required to run Paint.Net as per their website must run Windows 7 (Service Pack 1) and above. Another important thing to note is this software does not work on the Windows RT operating system. You can download Paint.Net from here.

4. PicMonkey (Web)

PicMonkey is the best alternative to Picnik Photo Editor which was shut down by Google and quickly merged into Google+ by the name Google+ Photo Editor. After Picnik was shut down by Google, two former Picnik engineers, Brian Terry and Justin Huff founded PicMonkey in April 2012. The online application to edit the pictures is very much simple. All you have to do is upload the image you want to edit, but once you're in you have a pile of different tools to use. Shapes, textures, and text can be added with a couple of clicks, and there are some cool effects to play around with too.
 
PicMonkey Editor Screenshot
Although PicMonkey does not provide tools and features that are provided with Photoshop, but it comes with ample effects and tools to give you Photoshop-esque look to your pictures.

How to get it?

Being a web-based photo editing application, PicMonkey can be used on all operating systems. Another impressive thing about PicMonkey is that it is also available on Google Chrome Store as an extension for Google Chrome browser. Check your platform and see where can you get PicMonkey from:
  • Windows/OS X/Linux- Get PicMonkey from here.
  • Google Chrome Extension- Get PicMonkey extension for Chrome browser from here.

5. Sumo Paint (Web)

Sumo Paint is an online image editor and an impressive web-based alternative to Photoshop. You can edit your photos without need to install anything to your device. It's one of the most versatile photo editor and painting application that works in a browser. You can open and save images from your hard drive or save it to cloud. Sumo Paint supports some advanced features like Layers, Texture, Fractals and so on. 
Sumo Paint Photo Editor Screenshot
Being a web-based photo editing application, Sumo Paint can be used on all operating systems. Like PicMonkey, Sumo Paint is also available on Google Chrome Store as an extension for Google Chrome browser. Check your platform and see where can you get Sumo Paint from:
  • Windows/OS X/Linux- Get Sumo Paint from here.
  • Google Chrome Extension- Get Sumo Paint extension for Chrome browser from here.
Those are our top 5 picks, but definitely there are other applications out there. Got a favorite that we didn't mention? Share it below!

Monday, December 29, 2014

[Solved] LXC: not authorized to change the password

Posted By: Saurabh Deochake - 2:43:00 PM


The Problem

This problem occurs especially when LXC Containers are run on a host machine with CentOS distribution. When we want to create an user inside the container, we get an error which says "..... is not authorized to change the password of <user_name>. A snippet of the error is shown below:
~]# passwd testuser

passwd: unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 is not authorized to change the password of testuser

Containers Abstract Image

The Solution 

The culprit behind this problem usually is SELinux. When set to "Enforcing" or "Permissive", the SELinux would deny the user to change user parameters inside the containers like passwords as we encountered in the problem. Though, it is not safe to disable SELinux; we can solve above problem temporarily by checking the status of SELinux and disabling it. To get the "passwd" command work inside the container, follow the steps below:

1. Check SELinux settings on CentOS Host Machine
~]$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted
2. Check SELinux settings on Guest
~]$ sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
3. Disable SELinux from Config file
  1. Go to the config file located at /etc/selinux/config 
  2. Change SELINUX option to disabled 
  3. Save and close the file
4. Reboot the Host Machine
5. After reboot, check SELinux setting parameter using getenforce
~]$ getenforce
Disabled
Now, check again if the problem still persists in the guest virtual machine. This temporary fix should solve the problem.
    *Note: This is only a temporary fix to the problem. If you want to have more insight on the problem and patches to fix the internal problems in LXC (if any), please post your queries to "lxc-users" mailing list here.

    Friday, December 26, 2014

    Libvirt: In a Nutshell

    Posted By: Saurabh Deochake - 9:40:00 PM


    In one of the previous posts, we discussed about lightweight virtualization solutions and more specifically, Linux Containers aka. LXC. Although, LXC has its own management tools that are shipped with the package, there are other APIs and virtual machine managers which can be used to manage various hypervisors and container systems. In this post, we discuss about Libvirt, a widely popular open source virtual machine management API.

    What is Libvirt?

    Libvrit is an open source API, daemon and virtual machine manager for managing platform virtualization. Libvirt can be used to manage various virtualization solutions like LXC, KVM, OpenVZ, Xen and VMware ESX. Libvirt is a C Library, but it offers bindings in other languages some of which are Python,Perl, Ruby and Java.  

    Some of Hypervisors Supported by Libvirt

    Supported Hypervisors

    Libvirt Supports a multitude of hypervisors and virtualization solutions. Some of widely known hypervisors supported by Libvirt are:
    1. LXC- Linux Containers
    2. OpenVZ
    3. QEMU/KVM
    4. Xen Hypervisor
    5. VirtualBox
    6. VMware ESX and GSX Hypervisors
    7. Microsoft's Hyper-V Hypervisor
    8. IBM's PowerVM for AIX

    Command Line Tools

    Libvirt comes with a plethora of tools for management purposes. These tools range from virtual machine management to file system management, from memory management to provision of virtual machines over the network. Some of important command line tools that are used are:
    • virsh: An interactive shell and a virtual machine management tool which comes shipped with core distribution of Libvirt. It is one of the most important tool when it comes to managing various tasks on domains like virtual machines, containers or storage managed by Libvirt. 
    • virsh-top: Another interactive command line utility to keep track of CPU, memory, disk and network utilization of all the virtual machines running on a host machine. This utility is essentially similar to "top" command which provides an ongoing look at processor activity of host machine.
    • virt-what: A shell script essentially used for detecting if the program is running on the virtual machine.
    • virt-df: Another commond line utility which is similar in working with that of Linux file system command, "df". This utility offers the file system information of all virtual machine running on the host machine. This utility gives the information about how much disk space is used in each of guest disk.
    • virt-clone: This tool allows disk image(s) and configurations to be cloned from one virtual machine to another. This tool comes in handy especially while creating a new virtual machine from existing virtual machine keeping disk configurations intact. It automates copying of data across to new disk images, and updates the UUID, MAC address, and name in the configuration.

    Get Libvirt

    Libvirt is an open source software and released under the GNU Lesser General Public License (see the file COPYING.LIB in the distribution package for the precise wording). You can get Libvirt from the latest upstream tarballs from hereYou can also get it using git clone from git clone git://libvirt.org/libvirt.git.

    Friday, February 21, 2014

    LXC: In a Nutshell

    Posted By: Saurabh Deochake - 11:12:00 PM


    What is LXC?

    LXC (LinuX Containers) is an operating system-level virtualization method for running multiple isolated Linux systems (containers) on a single control host. LXC provides operating system-level virtualization not via a 
    full blown virtual machine, but rather provides a virtual environment that has its own process and network space. LXC is an userspace API which supports Linux Kernel's support for containment.
    With containers, you have the option of kicking off any individual process you like inside any container. Instead, what we do is set up a file system containing a copy of a minimal operating system image, and kick off /sbin/init on that partition, in that file system, with its own Ethernet interface. We get the appearance of a VM, each container getting its own IP address, and disk file systems, its own set of software packages installed, and its own set of OS daemons processes.

    Linux Container(?)

    Features

    LXC provides following features of Linux Kernel to support containment:
    1. Chroots
    2. Control groups (cgroups)
    3. Kernel namespaces (ipc, uts, mount, pid, network and user)
    4. Apparmor and SELinux 
    5. Kernel capabilities and many more...

    chroot and LXC

    In simple words, LXC builds up from chroot to implement complete virtual systems, adding resource management and isolation mechanisms to Linux’s existing process management infrastructure. LXC is often considered as a virtualization solution between chroot on steroids and complete full blown virtual machine.  The main goal of LXC is to create a closest possible environment as that of a standard Linux installation but without the need for a separate kernel. 

    Container Life Cycle

    When the container is created, it contains the configuration information. When a process is launched, the container will be starting and running. When the last process running inside the container exits, the container is stopped.

    Container Life Cycle
    In case of failure when the container is initialized, it will pass through the aborting state.

    Components

    The current release of LXC is comprised of following main components:
    • The liblxc library
    • Several language bindings (python, ruby, lua etc.)
    • Standard tools to control the containers
    • Container templates

    Container Management

    The containers can be managed with the help of some popular container-management utilites like lxc-tools and other libraries like libvirt. Libvirt is an open source API, daemon and management tool for managing platform virtualization. 

    Get LXC

    LXC is free software and is released under the terms of the GNU LGPLv2.1+ license. You can get LXC from the latest upstream tarballs from here or directly from git repository of LXC from here. You can also get it using git clone from git clone git://github.com/lxc/lxc.

    Wednesday, February 12, 2014

    Cgroups: In a Nutshell

    Posted By: Saurabh Deochake - 12:18:00 PM



    What is Cgroups?

    Cgroups is a Linux kernel feature to limit, account and isolate resource usage of process groups. Cgroups allow you to allocate resources—such as CPU time, system memory, network bandwidth, or combinations of these resources—among user-defined groups of tasks (processes) running on a system. You can monitor the cgroups you configure, deny cgroups access to certain resources, and even reconfigure your cgroups dynamically on a running system. 



    The above figure describes the CPU shares limitation using Cgroups. We can see that three Cgroups use chunks of CPU. Cgroup #1’s share is 1024. Cgroup #2’s share is greater than both other Cgroups, so it’ll get more CPU than both others. Cgroup #3 will get least CPU share.

    Subsystems of Cgroups:

    Other than CPU subsystem, there are eight other subsystems available. Let’s have a look at all the Cgroups subsystems in brief:

    • blkio — this subsystem sets limits on input/output access to and from block devices such as physical drives (disk, solid state, USB, etc.).
    • cpu — this subsystem uses the scheduler to provide cgroup tasks access to the CPU.
    • cpuacct — this subsystem generates automatic reports on CPU resources used by tasks in a cgroup.
    • cpuset — this subsystem assigns individual CPUs (on a multicore system) and memory nodes to tasks in a cgroup.
    • devices — this subsystem allows or denies access to devices by tasks in a cgroup.
    • freezer — this subsystem suspends or resumes tasks in a cgroup.
    • memory — this subsystem sets limits on memory use by tasks in a cgroup, and generates automatic reports on memory resources used by those tasks.
    • net_cls — this subsystem tags network packets with a class identifier (classid) that allows the Linux traffic controller (tc) to identify packets originating from a particular cgroup task.
    • net_prio — this subsystem provides a way to dynamically set the priority of network traffic per network interface.
    • ns — the namespace subsystem.

    Features:

    Now, let’s discuss about features provided by Cgroups. 
    Cgroups provides following features:
    • Resource Limitation: Groups can be set to not exceed a resource limitation. This limitation includes memory limit, file system cache limit, disk I/O throughput limitation etc.
    • Prioritization: Some groups may get a larger share of CPU, disk I/O throughput etc.
    • Accounting: We can measure how much resources certain systems use.
    • Isolation: Separate namespaces are provided for groups, so they remain fully exclusive to each other. The groups cannot see each other’s processes, network connections etc.
    • Control: We can freeze groups, checkpoint and restart the container. 
    Today, I briefly discussed about Cgroups. Next time, we'll discuss about a buzzing virtualization solution in the Open Source Community, Linux Containers (LXC).

    Sunday, February 9, 2014

    Fedora 21 will be Nameless

    Posted By: Saurabh Deochake - 8:22:00 PM


    Red Hat owned and community-supported Fedora Project developed "Fedora 21" has always had some funky and colorful names. After the Fedora 20 release was named Heisenbug, the next release Fedora 21 will not have any name.  Fedora 19 was called Schrodinger's Cat, Fedora 18 was the Spherical Cow, and Fedora 17 was the Beefy Miracle.



    Jaroslav Reznik of Red Hat in his blog post says,
     “What will be the code name for Fedora 21. And again short answer: null. Not null as null string but null. Fedora Board decided to end release names process. It does not mean “no more release names” but it’s up to community or working groups, if anyone wants to step into the role of Name Wrangler and helps running this process. Or reform it in any way.”

    Late Release of Fedora 21

    A version of Fedora has a relatively short life cycle—the maintenance period is only 13 months: there are 6 months between releases, and version X is supported only until 1 month after version X+2. Typically, the Fedora project has had two releases in any given year: one in the early spring, the other early winter. For 2014, that likely won't be the case. 
    Jaroslav Reznik further answers about the schedule of Fedora 21, 
    "Is Fedora 21 going to be released in the old model way, or new one? Hard to answer right now. But there's one date - F21 is not going to be released earlier than in August (and I'd say late August)". 
    There has been a discussion about Fedora 21's release schedule.

    The time gap between Fedora 20 and Fedora 21 should be approximately 6 months. The time between the two releases will be used to work on tooling for quality control and release automation. But this is not the case this time. Jaroslav Reznik further says,
    “But this time we are in a bit different situation – there are several working groups trying to redefine, how Fedora should look like in the future and it does not make sense to create schedule. We need resolution from this effort. It’s planned for January.”

    2014 will be an exciting year in the Red Hat community, beyond just the evolution of Fedora. Red Hat Enterprise Linux 7 will likely be announced at some point in this year. Moreover, Red Hat recently partnered with its community developed CentOS community Linux project. CentOS is a clone of Red Hat's Red Hat Enterprise Linux (RHEL) platform, and provids a free alternative to Red Hat's RHEL.

    Creative Commons License
    This blog by Linuxys is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

    Copyright © 2015 Linuxys™ All rights reserved.

    Designed by Templateism. Hosted on Blogger Platform.