Pages

Thursday, August 9, 2012

Python: Import a Submodule Programmatically

Situation:
In Python 2.7, there is a need to import a sub-package programmatically by name.

Problem:
I've looked at __import__ and importlib but the solution is not readily apparent.

Solution:
import importlib
module_name = '.'.join(('os','path'))
path = importlib.import_module(module_name)

#or

import sys

module_name = '.'.join(('os','path'))
__import__(module_name)
path = sys.modules[module_name]

References:
  1.  importlib – Convenience wrappers for __import__()
  2. Source code for importlib





Thursday, August 2, 2012

Trouble Starting Ubuntu: System Running in Low Graphics Mode

Situation:
Trying to boot computer into Ubuntu 12.04 LTS(Precise)

Problem:
You reach dialog which says "System running in low graphics mode"

Solution:
<CTRL-ALT-F1> to get to command line
<CTRL-C> to exit current process if needed

sudo apt-get install --reinstall ubuntu-desktop
sudo reboot

References:
  1. Ask Ubuntu: Your system is running in low-graphics mode with an ATI Radeon 3200 Graphics card

Wednesday, August 1, 2012

Ubuntu Software Center is Prompting for Root

Situation:
Trying to install package using Ubuntu Software Center on Ubuntu 12.04 LTS(Precise)

Problem:
The user is prompted for the root password instead of their own

Solution:
Edit  /etc/polkit-1/localauthority.conf.d/51-ubuntu-admin.conf to include the user or their group. Here is an example of the contents of this file:

[Configuration]
AdminIdentities=unix-group:administrators;unix-user:johnsmith

References:
  1. pklocalauthority - PolicyKit Local Authority
    
    
  2. Ubuntu forums