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

Testing #13

Merged
merged 10 commits into from
Jun 25, 2023
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/lint_and_pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
python -m pip install --upgrade pip
pip install flake8 pytest
python -m pip install -e .
# - name: Lint with flake8
# run: |
# flake8 .
- name: Lint with flake8
run: |
flake8 .
- name: Test with pytest
run: |
pytest
16 changes: 10 additions & 6 deletions ptsl/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ def __init__(self,

..note:: If `certificate_path` is given, the legacy AuthorizeConnection
method will be used for setting up the connection session. If it is
`None`, then `company_name` and `application_name` will be used with
the RegisterConnection method (available since Pro Tools 2023.3).
`None`, then `company_name` and `application_name` will be used
with the RegisterConnection method (available since Pro Tools
2023.3).
"""

self.channel = grpc.insecure_channel(address)
Expand All @@ -122,7 +123,8 @@ def __init__(self,

else:
raise AssertionError(
"company_name and application_name parameters were not given")
"company_name and application_name parameters were " +
"not given")

self.is_open = True

Expand Down Expand Up @@ -276,8 +278,9 @@ def _primitive_register_connection(self, company_name: str,
This method is called automatically by the initializer.
"""

req = pt.RegisterConnectionRequestBody(company_name=company_name,
application_name=application_name)
req = pt.RegisterConnectionRequestBody(
company_name=company_name,
application_name=application_name)

req_json = json_format.MessageToJson(req,
preserving_proto_field_name=True)
Expand All @@ -297,7 +300,8 @@ def _primitive_register_connection(self, company_name: str,

def _primitive_authorize_connection(self, api_key_path) -> Optional[str]:
"""
(Deprecated) Authorizes the client's connection to the Pro Tools RPC server.
(Deprecated) Authorizes the client's connection to the Pro Tools RPC
server.

This method is called automatically by the initializer.
"""
Expand Down
43 changes: 24 additions & 19 deletions ptsl/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def ptsl_version(self) -> int:
op = ops.GetPTSLVersion()
self.client.run(op)
assert isinstance(
op.response, pt.GetPTSLVersionResponseBody), f"Expected response body, encountered {op.response}"
op.response, pt.GetPTSLVersionResponseBody), \
f"Expected response body, encountered {op.response}"

return op.response.version

Expand Down Expand Up @@ -253,20 +254,22 @@ def save_session_as(self, path: str, name: str):
op = ops.SaveSessionAs(session_name=name, session_location=path)
self.client.run(op)

def export_session_as_text(self,
include_clip_list: bool = False,
include_file_list: bool = False,
include_markers: bool = False,
include_plugin_list: bool = False,
include_track_edls: bool = False,
show_sub_frames: bool = False,
track_list_type: Optional[pt.TrackListType] = pt.SelectedTracksOnly,
include_user_timestamp=False,
fade_handling_type: pt.FadeHandlingType = pt.DontShowCrossfades,
track_offset_options: pt.TrackOffsetOptions = pt.TimeCode,
text_as_file_format: pt.TextAsFileFormat = pt.UTF8,
output_type: pt.ESI_OutputType = pt.ESI_String,
output_path: Optional[str] = None) -> str:
def export_session_as_text(
self,
include_clip_list: bool = False,
include_file_list: bool = False,
include_markers: bool = False,
include_plugin_list: bool = False,
include_track_edls: bool = False,
show_sub_frames: bool = False,
track_list_type: Optional[pt.TrackListType] =
pt.SelectedTracksOnly,
include_user_timestamp=False,
fade_handling_type: pt.FadeHandlingType = pt.DontShowCrossfades,
track_offset_options: pt.TrackOffsetOptions = pt.TimeCode,
text_as_file_format: pt.TextAsFileFormat = pt.UTF8,
output_type: pt.ESI_OutputType = pt.ESI_String,
output_path: Optional[str] = None) -> str:
"""
Export the open session as text.
"""
Expand Down Expand Up @@ -324,7 +327,8 @@ def extend_selection_to_target_tracks(self, tracks: List[str]):
"""
Extend selection to target tracks.

:param List[str] tracks: A list of track names to extend the selection to.
:param List[str] tracks: A list of track names to extend
the selection to.
"""
op = ops.ExtendSelectionToTargetTracks(tracks_to_extend_to=tracks)
self.client.run(op)
Expand Down Expand Up @@ -427,12 +431,13 @@ def edit_memory_location(self, location_number: int,
"""
Edit a memory location.

:param int location_number: Location number to edit (if location does not
exist, this will create a new location in 2023.6)
:param int location_number: Location number to edit (if location
does not exist, this will create a new location in 2023.6)
:param str name: Location name
:param str start_time: Start time
:param str end_time: End time
:param TimeProperties time_properties: Time properties, either this is a range or a marker
:param TimeProperties time_properties: Time properties, either this
is a range or a marker
:param MemoryLocationReference reference: Reference
:param MemoryLocationProperties general_properties: Location properties
:param str comments: Comment field
Expand Down
5 changes: 2 additions & 3 deletions ptsl/ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@
from .rename_selected_clip import RenameSelectedClip
from .rename_target_clip import RenameTargetClip
from .toggle_play_state import \
TogglePlayState, ToggleRecordEnable, \
PlayHalfSpeed, RecordHalfSpeed
TogglePlayState, ToggleRecordEnable, \
PlayHalfSpeed, RecordHalfSpeed

from .memory_locations import EditMemoryLocation, GetMemoryLocations

1 change: 1 addition & 0 deletions ptsl/ops/export_selected_tracks_as_aaf_omf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ptsl.ops import Operation


class ExportSelectedTracksAsAAFOMF(Operation):
pass
2 changes: 1 addition & 1 deletion ptsl/ops/export_session_info_as_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# https://duc.avid.com/showthread.php?t=422971
class ExportSessionInfoAsText(Operation):

@classmethod
def response_body(cls):
return None
5 changes: 2 additions & 3 deletions ptsl/ops/extend_selection_to_target_tracks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ptsl import PTSL_pb2 as pt

from .operation import Operation


class ExtendSelectionToTargetTracks(Operation):
pass
pass
1 change: 1 addition & 0 deletions ptsl/ops/get_dyamic_properties.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ptsl.ops import Operation


class GetDynamicProperties(Operation):
pass
1 change: 1 addition & 0 deletions ptsl/ops/get_file_location.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ptsl.ops import Operation


class GetFileLocation(Operation):
pass
14 changes: 7 additions & 7 deletions ptsl/ops/get_playback_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ptsl.ops import Operation


class GetPlaybackMode(Operation):
pass

Expand All @@ -14,13 +15,12 @@ def xform(x):

decoder = json.JSONDecoder()
decoded = decoder.decode(in_json)
if isinstance(['possible_settings'][0],str):
decoded['current_settings'] = [xform(x) for x in decoded['current_settings']]
decoded['possible_settings'] = [xform(x) for x in decoded['possible_settings']]
if isinstance(['possible_settings'][0], str):
decoded['current_settings'] = [
xform(x) for x in decoded['current_settings']]
decoded['possible_settings'] = [
xform(x) for x in decoded['possible_settings']]
encoder = json.JSONEncoder()
encoded = encoder.encode(decoded)

return encoded



return encoded
3 changes: 2 additions & 1 deletion ptsl/ops/get_ptsl_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ptsl.ops import Operation


class GetPTSLVersion(Operation):
pass
pass
1 change: 1 addition & 0 deletions ptsl/ops/get_record_mode.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ptsl.ops import Operation


class GetRecordMode(Operation):
pass
3 changes: 2 additions & 1 deletion ptsl/ops/get_session_audio_format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ptsl.ops import Operation


class GetSessionAudioFormat(Operation):
pass
pass
3 changes: 2 additions & 1 deletion ptsl/ops/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def on_empty_response_body(self):

def on_response_body(self, response_body: R):
"""
The client calls this when the server responds with a JSON `pt.ResponseBody`.
The client calls this when the server responds with a JSON
`pt.ResponseBody`.
"""
self.response = response_body
Loading