Pages

Sunday, November 4, 2012

Ubuntu 12.04 Restore Default Scrollbars

Situation:
Ubuntu 12.04 LTS(Precise)

Problem:
Please restore the default scrollbars.

Solution:
Run the following at command line:

sudo su
echo "export LIBOVERLAY_SCROLLBAR=0" > /etc/X11/Xsession.d/80overlayscrollbars
gnome-session-quit #log out and back in

References:

Error "string indices must be integers" When Deserializing Queryset


Situation:
Attempting to deserialize a django 1.5 queryset

from django.core import serializers
queryset = MyModel.objects.all()
data = serializers.serialize('json', queryset)
#... on another server, data loaded using urllib2:
obj = serializers.deserialize('json', data) # error

Problem:
Django returns the error "string indices must be integers"

Solution:
You are not deserializing what you think you are deserializing.  Look at the JSON string and it should be apparent.   I had this problem in two cases:

  1. I had accidentally serialized twice (the JSON string contained escaped quotation marks: \")
  2. There was an error message instead of the actual object


References:

  1. Django Docs:  Serialization

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