Beispiel #1
0
def tryGtk3Import():
    """Try GObject inspection to retrieve GTK
    (probably only works with GTK 3 and above)
    """
    global gi, Gtk, Gdk, loadedGtkMajor
    
    import sys
    
    # First step: Try to load gi module
    try:
        import gi
    except:
        import ExceptionLogger
        ExceptionLogger.logOptionalComponentException(
                "Import GI in GtkHacks.py"
                .format(WX_GTK_VER_STRING))
        
        return
    
    # Second step: Load required GTK version
    try:
        gi.require_version('Gtk', WX_GTK_VER_STRING)
        from gi.repository import Gtk, Gdk
    
        loadedGtkMajor = WX_GTK_MAJOR # Success
    except:
        # Failed:
        import ExceptionLogger
        ExceptionLogger.logOptionalComponentException(
                "Import GTK (version {0}) by GI in GtkHacks.py"
                .format(WX_GTK_VER_STRING))

        # Problem now: gi polluted sys.modules so that subsequent
        # gtk imports would fail.
        
        # Cleaning hack:
        
        for m in ('glib', 'gobject', 'gio', 'gtk', 'gtk.gdk'):
            try:
                if sys.modules.has_key(m) and \
                        isinstance(sys.modules[m], gi._DummyStaticModule):
                    del sys.modules[m]
            except:
                ExceptionLogger.logOptionalComponentException(
                        "Cleaning after GI, module name {0} in GtkHacks.py"
                        .format(m))
Beispiel #2
0
# from wxHelper import *

from . import MiscEvent

from .Utilities import DUMBTHREADSTOP

from .wxHelper import GUI_ID, XrcControls, autosizeColumn, wxKeyFunctionSink

from .WikiPyparsing import buildSyntaxNode

try:
    from .EnchantDriver import Dict
    from . import EnchantDriver
except (AttributeError, ImportError, WindowsError):
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
        "Initialize enchant driver (spell checking)")
    Dict = None

    # traceback.print_exc()

    # WindowsError may happen if an incomplete enchant installation is found
    # in the system

from .DocPages import AliasWikiPage, WikiPage


class SpellCheckerDialog(wx.Dialog):
    def __init__(self,
                 parent,
                 ID,
                 mainControl,
Beispiel #3
0

# import WindowsHacks

try:
    import WindowsHacks
except:
    if SystemInfo.isWindows():
        traceback.print_exc()
    WindowsHacks = None

try:
    import GtkHacks
except:
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
            "Initialize GTK hacks in OsAbstract.py")
    GtkHacks = None


# Define startFile
if SystemInfo.isWindows():
    if SystemInfo.isWinNT() and SystemInfo.isUnicode() and WindowsHacks:
        startFile = WindowsHacks.startFile
    else:
        def startFile(mainControl, link):
            os.startfile(mbcsEnc(link, "replace")[0])
else:
    def startFile(mainControl, link):
        # We need mainControl only for this version of startFile()
        
        startPath = mainControl.getConfig().get("main", "fileLauncher_path", u"")
Beispiel #4
0
from .Configuration import MIDDLE_MOUSE_CONFIG_TO_TABMODE

from . import OsAbstract

from . import DocPages
from .TempFileSet import TempFileSet

from . import PluginManager


# Try and load webkit renderer
try:
    import WikiHtmlViewWK
except:
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException("Initialize webkit HTML renderer")
    WikiHtmlViewWK = None


# Try and load Windows IE renderer
if isWindows():
    try:
        import WikiHtmlViewIE
    except:
        import ExceptionLogger
        ExceptionLogger.logOptionalComponentException("Initialize IE HTML renderer")
        WikiHtmlViewIE = None
else:
    WikiHtmlViewIE = None

Beispiel #5
0
# GtkHacks for the Clipboard Catcher


try:
    import LinuxHacks
except:
    if SystemInfo.isLinux():
        traceback.print_exc()
    LinuxHacks = None


try:
    import GtkHacks
except:
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
            "Initialize GTK hacks in OsAbstract.py")
    GtkHacks = None




# Define startFile
if SystemInfo.isWindows():
    if SystemInfo.isWinNT() and SystemInfo.isUnicode() and WindowsHacks:
        startFile = WindowsHacks.startFile
    else:
        def startFile(mainControl, link):
            os.startfile(mbcsEnc(link, "replace")[0])
else:
    def startFile(mainControl, link):
        # We need mainControl only for this version of startFile()
Beispiel #6
0
from ctypes import c_int, c_uint, c_long, c_ulong, c_ushort, c_char, c_char_p, \
        c_wchar_p, c_byte, byref, create_string_buffer, create_unicode_buffer, \
        c_void_p, string_at, sizeof, Structure   # , WindowsError

