Skip to content

Commit

Permalink
chore: Add windows support as tier2
Browse files Browse the repository at this point in the history
It will be guaranteed that gallia does not use any linux only interfaces
and crashes on windows systems. That's all.
  • Loading branch information
rumpelsepp committed Jul 3, 2024
1 parent b97ba7d commit 247eb74
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
26 changes: 16 additions & 10 deletions src/gallia/command/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import argparse
import asyncio
import fcntl
import os
import os.path
import shutil
Expand All @@ -20,6 +19,9 @@
from tempfile import gettempdir
from typing import cast

if sys.platform != "windows":
import fcntl

import exitcode
import msgspec

Expand Down Expand Up @@ -344,7 +346,9 @@ def prepare_artifactsdir(
artifacts_dir.mkdir(parents=True)

self._dump_environment(artifacts_dir.joinpath(FileNames.ENV.value))
self._add_latest_link(command_dir)

if sys.platform != "windows":
self._add_latest_link(command_dir)

return artifacts_dir.absolute()

Expand All @@ -369,12 +373,13 @@ def _release_flock(self) -> None:
os.close(self._lock_file_fd)

def entry_point(self, args: Namespace) -> int:
if (p := args.lock_file) is not None:
try:
self._aquire_flock(p)
except OSError as e:
logger.critical(f"Unable to lock {p}: {e}")
return exitcode.OSFILE
if sys.platform != "windows":
if (p := args.lock_file) is not None:
try:
self._aquire_flock(p)
except OSError as e:
logger.critical(f"Unable to lock {p}: {e}")
return exitcode.OSFILE

if self.HAS_ARTIFACTS_DIR:
self.artifacts_dir = self.prepare_artifactsdir(
Expand Down Expand Up @@ -433,8 +438,9 @@ def entry_point(self, args: Namespace) -> int:
if args.hooks:
self.run_hook(HookVariant.POST, args, exit_code)

if self._lock_file_fd is not None:
self._release_flock()
if sys.platform != "windows":
if self._lock_file_fd is not None:
self._release_flock()

return exit_code

Expand Down
29 changes: 17 additions & 12 deletions src/gallia/transports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,42 @@
import sys

from gallia.transports.base import BaseTransport, TargetURI
from gallia.transports.can import RawCANTransport
from gallia.transports.doip import DoIPTransport
from gallia.transports.isotp import ISOTPTransport
from gallia.transports.tcp import TCPLinesTransport, TCPTransport
from gallia.transports.unix import UnixLinesTransport, UnixTransport

registry: list[type[BaseTransport]] = [
DoIPTransport,
ISOTPTransport,
RawCANTransport,
TCPLinesTransport,
TCPTransport,
UnixLinesTransport,
UnixTransport,
]

__all__ = [
"BaseTransport",
"DoIPTransport",
"ISOTPTransport",
"RawCANTransport",
"TCPLinesTransport",
"TCPTransport",
"UnixLinesTransport",
"UnixTransport",
"TargetURI",
]


if sys.platform == "linux":
from gallia.transports.isotp import ISOTPTransport
registry.append(ISOTPTransport)
__all__.append("ISOTPTransport")

from gallia.transports.can import RawCANTransport
registry.append(RawCANTransport)
__all__.append("RawCANTransport")

from gallia.transports.unix import UnixLinesTransport, UnixTransport
registry.append(UnixLinesTransport)
__all__.append("UnixLinesTransport")
registry.append(UnixTransport)
__all__.append("UnixTransport")


if sys.platform == "windows":
from gallia.transports import vector
from gallia.transports.vector import vector

registry.append(vector.FlexrayTransport)
__all__.append("FlexrayTransport")

0 comments on commit 247eb74

Please sign in to comment.