]> git.lizzy.rs Git - torbrowser-launcher.git/blob - torbrowser_launcher/__init__.py
b78119b806b3aba0ba82c3a19480875c19790ed3
[torbrowser-launcher.git] / torbrowser_launcher / __init__.py
1 """
2 Tor Browser Launcher
3 https://github.com/micahflee/torbrowser-launcher/
4
5 Copyright (c) 2013-2014 Micah Lee <micah@micahflee.com>
6
7 Permission is hereby granted, free of charge, to any person
8 obtaining a copy of this software and associated documentation
9 files (the "Software"), to deal in the Software without
10 restriction, including without limitation the rights to use,
11 copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following
14 conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 OTHER DEALINGS IN THE SOFTWARE.
27 """
28
29 import os, sys
30
31 from common import Common, SHARE
32 from settings import Settings
33 from launcher import Launcher
34
35 def main():
36     with open(os.path.join(SHARE, 'version')) as buf:
37         tor_browser_launcher_version = buf.read().strip()
38
39     print _('Tor Browser Launcher')
40     print _('By Micah Lee, licensed under BSD')
41     print _('version {0}').format(tor_browser_launcher_version)
42     print 'https://github.com/micahflee/torbrowser-launcher'
43
44     common = Common(tor_browser_launcher_version)
45
46     # is torbrowser-launcher already running?
47     tbl_pid = common.get_pid(common.paths['tbl_bin'], True)
48     if tbl_pid:
49         print _('Tor Browser Launcher is already running (pid {0}), bringing to front').format(tbl_pid)
50         common.bring_window_to_front(tbl_pid)
51         sys.exit()
52
53     if '-settings' in sys.argv:
54         # settings mode
55         app = Settings(common)
56
57     else:
58         # launcher mode
59         app = Launcher(common)
60
61 if __name__ == "__main__":
62     main()
63