Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Bare bones Linux port #91

Closed
wants to merge 1 commit into from
Closed
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
Binary file added cddagl/CDDA Game Launcher/configs.db
Binary file not shown.
4 changes: 3 additions & 1 deletion cddagl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: MIT

from cddagl.platform_api import is_windows
def fix_pywin32_loading():
try:
import pywintypes
Expand All @@ -11,7 +12,8 @@ def fix_pywin32_loading():
sys.path.append(r'win32\lib')
import pywin32_bootstrap

fix_pywin32_loading()
if is_windows():
fix_pywin32_loading()

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

import winutils
from pywintypes import com_error
from cddagl.platform_api.utils import is_windows

if is_windows():
import winutils
from pywintypes import com_error

import cddagl
from cddagl.i18n import proxy_gettext as _
Expand Down
5 changes: 4 additions & 1 deletion cddagl/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@
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_api import get_ui_locale, SingleInstance, write_named_pipe, is_windows

logger = logging.getLogger('cddagl')


def init_single_instance():
if not is_windows():
return None

if not config_true(get_config_value('allow_multiple_instances', 'False')):
single_instance = SingleInstance()

Expand Down
4 changes: 4 additions & 0 deletions cddagl/platform_api/PosixNotImplementedError.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class PosixNotImplementedError(NotImplementedError):
def __init__(self):
default_message = 'Not implemented for posix!'
super().__init__(default_message)
9 changes: 9 additions & 0 deletions cddagl/platform_api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from .utils import is_windows

if is_windows():
from .win32 import *
from pywintypes import error as PyWinError
else:
from .posix import *
from cddagl.posix_polyfill.pywintypes import PyWinError

62 changes: 62 additions & 0 deletions cddagl/platform_api/posix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import os

import psutil

from cddagl.platform_api.PosixNotImplementedError import PosixNotImplementedError


def get_ui_locale():
return None


def process_id_from_path(processName):
'''
Get a list of all the PIDs of all the running processes whose name contains
the given string processName
'''
pids = []
# Iterate over the all the running process
for proc in psutil.process_iter():
try:
if processName.lower() in proc.exe().lower():
pids.append(proc.pid)
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
if len(pids):
return pids[0]
else:
return None


def get_downloads_directory():
raise PosixNotImplementedError()


def find_process_with_file_handle(path):
raise PosixNotImplementedError()


def activate_window():
raise PosixNotImplementedError()


def wait_for_pid():
raise PosixNotImplementedError()


def get_documents_directory():
return os.path.join(os.path.expanduser('~'))


def write_named_pipe():
raise PosixNotImplementedError()


class SimpleNamedPipe:
def __int__(self, name):
raise PosixNotImplementedError()


class SingleInstance:
def __int__(self):
raise PosixNotImplementedError()
5 changes: 5 additions & 0 deletions cddagl/platform_api/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import platform


def is_windows():
return platform.system() == "Windows"
Loading