home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- import os
- import sys
- import shutil
- import locale
- import wx
- import util
- import stdpaths
- import path
- from ctypes import windll
- import logging
- log = logging.getLogger('AutoUpdate')
-
- def platform_cleanup():
- return _remove_virtual_store()
-
-
- def get_exe_name():
- return util.program_dir().relpathto(path.path(sys._real_exe.decode(locale.getpreferredencoding())))
-
-
- def _remove_virtual_store():
- if not os.name == 'nt':
- return []
- import gui.native.win.winutil as winutil
- if not winutil.is_vista():
- return []
- to_remove = []
- for virtual_store in (stdpaths.userlocaldata / 'VirtualStore' / 'Program Files' / 'Digsby', stdpaths.userlocaldata / 'VirtualStore' / 'Program Files (x86)' / 'Digsby'):
- util.traceguard.__enter__()
-
- try:
- if virtual_store.isdir():
- to_remove.extend(virtual_store.walkfiles())
- finally:
- pass
-
-
- return to_remove
-
-
- def get_top_level_hwnd():
- splash = wx.FindWindowByName('Digsby Login Window')
- if splash is None:
- topwins = wx.GetTopLevelWindows()
- if isinstance(topwins, list) and topwins:
- topwins = topwins[0]
-
- splash = None if topwins else None
-
- if splash is not None:
- return splash.Handle
-
-
- def restart_and_update(tempdir):
- import atexit
- atexit.register(_launch_updater, tempdir)
- force_restart_timer = util.Timer(7, _launch_updater, tempdir)
- if wx.GetApp().DigsbyCleanupAndQuit():
- force_restart_timer.start()
-
-
-
- def _launch_updater(tempdir):
- ShellExecute = windll.shell32.ShellExecuteW
- POST_UPDATE_EXE = 'Digsby Updater.exe'
- UPDATE_EXE = 'Digsby PreUpdater.exe'
- tempdir = path.path(tempdir)
- exc = get_exe_name()
- for EXE in (POST_UPDATE_EXE, UPDATE_EXE):
- if sys.DEV:
- updater = path.path('ext') / 'msw' / EXE
- else:
- updater = path.path(sys.executable.decode(locale.getpreferredencoding())).parent / 'lib' / EXE
- if not updater.isfile():
- raise AssertionError('could not find %s' % updater)
- updater.isfile()
- updater.copy2(tempdir.parent)
- updater = tempdir.parent / updater.name
- if not updater.isfile():
- raise AssertionError('could not copy %s to %s' % updater.name, tempdir.parent)
- updater.isfile()
- log.info('updater path is %r', updater)
-
- hwnd = get_top_level_hwnd()
- log.info('top level window HWND is %s', hwnd)
- SW_SHOWNORMAL = 1
- SE_ERR_ACCESSDENIED = 5
- params = u'supersecret "%s" "%s"' % (tempdir.parent, exc)
- log.info('%s %s', updater, params)
- res = ShellExecute(hwnd, None, updater, params, None, SW_SHOWNORMAL)
- if res > 32:
- log.info('ShellExecute successful: %s', res)
- elif res == SE_ERR_ACCESSDENIED:
- log.info('access denied')
- else:
- log.info('ShellExecute error: %s', res)
-
-