55`controller.py`.
66"""
77
8- import warnings
8+ # import warnings
9+
10+ # Loading constants Constants.py
11+ from pipewire_python ._constants import (
12+ MESSAGES_ERROR ,
13+ RECOMMENDED_FORMATS ,
14+ RECOMMENDED_RATES ,
15+ )
916
1017# Loading internal functions
11- from ._utils import (
18+ from pipewire_python ._utils import (
1219 _drop_keys_with_none_values ,
1320 _execute_shell_command ,
1421 _filter_by_type ,
1825 _get_dict_from_stdout ,
1926)
2027
21- # Loading constants Constants.py
22- from ._constants import MESSAGES_ERROR , RECOMMENDED_FORMATS , RECOMMENDED_RATES
23-
2428# [DEPRECATED] [FLAKE8] TO_AVOID_F401 PEP8
2529# [DEPRECATED] https://stackoverflow.com/a/31079085/10491422
2630# NOW USED IN DOCUMENTATION
@@ -103,7 +107,9 @@ def __init__(
103107 # get default parameters with help
104108 stdout , _ = _execute_shell_command (command = mycommand , verbose = verbose ) # stderr
105109 # convert stdout to dictionary
106- dict_default_values = _get_dict_from_stdout (stdout = str (stdout .decode ()), verbose = verbose )
110+ dict_default_values = _get_dict_from_stdout (
111+ stdout = str (stdout .decode ()), verbose = verbose
112+ )
107113
108114 if verbose :
109115 print (self ._pipewire_configs )
@@ -164,7 +170,9 @@ def get_version(
164170 if verbose :
165171 print (f"[mycommand]{ mycommand } " )
166172
167- stdout , _ = _execute_shell_command (command = mycommand , timeout = - 1 , verbose = verbose )
173+ stdout , _ = _execute_shell_command (
174+ command = mycommand , timeout = - 1 , verbose = verbose
175+ )
168176 versions = stdout .decode ().split ("\n " )[1 :]
169177
170178 self ._pipewire_cli ["--version" ] = versions
@@ -311,7 +319,9 @@ def set_config(
311319 elif target is None :
312320 pass
313321 else :
314- raise ValueError (f"{ MESSAGES_ERROR ['ValueError' ]} [target='{ target } '] EMPTY VALUE" )
322+ raise ValueError (
323+ f"{ MESSAGES_ERROR ['ValueError' ]} [target='{ target } '] EMPTY VALUE"
324+ )
315325 # 5 - latency
316326 if latency :
317327 if any (chr .isdigit () for chr in latency ): # Contain numbers
@@ -323,7 +333,9 @@ def set_config(
323333 elif latency is None :
324334 pass
325335 else :
326- raise ValueError (f"{ MESSAGES_ERROR ['ValueError' ]} [latency='{ latency } '] EMPTY VALUE" )
336+ raise ValueError (
337+ f"{ MESSAGES_ERROR ['ValueError' ]} [latency='{ latency } '] EMPTY VALUE"
338+ )
327339 # 6 - rate
328340 if rate :
329341 if rate in RECOMMENDED_RATES :
@@ -336,7 +348,9 @@ def set_config(
336348 elif rate is None :
337349 pass
338350 else :
339- raise ValueError (f"{ MESSAGES_ERROR ['ValueError' ]} [rate='{ rate } '] EMPTY VALUE" )
351+ raise ValueError (
352+ f"{ MESSAGES_ERROR ['ValueError' ]} [rate='{ rate } '] EMPTY VALUE"
353+ )
340354 # 7 - channels
341355 if channels :
342356 if channels in [1 , 2 ]: # values
@@ -349,7 +363,9 @@ def set_config(
349363 elif channels is None :
350364 pass
351365 else :
352- raise ValueError (f"{ MESSAGES_ERROR ['ValueError' ]} [channels='{ channels } '] EMPTY VALUE" )
366+ raise ValueError (
367+ f"{ MESSAGES_ERROR ['ValueError' ]} [channels='{ channels } '] EMPTY VALUE"
368+ )
353369 # 8 - channels-map
354370 if channels_map :
355371 self ._pipewire_configs ["--channels-map" ] = str (channels_map )
@@ -371,7 +387,9 @@ def set_config(
371387 elif _format is None :
372388 pass
373389 else :
374- raise ValueError (f"{ MESSAGES_ERROR ['ValueError' ]} [_format='{ _format } '] EMPTY VALUE" )
390+ raise ValueError (
391+ f"{ MESSAGES_ERROR ['ValueError' ]} [_format='{ _format } '] EMPTY VALUE"
392+ )
375393 # 10 - volume
376394 if volume :
377395 if 0.0 <= volume <= 1.0 :
@@ -384,7 +402,9 @@ def set_config(
384402 elif volume is None :
385403 pass
386404 else :
387- raise ValueError (f"{ MESSAGES_ERROR ['ValueError' ]} [volume='{ volume } '] EMPTY VALUE" )
405+ raise ValueError (
406+ f"{ MESSAGES_ERROR ['ValueError' ]} [volume='{ volume } '] EMPTY VALUE"
407+ )
388408 # 11 - quality
389409 if quality :
390410 if 0 <= quality <= 15 :
@@ -396,7 +416,9 @@ def set_config(
396416 elif quality is None :
397417 pass
398418 else :
399- raise ValueError (f"{ MESSAGES_ERROR ['ValueError' ]} [volume='{ volume } '] EMPTY VALUE" )
419+ raise ValueError (
420+ f"{ MESSAGES_ERROR ['ValueError' ]} [volume='{ volume } '] EMPTY VALUE"
421+ )
400422
401423 # 12 - verbose cli
402424 if verbose : # True
@@ -419,13 +441,17 @@ def load_list_targets(
419441
420442 if mode == "playback" :
421443 mycommand = ["pw-cat" , "--playback" , "--list-targets" ]
422- stdout , _ = _execute_shell_command (command = mycommand , timeout = - 1 , verbose = verbose )
444+ stdout , _ = _execute_shell_command (
445+ command = mycommand , timeout = - 1 , verbose = verbose
446+ )
423447 self ._pipewire_list_targets ["list_playback" ] = _generate_dict_list_targets (
424448 longstring = stdout .decode (), verbose = verbose
425449 )
426450 elif mode == "record" :
427451 mycommand = ["pw-cat" , "--record" , "--list-targets" ]
428- stdout , _ = _execute_shell_command (command = mycommand , timeout = - 1 , verbose = verbose )
452+ stdout , _ = _execute_shell_command (
453+ command = mycommand , timeout = - 1 , verbose = verbose
454+ )
429455 self ._pipewire_list_targets ["list_record" ] = _generate_dict_list_targets (
430456 longstring = stdout .decode (), verbose = verbose
431457 )
@@ -503,10 +529,13 @@ def get_list_interfaces(
503529 ```
504530 Args:
505531 filtered_by_type : If False, returns all. If not, returns a fitered dict
506- type_interfaces : Set type of Interface ["Client","Link","Node","Factory","Module","Metadata","Endpoint","Session","Endpoint Stream","EndpointLink","Port"]
532+ type_interfaces : Set type of Interface
533+ ["Client","Link","Node","Factory","Module","Metadata","Endpoint",
534+ "Session","Endpoint Stream","EndpointLink","Port"]
507535
508536 Returns:
509- - dict_interfaces_filtered: dictionary with list of interfaces matching conditions
537+ - dict_interfaces_filtered: dictionary
538+ with list of interfaces matching conditions
510539
511540 Examples:
512541 ```python
@@ -519,8 +548,12 @@ def get_list_interfaces(
519548 # if verbose:
520549 # print(f"[mycommand]{mycommand}")
521550
522- stdout , _ = _execute_shell_command (command = mycommand , timeout = - 1 , verbose = verbose )
523- dict_interfaces = _generate_dict_interfaces (longstring = stdout .decode (), verbose = verbose )
551+ stdout , _ = _execute_shell_command (
552+ command = mycommand , timeout = - 1 , verbose = verbose
553+ )
554+ dict_interfaces = _generate_dict_interfaces (
555+ longstring = stdout .decode (), verbose = verbose
556+ )
524557
525558 if filtered_by_type :
526559 dict_interfaces_filtered = _filter_by_type (
@@ -554,16 +587,20 @@ def playback(
554587 - stdout (`str`): Shell response to the command in stdout format
555588 - stderr (`str`): Shell response response to the command in stderr format
556589 """
557- warnings .warn ("The name of the function may change on future releases" , DeprecationWarning )
590+ # warnings.warn("The name of the function may change on future releases", DeprecationWarning)
558591
559- mycommand = ["pw-cat" , "--playback" , audio_filename ] + _generate_command_by_dict (
560- mydict = self ._pipewire_configs , verbose = verbose
561- )
592+ mycommand = [
593+ "pw-cat" ,
594+ "--playback" ,
595+ audio_filename ,
596+ ] + _generate_command_by_dict (mydict = self ._pipewire_configs , verbose = verbose )
562597
563598 if verbose :
564599 print (f"[mycommand]{ mycommand } " )
565600
566- stdout , stderr = _execute_shell_command (command = mycommand , timeout = - 1 , verbose = verbose )
601+ stdout , stderr = _execute_shell_command (
602+ command = mycommand , timeout = - 1 , verbose = verbose
603+ )
567604 return stdout , stderr
568605
569606 def record (
@@ -590,7 +627,7 @@ def record(
590627 - stdout (`str`): Shell response to the command in stdout format
591628 - stderr (`str`): Shell response response to the command in stderr format
592629 """
593- warnings .warn ("The name of the function may change on future releases" , DeprecationWarning )
630+ # warnings.warn("The name of the function may change on future releases", DeprecationWarning)
594631
595632 mycommand = ["pw-cat" , "--record" , audio_filename ] + _generate_command_by_dict (
596633 mydict = self ._pipewire_configs , verbose = verbose
0 commit comments