Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions cddagl/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
def fix_pywin32_loading():
try:
import pywintypes
except ImportError:
import sys
sys.path.append(r'win32')
sys.path.append(r'win32\lib')
import pywin32_bootstrap

fix_pywin32_loading()
from cddagl.platform import prelaunch_platform_fix
prelaunch_platform_fix()

import cddagl.launcher
cddagl.launcher.run_cddagl()
8 changes: 4 additions & 4 deletions cddagl/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import traceback
from io import StringIO

import winutils
from pywintypes import com_error
from cddagl.platform import winutils
from cddagl.platform import pywintypes_com_error

import cddagl
from cddagl.i18n import proxy_gettext as _
Expand Down Expand Up @@ -108,7 +108,7 @@ def delete_path(path):

try:
return winutils.delete(path, flags)
except com_error:
except pywintypes_com_error:
return False

def move_path(srcpath, dstpath):
Expand All @@ -134,7 +134,7 @@ def move_path(srcpath, dstpath):

try:
return winutils.move(srcpath, dstpath, flags)
except com_error:
except pywintypes_com_error:
return False

def safe_humanize(arrow_date, other=None, locale='en_us', only_distance=False, granularity='auto'):
Expand Down
2 changes: 1 addition & 1 deletion cddagl/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from cddagl.sql.functions import init_config, get_config_value, config_true
from cddagl.ui.views.dialogs import ExceptionWindow
from cddagl.ui.views.tabbed import TabbedWindow
from cddagl.win32 import get_ui_locale, SingleInstance, write_named_pipe
from cddagl.platform import get_ui_locale, SingleInstance, write_named_pipe

logger = logging.getLogger('cddagl')

Expand Down
7 changes: 7 additions & 0 deletions cddagl/platform/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import platform

if platform.system() == "Linux":
from .linux import *
else:
from .windows.win32 import *
from .windows.lib import *
46 changes: 46 additions & 0 deletions cddagl/platform/linux.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
########## win32 ##########
find_process_with_file_handle = None
get_downloads_directory = None
activate_window = None
process_id_from_path = None
wait_for_pid = None
get_documents_directory = None
# get_ui_locale = None
# SimpleNamedPipe = None
# SingleInstance = None
write_named_pipe = None

def get_ui_locale():
return 'en_US'

def get_documents_directory():
return "/home/armor/tmp"

class SingleInstance:
def __init__(self):
pass

def aleradyrunning(self):
return False

class SimpleNamedPipe:
def __init__(self, pipe_name):
pass

def connect(self):
pass

def read(self):
pass

def write(self, data):
pass

def prelaunch_platform_fix():
pass

########## lib ##########
pywintypes_error = None
pywintypes_com_error = None

winutils = None
Empty file.
12 changes: 12 additions & 0 deletions cddagl/platform/windows/lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from pywintypes import error as pywintypes_error, com_error as pywintypes_com_error
import winutils

def prelaunch_platform_fix():
# fix_pywin32_loading
try:
import pywintypes
except ImportError:
import sys
sys.path.append(r'win32')
sys.path.append(r'win32\lib')
import pywin32_bootstrap
File renamed without changes.
2 changes: 1 addition & 1 deletion cddagl/ui/views/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from cddagl.functions import sizeof_fmt, safe_filename, alphanum_key, delete_path, safe_humanize
from cddagl.i18n import proxy_gettext as _
from cddagl.sql.functions import get_config_value, set_config_value, config_true
from cddagl.win32 import find_process_with_file_handle
from cddagl.platform import find_process_with_file_handle

logger = logging.getLogger('cddagl')

Expand Down
2 changes: 1 addition & 1 deletion cddagl/ui/views/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from cddagl.constants import get_resource_path
from cddagl.functions import clean_qt_path, bitness
from cddagl.i18n import proxy_gettext as _
from cddagl.win32 import get_downloads_directory
from cddagl.platform import get_downloads_directory

import markdown2

Expand Down
4 changes: 2 additions & 2 deletions cddagl/ui/views/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)
from PyQt5.QtGui import QRegularExpressionValidator
from babel.dates import format_datetime
from pywintypes import error as PyWinError
from cddagl.platform import pywintypes_error as PyWinError

import cddagl.constants as cons
from cddagl.constants import get_cddagl_path, get_cdda_uld_path
Expand All @@ -46,7 +46,7 @@
get_config_value, set_config_value, new_version, get_build_from_sha256,
new_build, config_true
)
from cddagl.win32 import (
from cddagl.platform import (
find_process_with_file_handle, activate_window, process_id_from_path, wait_for_pid,
get_documents_directory
)
Expand Down
2 changes: 1 addition & 1 deletion cddagl/ui/views/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from cddagl.functions import clean_qt_path
from cddagl.i18n import load_gettext_locale, get_available_locales, proxy_gettext as _
from cddagl.sql.functions import get_config_value, set_config_value, config_true
from cddagl.win32 import get_ui_locale
from cddagl.platform import get_ui_locale

logger = logging.getLogger('cddagl')

Expand Down
4 changes: 2 additions & 2 deletions cddagl/ui/views/tabbed.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
QAction, QDialog, QTabWidget, QCheckBox, QMessageBox, QMenu
)
from PyQt5.QtGui import QDesktopServices
from pywintypes import error as PyWinError
from cddagl.platform import pywintypes_error as PyWinError

import cddagl.constants as cons
from cddagl import __version__ as version
Expand All @@ -33,7 +33,7 @@
from cddagl.ui.views.main import MainTab
from cddagl.ui.views.settings import SettingsTab
from cddagl.ui.views.soundpacks import SoundpacksTab
from cddagl.win32 import SimpleNamedPipe
from cddagl.platform import SimpleNamedPipe

logger = logging.getLogger('cddagl')

Expand Down