Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

Commit

Permalink
make python3 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
lebrunthibault committed Apr 23, 2023
1 parent 3fd38cf commit 0dc418b
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 48 deletions.
3 changes: 1 addition & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import sys
from os.path import dirname

if sys.version_info.major == 2:
sys.path.insert(0, "%s\\venv\\Lib\\site-packages" % dirname(os.path.realpath(__file__)))
sys.path.insert(0, "%s\\venv\\Lib\\site-packages" % dirname(os.path.realpath(__file__)))

live_environment_loaded = "Live" in sys.modules

Expand Down
3 changes: 0 additions & 3 deletions application/Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from protocol0.domain.audit.AudioLatencyAnalyzerService import AudioLatencyAnalyzerService
from protocol0.domain.audit.LogService import LogService
from protocol0.domain.audit.SetFixerService import SetFixerService
from protocol0.domain.audit.SetProfilingService import SetProfilingService
from protocol0.domain.audit.SetUpgradeService import SetUpgradeService
from protocol0.domain.audit.SongStatsService import SongStatsService
from protocol0.domain.lom.device.DeviceDisplayService import DeviceDisplayService
Expand Down Expand Up @@ -186,7 +185,6 @@ def __init__(self, control_surface):
)
log_service = LogService(ableton_set, track_mapper_service, matching_track_service)

set_profiling_service = SetProfilingService()
song_stats_service = SongStatsService()

self._register(midi_service)
Expand Down Expand Up @@ -229,7 +227,6 @@ def __init__(self, control_surface):
self._register(log_service)
self._register(set_upgrade_service)
self._register(set_fixer_service)
self._register(set_profiling_service)
self._register(song_stats_service)

self._register(session_to_arrangement_service)
Expand Down
6 changes: 3 additions & 3 deletions application/control_surface/group/ActionGroupTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from protocol0.application.control_surface.ActionGroupInterface import ActionGroupInterface
from protocol0.domain.audit.AudioLatencyAnalyzerService import AudioLatencyAnalyzerService
from protocol0.domain.audit.SetProfilingService import SetProfilingService
from protocol0.domain.lom.clip.AudioClip import AudioClip
from protocol0.domain.lom.track.simple_track.audio.SimpleAudioTrack import SimpleAudioTrack
from protocol0.domain.shared.backend.Backend import Backend
from protocol0.shared.Song import Song
from protocol0.shared.logging.Logger import Logger

Expand All @@ -25,7 +25,7 @@ def configure(self):
self.add_encoder(
identifier=2,
name="start set launch time profiling",
on_press=self._container.get(SetProfilingService).profile_set,
on_press=Backend.client().start_set_profiling,
)

# CLR encoder
Expand Down Expand Up @@ -56,4 +56,4 @@ def action_log_midi(self):
def action_test(self):
# type: () -> None
from protocol0.shared.logging.Logger import Logger
Logger.dev(Song.selected_clip())
Logger.dev("toto")
7 changes: 4 additions & 3 deletions application/error/SentryService.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sentry_sdk
from typing import Dict, Any

from protocol0.shared.Config import Config
Expand All @@ -9,11 +8,13 @@ class SentryService(object):
def __init__(self):
# type: () -> None
self.activated = False
self.sdk = sentry_sdk

def activate(self):
# type: () -> None
self.sdk.init(
# noinspection PyUnresolvedReferences
import sentry_sdk

sentry_sdk.init(
dsn=Config.SENTRY_DSN,
before_send=self._before_send,
# Set traces_sample_rate to 1.0 to capture 100%
Expand Down
22 changes: 0 additions & 22 deletions domain/audit/SetProfilingService.py

This file was deleted.

3 changes: 2 additions & 1 deletion domain/audit/stats/Stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Dict, Protocol
from typing_extensions import Protocol
from typing import Dict


class Stats(Protocol):
Expand Down
5 changes: 3 additions & 2 deletions domain/lom/song/SongInitService.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ def init_song(self):
CommandBus.dispatch(ResetPlaybackCommand())

DomainEventBus.emit(SongInitializedEvent())
ApplicationView.show_session()
seq = Sequence()
seq.wait(10)
seq.wait(2)
seq.add(ApplicationView.show_session)
seq.wait(8)

if not self._ableton_set.is_unknown and not self._ableton_set.is_test:
seq.add(self._check_sound_id_device)
Expand Down
2 changes: 1 addition & 1 deletion domain/lom/track/P0TrackInterface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Live
from typing import Protocol
from typing_extensions import Protocol


class P0TrackInterface(Protocol):
Expand Down
4 changes: 1 addition & 3 deletions domain/lom/track/simple_track/SimpleTrackClips.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from collections import Iterator

from typing import List, TYPE_CHECKING
from typing import List, TYPE_CHECKING, Iterator

from protocol0.domain.lom.clip.Clip import Clip
from protocol0.domain.lom.track.simple_track.SimpleTrackClipColorManager import \
Expand Down
3 changes: 2 additions & 1 deletion domain/shared/LiveObject.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Protocol, Any
from typing_extensions import Protocol
from typing import Any


def liveobj_valid(obj):
Expand Down
2 changes: 1 addition & 1 deletion domain/shared/event/HasEmitter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Protocol, runtime_checkable
from typing_extensions import Protocol, runtime_checkable


@runtime_checkable
Expand Down
1 change: 1 addition & 0 deletions domain/shared/utils/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def smart_string(s):

if not isinstance(s, basestring):
s = str(s)

try:
return s.decode("utf-8").encode("ascii", "ignore")
except UnicodeEncodeError:
Expand Down
8 changes: 6 additions & 2 deletions infra/logging/LoggerService.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
import sys
import types

from typing import Optional, Any, List, Dict
Expand Down Expand Up @@ -27,7 +28,7 @@ def log(self, message, debug=True, level=None):

Logger.warning(e)

if not isinstance(message, basestring):
if sys.version_info.major == 2 and not isinstance(message, basestring):
message = str(message)

level = level or LogLevelEnum.INFO
Expand All @@ -48,5 +49,8 @@ def log(self, message, debug=True, level=None):
frame_info.method_name,
)
for line in message.splitlines():
line = "P0 - %s" % line.decode("utf-8").encode("ascii", "replace")
if sys.version_info.major == 2:
line.decode("utf-8").encode("ascii", "replace")

line = "P0 - %s" % line
logging.info(line)
Binary file modified requirements.txt
Binary file not shown.
2 changes: 1 addition & 1 deletion shared/Song.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import traceback
from collections import Iterator
from typing import Iterator

import Live
from typing import TYPE_CHECKING, Optional, List, cast, Type
Expand Down
2 changes: 1 addition & 1 deletion shared/logging/StatusBar.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import Callable
from typing import Callable

from typing import Optional

Expand Down
2 changes: 1 addition & 1 deletion shared/observer/Observer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Protocol, TYPE_CHECKING
from typing_extensions import Protocol, TYPE_CHECKING

if TYPE_CHECKING:
from protocol0.shared.observer.Observable import Observable
Expand Down
3 changes: 2 additions & 1 deletion shared/sequence/HasSequenceState.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Protocol, runtime_checkable, Any
from typing_extensions import Protocol, runtime_checkable
from typing import Any

from protocol0.shared.observer.Observer import Observer
from protocol0.shared.sequence.SequenceState import SequenceState
Expand Down

0 comments on commit 0dc418b

Please sign in to comment.