from . import SystemInfo

libc = ctypes.CDLL('libc.so.6', use_errno=True)

# Based on "bits/sched.h", see e.g. http://code.woboq.org/gcc/include/bits/sched.h.html
# and http://linux.die.net/man/2/sched_setaffinity
try:
    sched_setaffinity = libc.sched_setaffinity
    sched_getaffinity = libc.sched_getaffinity
except:
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
        "Link to sched_setaffinity() in LinuxHacks.py")

    sched_setaffinity = None
    sched_getaffinity = None

# int sched_setaffinity(pid_t pid, size_t cpusetsize,
#                       cpu_set_t *mask);

# Naming is based on the C definitions, sometimes with less leading underscores
# than in original code

size_t = c_ulong
_cpu_mask = c_ulong
_CPU_SETSIZE = 1024
_NCPUBITS = 8 * sizeof(_cpu_mask)
Beispiel #7
0
import os, os.path

from time import time, localtime
import datetime
import string, glob, traceback

from pwiki.WikiExceptions import *   # TODO make normal import
from pwiki import SearchAndReplace

try:
    import pwiki.sqlite3api as sqlite
    import DbStructure
    from DbStructure import createWikiDB, WikiDBExistsException
except:
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
            "Initialize external sqlite for original_sqlite/WikiData.py")
    sqlite = None
# finally:
#     pass

from pwiki.StringOps import getBinCompactForDiff, applyBinCompact, longPathEnc, \
        longPathDec, binCompactToCompact, fileContentToUnicode, utf8Enc, utf8Dec, \
        uniWithNone, loadEntireTxtFile, Conjunction, lineendToInternal
from pwiki.StringOps import loadEntireFile, writeEntireFile, \
        iterCompatibleFilename, getFileSignatureBlock, guessBaseNameByFilename, \
        createRandomString, pathDec

from ..BaseWikiData import BasicWikiData, SqliteWikiData, FileWikiData

import Consts
Beispiel #8
0
from . import SystemInfo



libc = ctypes.CDLL('libc.so.6', use_errno=True)


# Based on "bits/sched.h", see e.g. http://code.woboq.org/gcc/include/bits/sched.h.html
# and http://linux.die.net/man/2/sched_setaffinity
try:
    sched_setaffinity = libc.sched_setaffinity
    sched_getaffinity = libc.sched_getaffinity
except:
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
            "Link to sched_setaffinity() in LinuxHacks.py")
    
    sched_setaffinity = None
    sched_getaffinity = None


# int sched_setaffinity(pid_t pid, size_t cpusetsize,
#                       cpu_set_t *mask);

# Naming is based on the C definitions, sometimes with less leading underscores
# than in original code

size_t = c_ulong
_cpu_mask = c_ulong
_CPU_SETSIZE = 1024
_NCPUBITS = 8 * sizeof (_cpu_mask)
Beispiel #9
0


from os.path import exists, join, basename
import os, os.path

from time import time, localtime
import datetime
import string, glob, traceback

try:
#     tracer.runctx('import gadfly', globals(), locals())
    import gadfly
except ImportError:
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
            "Initialize gadfly for original_gadfly/WikiData.py")
    gadfly = None
# finally:
#     pass

if gadfly is not None:
    import DbStructure
    from DbStructure import createWikiDB


import Consts
from pwiki.WikiExceptions import *   # TODO make normal import?
from pwiki import SearchAndReplace

from pwiki.StringOps import longPathEnc, longPathDec, utf8Enc, utf8Dec, BOM_UTF8, \
        fileContentToUnicode, loadEntireTxtFile, loadEntireFile, \
Beispiel #10
0
from . import MiscEvent

from .Utilities import DUMBTHREADSTOP

from .wxHelper import GUI_ID, XrcControls, autosizeColumn, wxKeyFunctionSink

from .WikiPyparsing import buildSyntaxNode


try:
    from .EnchantDriver import Dict
    from . import EnchantDriver
except (AttributeError, ImportError, WindowsError):
    import ExceptionLogger
    ExceptionLogger.logOptionalComponentException(
            "Initialize enchant driver (spell checking)")
    Dict = None

    # traceback.print_exc()
    
    # WindowsError may happen if an incomplete enchant installation is found
    # in the system


from .DocPages import AliasWikiPage, WikiPage



class SpellCheckerDialog(wx.Dialog):
    def __init__(self, parent, ID, mainControl, title=None,
                 pos=wx.DefaultPosition, size=wx.DefaultSize,