Merge lp://qastaging/~brian.curtin/ubuntuone-control-panel/autostart-clean into lp://qastaging/ubuntuone-control-panel

Proposed by Brian Curtin
Status: Merged
Approved by: Roberto Alsina
Approved revision: 306
Merged at revision: 298
Proposed branch: lp://qastaging/~brian.curtin/ubuntuone-control-panel/autostart-clean
Merge into: lp://qastaging/ubuntuone-control-panel
Diff against target: 216 lines (+128/-0)
5 files modified
ubuntuone/controlpanel/gui/qt/gui.py (+2/-0)
ubuntuone/controlpanel/gui/qt/tests/test_gui.py (+16/-0)
ubuntuone/controlpanel/utils/__init__.py (+2/-0)
ubuntuone/controlpanel/utils/tests/test_windows.py (+88/-0)
ubuntuone/controlpanel/utils/windows.py (+20/-0)
To merge this branch: bzr merge lp://qastaging/~brian.curtin/ubuntuone-control-panel/autostart-clean
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Natalia Bidart (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+99089@code.qastaging.launchpad.net

Commit message

- Add Ubuntu One to the Windows auto-start registry key

Description of the change

Introduce add_to_autostart (from ubuntuone-windows-installer) and add it to the install wizard for new users as well as ensure it gets called for users who already have credentials.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

If we're a already calling add_to_autostart from ubuntuone/controlpanel/gui/qt/gui.py, why would you also add it in the wizard code?

Unless I'm missing something (please let me know), there is no need to do that. Also, semantically, the wizard is a 're usable' widget, and we would not like to leak thing like adding to autostart when using it.

review: Needs Fixing
Revision history for this message
Manuel de la Peña (mandel) wrote :

Adding tho the comments of natalia, I would call the parents setup before I do any patching or operations. Also I would not add the setup of we only have one test, but im lazy :)

review: Needs Fixing
301. By Brian Curtin

Removed an add_to_autostart call which is no longer needed.

Revision history for this message
Brian Curtin (brian.curtin) wrote :

Rev 301 removes the call Natalia was talking about.

Manuel: I need that ordering in the setUp because I need add_to_autostart patched before anything else up the chain runs. The add_to_autostart is called when MainWindow is created, and it's created within BaseTestCase, so I have to get patched in before then.

302. By Brian Curtin

Add docstrings to two test classes

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

ubuntuone/controlpanel/gui/qt/tests/test_gui.py:
    130: [C0111, AutoStartTestCase.test_add_to_autostart] Missing docstring

ubuntuone/controlpanel/utils/tests/test_windows.py:
    162: [W0622, AutostartTestCase.test_add_syncdaemon_to_autostart] Redefining built-in 'dir'

ubuntuone/controlpanel/utils/windows.py:
    22: [F0401] Unable to import '_winreg'

review: Needs Fixing
303. By Brian Curtin

fix lint errors

Revision history for this message
Brian Curtin (brian.curtin) wrote :

Rev 303 fixes the remaining lint issues.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Lookis at the logic inside add_to_autostart, is there any reason to have the "else: return" in the middle of the code? Why not just:

def add_to_autostart():
    """Add syncdaemon to the session's autostart."""
    if getattr(sys, "frozen", False):
        sd_path = '"%s"' % os.path.join(os.path.dirname(
            os.path.abspath(sys.executable)),
            "ubuntuone-syncdaemon.exe")
        u1cp_path = '"%s"' % os.path.join(os.path.dirname(
            os.path.abspath(sys.executable)),
            "ubuntuone-control-panel-qt.exe")

        with _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, AUTORUN_KEY,
                             0, _winreg.KEY_ALL_ACCESS) as key:
            # pylint: disable=E0602
            _winreg.SetValueEx(key, "Ubuntu One", 0, _winreg.REG_SZ, sd_path)
            _winreg.SetValueEx(key, "Ubuntu One Icon", 0, _winreg.REG_SZ,
                               u1cp_path + " --minimized --with-icon")

Revision history for this message
Brian Curtin (brian.curtin) wrote :

That was an artifact of the old implementation from ubuntuone-windows-installer. Removed.

304. By Brian Curtin

Remove unnecessary else/return block

Revision history for this message
Manuel de la Peña (mandel) wrote :

> Rev 301 removes the call Natalia was talking about.
>
> Manuel: I need that ordering in the setUp because I need add_to_autostart
> patched before anything else up the chain runs. The add_to_autostart is called
> when MainWindow is created, and it's created within BaseTestCase, so I have to
> get patched in before then.

Very well then.. I would have added a comment to state so to avoid stupid reviewers :)

Few things:

8 +from ubuntuone.controlpanel.utils import add_to_autostart

I know we do take a lot of effort in doing alphabetical ordered imports, can you move the import a few lines? I'm the first one to ignore this rule, but is a style we try to keep.

Besides that every thing looks good so I'll approve assuming you will order the imports!

PS: I had no idea _winreg could be a context manager!

review: Approve
305. By Brian Curtin

Alphabetical import ordering

306. By Brian Curtin

Add comment explaining patching order

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Looks good!

review: Approve
Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches