Screen unlock helpers needs to be simpler for developers

Bug #1250458 reported by Omer Akram
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
unity8 (Ubuntu)
Triaged
Medium
Omer Akram

Bug Description

Right now the screen unlocking helper in process_helpers.py provides two functions. One to unlock the screen and the other to start unity in testability but they are not called from within each other.

What would make more sense and also make the life of developers easy is that unlock_unity() should itself check if unity is running in testability and if not start it in testability and unlock the screen. Also if the screen is already unlocked it should just do nothing instead of raising an exception.

With the above suggestion I think it makes more sense to rename that function to ensure_unity_unlocked().

Currently I am using something like this and calling it in setUp():

def ensure_screen_unlocked(self):
    unity_pid = process_helpers._get_unity_pid()

    try:
        if get_proxy_object_for_existing_process(unity_pid):
            process_helpers.unlock_unity()
    except RuntimeError:
        logger.log("Could not find autopilot interface for unity8, "
                            "restarting it in testability mode.")
        process_helpers.restart_unity_with_testability()
        process_helpers.unlock_unity()

ProblemType: Bug
DistroRelease: Ubuntu 14.04
Package: unity8 7.83+14.04.20131106-0ubuntu1
ProcVersionSignature: Ubuntu 3.12.0-2.5-generic 3.12.0
Uname: Linux 3.12.0-2-generic i686
NonfreeKernelModules: wl
ApportVersion: 2.12.6-0ubuntu1
Architecture: i386
Date: Tue Nov 12 17:47:38 2013
InstallationDate: Installed on 2013-11-07 (4 days ago)
InstallationMedia: Ubuntu 14.04 LTS "Trusty Tahr" - Alpha i386 (20131107)
MarkForUpload: True
SourcePackage: unity8
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Omer Akram (om26er) wrote :
Revision history for this message
Omer Akram (om26er) wrote :

I can work on it if we have an agreement.

Revision history for this message
Michał Sawicz (saviq) wrote :

For unlock_screen - I wonder if just returning False instead of raising would be better? Most of the users won't care about the return value, but we'd still have the ability to find the status.

Or well, yeah, a wrapper that will just pass on RuntimeException would be good enough.

Revision history for this message
Christopher Lee (veebers) wrote :

I like the idea of returning True or False. It means that callers don't need to worry about catching pesky exceptions :-)
It also means that we don't have to write another specific method just to make sure the greeter _wasn't_ swiped away.

Revision history for this message
kevin gunn (kgunn72) wrote :

seems we have a agreement & boolean return a bit preferred

Changed in unity8:
assignee: nobody → Omer Akram (om26er)
importance: Undecided → Medium
status: New → Triaged
Changed in unity8 (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Omer Akram (om26er)
Michał Sawicz (saviq)
no longer affects: unity8
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.