~mvo/ubuntu-sso-client/lp711413

« back to all changes in this revision

Viewing changes to ubuntu_sso/main/darwin.py

  • Committer: Tarmac
  • Author(s): Manuel de la Pena
  • Date: 2012-05-21 14:55:49 UTC
  • mfrom: (956.1.4 darwin-ac-cmdline)
  • Revision ID: tarmac-20120521145549-kvq3znb63lk4iipk
- Moved the code out to a function so that it can be called from other projects (LP: #1002307).

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    return path
56
56
 
57
57
 
 
58
def get_activation_cmdline(name):
 
59
    """Find the path to the executable callback."""
 
60
    # TODO: We have to either use launchd to launch the different services
 
61
    # on demand or us LaunchServices to handle running the app via an URL.
 
62
    ubuntu_sso_pkg_dir = os.path.dirname(os.path.dirname(ubuntu_sso.__file__))
 
63
    ubuntu_sso_bin_dir = os.path.join(ubuntu_sso_pkg_dir, 'bin')
 
64
    ubuntu_sso_bin = os.path.join(ubuntu_sso_bin_dir, 'ubuntu-sso-login')
 
65
    ubuntuone_client_bin_dir = os.path.join(ubuntu_sso_pkg_dir,
 
66
                                            '../ubuntuone-client/bin')
 
67
    ubuntuone_client_bin = os.path.join(ubuntuone_client_bin_dir, name)
 
68
    if os.path.exists(ubuntuone_client_bin):
 
69
        return ubuntuone_client_bin
 
70
    return ubuntu_sso_bin
 
71
 
 
72
 
58
73
class DescriptionFactory(object):
59
74
    """Factory that provides the server and client descriptions."""
60
75
 
81
96
    @property
82
97
    def cmdline(self):
83
98
        """Get the command line to activate an executable."""
84
 
        # MAYBE: use special URI schemes to have LaunchServices handle
85
 
        # running the app, instead of paths to scripts
86
 
        # e.g. 'x-ubuntuone-syncdaemon', 'x-ubuntu-sso-login'
87
 
        ubuntu_sso_pkg_dir = os.path.dirname(
88
 
            os.path.dirname(ubuntu_sso.__file__))
89
 
        ubuntu_sso_bin_dir = os.path.join(ubuntu_sso_pkg_dir, 'bin')
90
 
        ubuntu_sso_bin = os.path.join(ubuntu_sso_bin_dir, 'ubuntu-sso-login')
91
 
        ubuntuone_client_bin_dir = os.path.join(ubuntu_sso_pkg_dir,
92
 
                                                '../ubuntuone-client/bin')
93
 
        ubuntuone_client_bin = os.path.join(ubuntuone_client_bin_dir,
94
 
                                            self.name)
95
 
        if os.path.exists(ubuntuone_client_bin):
96
 
            return ubuntuone_client_bin
97
 
        return ubuntu_sso_bin
 
99
        return get_activation_cmdline(self.name)
98
100
 
99
101
 
100
102
class UbuntuSSOClient(BaseClient):