~ubuntu-branches/ubuntu/lucid/landscape-client/lucid-updates

« back to all changes in this revision

Viewing changes to scripts/landscape-client-settings-ui

  • Committer: Package Import Robot
  • Author(s): Andreas Hasenack
  • Date: 2012-04-10 14:28:48 UTC
  • mfrom: (1.1.27)
  • mto: This revision was merged to the branch mainline in revision 35.
  • Revision ID: package-import@ubuntu.com-20120410142848-7xsy4g2xii7y7ntc
ImportĀ upstreamĀ versionĀ 12.04.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python 
 
2
import os
 
3
import sys
 
4
 
 
5
from gettext import bindtextdomain, textdomain
 
6
 
 
7
script_dir = os.path.abspath("scripts")
 
8
if os.path.dirname(os.path.abspath(sys.argv[0])) == script_dir:
 
9
    sys.path.insert(0, "./")
 
10
else:
 
11
    from landscape.lib.warning import hide_warnings
 
12
    hide_warnings()
 
13
 
 
14
from landscape.ui.controller.app import SettingsApplicationController
 
15
from landscape.lib.lock import lock_path, LockError
 
16
 
 
17
if __name__ == "__main__":
 
18
    lock_file = os.path.join("/var/lock", "landscape-client-settings-ui")
 
19
    try:
 
20
        unlock_path = lock_path(lock_file, timeout=1)
 
21
    except LockError:
 
22
        sys.stderr.write("Another instance of "
 
23
                         "landscape-client-settings-ui is already "
 
24
                         "running.\n")
 
25
        sys.exit(1)
 
26
    else:
 
27
        bindtextdomain("landscape-client", "/usr/share/locale")
 
28
        textdomain("landscape-client")
 
29
        app = SettingsApplicationController(args=sys.argv[1:])
 
30
        try:
 
31
            app.run(None)
 
32
        except Exception, e:
 
33
            sys.stderr.write("%s\n" % str(e))
 
34
        finally:
 
35
            unlock_path()