PageRenderTime 30ms CodeModel.GetById 20ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/win32/config.py

https://bitbucket.org/tortoisehg/hgtk/
Python | 35 lines | 18 code | 5 blank | 12 comment | 1 complexity | 1bc3fa23743b3b78752d67a65474b138 MD5 | raw file
 1"""
 2config.py
 3 Copyright (C) 2009 Steve Borho <steve@borho.org>
 4
 5This software may be used and distributed according to the terms
 6of the GNU General Public License, incorporated herein by reference.
 7"""
 8
 9# This version of config.py is used in the binary installer
10# distributions of TortoiseHg on Windows.  Since we no longer need to
11# worry about Python shell extensions, we can use the path of the
12# current executable to find our package data.
13
14import os
15import sys
16import win32api, win32process
17
18proc = win32api.GetCurrentProcess()
19try:
20    # This will fail on windows < NT
21    procpath = win32process.GetModuleFileNameEx(proc, 0)
22except:
23    procpath = win32api.GetModuleFileName(0)
24
25bin_path = os.path.dirname(procpath)
26license_path = os.path.join(bin_path, 'COPYING.txt')
27locale_path = os.path.join(bin_path, 'locale')
28icon_path = os.path.join(bin_path, 'icons')
29
30enc = sys.getfilesystemencoding()
31if enc:
32    bin_path = bin_path.encode(enc)
33    license_path = license_path.encode(enc)
34    locale_path = locale_path.encode(enc)
35    icon_path = icon_path.encode(enc)