File: Application.py

package info (click to toggle)
cain 1.10+dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 29,856 kB
  • sloc: cpp: 49,612; python: 14,988; xml: 11,654; ansic: 3,644; makefile: 133; sh: 2
file content (45 lines) | stat: -rwxr-xr-x 1,430 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /usr/bin/env python

"""The script that launches Cain."""

import sys
import os
import os.path
import wx
from MainFrame import MainFrame
from resourcePath import resourcePath
from os.path import expanduser, join

class Application(wx.App):
    """The application class for Cain."""

    def __init__(self):
        """Construct the base class and redirect the output."""
        directory = os.path.join(os.path.expanduser('~'), '.cain')
        if not os.access(directory, os.W_OK):
            try:
                os.mkdir(directory)
            except:
                # If we can't get write permissions for the log file, don't
                # redirect the output.
                wx.App.__init__(self)
                return
        wx.App.__init__(self, redirect=True,
                        filename=os.path.join(directory, "ErrorLog.txt"))

    def OnInit(self):
        # Splash screen.
        image = wx.Image(os.path.join(resourcePath, "gui/splash.png"),
                         wx.BITMAP_TYPE_PNG)
        bmp = image.ConvertToBitmap()
        wx.SplashScreen(bmp, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
                        2000, None, -1)
        wx.Yield()
        # Main window.
        self.frame = MainFrame()
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

    def readInitialFile(self, inputFileName):
        self.frame.readFile(inputFileName, False)