Skip to content

Commit 2a5d923

Browse files
committed
Merge branch 'release/v20220416'
2 parents a93daff + ee1e7de commit 2a5d923

34 files changed

+2312
-793
lines changed

.github/workflows/pypi-release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: PyPI release
2+
3+
on: [push]
4+
5+
jobs:
6+
pypi:
7+
runs-on: windows-2019
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-python@v2
11+
- name: Install dependencies
12+
run: python -m pip install --upgrade setuptools wheel twine
13+
- name: Build
14+
run: |
15+
python setup.py sdist bdist_wheel
16+
twine check dist/*
17+
- name: Publish package
18+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
19+
uses: pypa/[email protected]
20+
with:
21+
verbose: true
22+
user: __token__
23+
password: ${{ secrets.pypi_password }}

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tests
2+
3+
on: [push]
4+
5+
jobs:
6+
linter:
7+
runs-on: windows-2019
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-python@v2
11+
- run: pip install tox
12+
- run: tox -e pep8
13+
- run: tox -e isort
14+
test:
15+
runs-on: windows-2019
16+
strategy:
17+
matrix:
18+
python: ['3.7', '3.8', '3.9', '3.10']
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
# Virtual network sound card for Microsoft Windows
23+
- name: Install Scream
24+
shell: powershell
25+
run: |
26+
Invoke-WebRequest https://github.com/duncanthrax/scream/releases/download/3.8/Scream3.8.zip -OutFile Scream3.8.zip
27+
Expand-Archive -Path Scream3.8.zip -DestinationPath Scream
28+
Import-Certificate -FilePath Scream\Install\driver\x64\Scream.cat -CertStoreLocation Cert:\LocalMachine\TrustedPublisher
29+
Scream\Install\helpers\devcon-x64.exe install Scream\Install\driver\x64\Scream.inf *Scream
30+
- uses: actions/setup-python@v2
31+
with:
32+
python-version: ${{ matrix.python }}
33+
- run: pip install tox
34+
- run: tox -e py

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Custom
22
venv/
3+
.vscode/
34
*.swp
45

56
# Byte-compiled / optimized / DLL files

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Change Log
22

3+
## [20220416]
4+
- Migrate to GitHub Actions
5+
- CI tests via virtual sound card
6+
- Drop Python 2.7 and 3.6
7+
- Add support for 3.7 up to 3.10
8+
- Fix missing api package, refs #63 (@Jan-Zeiseweis)
9+
- Automatic PyPI release on tagging, refs #44
10+
11+
## [20210516]
12+
- Fixed GetAllDevices() COMError, refs #15, #28 and #30 (@micolous and @reversefold)
13+
- New IAudioSessionEvents callbacks support, refs #27, #36 (@TurboAnonym)
14+
- IAudioSessionControl GetState fix, refs #32, #37 (@TurboAnonym)
15+
- Adding AudioUtilities.GetMicrophone(), refs #39 (@alebzk)
16+
- Reorganize / Split the pycaw.pycaw file in modules and subpackages, refs #38 (@TurboAnonym)
17+
- OnSessionCreated support + Wrapper for callbacks, refs #40 (@TurboAnonym)
18+
- "Magic" module, easy session control, refs #42 (@TurboAnonym)
19+
320
## [20190904]
421
- Fixed enum34 dependency, refs #17 (@mmxfguerin)
522

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# pycaw
22

3-
[![Build Status](https://travis-ci.org/AndreMiras/pycaw.svg?branch=develop)](https://travis-ci.org/AndreMiras/pycaw)
3+
[![Tests](https://github.com/AndreMiras/pycaw/actions/workflows/tests.yml/badge.svg)](https://github.com/AndreMiras/pycaw/actions/workflows/tests.yml)
4+
[![PyPI release](https://github.com/AndreMiras/pycaw/actions/workflows/pypi-release.yml/badge.svg)](https://github.com/AndreMiras/pycaw/actions/workflows/pypi-release.yml)
45
[![PyPI version](https://badge.fury.io/py/pycaw.svg)](https://badge.fury.io/py/pycaw)
56

67
Python Core Audio Windows Library, working for both Python2 and Python3.

docs/Release.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# How to release
2+
3+
This is documenting the release process.
4+
5+
6+
## Git flow & CHANGELOG.md
7+
8+
Make sure the CHANGELOG.md is up to date and follows the http://keepachangelog.com guidelines.
9+
Start the release with git flow:
10+
```batch
11+
git flow release start vYYYYMMDD
12+
```
13+
Now update the [CHANGELOG.md](/CHANGELOG.md) `[Unreleased]` section to match the new release version.
14+
Also update the `version` string in the [setup.py](/setup.py) file. Then commit and finish release.
15+
```batch
16+
git commit -a -m ":bookmark: vYYYYMMDD"
17+
git flow release finish
18+
```
19+
Push everything, make sure tags are also pushed:
20+
```batch
21+
git push
22+
git push origin main:main
23+
git push --tags
24+
```
25+
26+
## Publish to PyPI
27+
This process is handled automatically by [GitHub Actions](https://github.com/AndreMiras/pycaw/actions/workflows/pypi-release.yml).
28+
If needed below are the instructions to perform it manually.
29+
Build it:
30+
```batch
31+
python setup.py sdist bdist_wheel
32+
```
33+
Check archive content:
34+
```batch
35+
tar -tvf dist\pycaw-*.tar.gz
36+
```
37+
Upload:
38+
```batch
39+
twine upload dist\pycaw-*.tar.gz
40+
```
41+
42+
## GitHub
43+
44+
Got to GitHub [Release/Tags](https://github.com/AndreMiras/pycaw/tags), click "Add release notes" for the tag just created.
45+
Add the tag name in the "Release title" field and the relevant CHANGELOG.md section in the "Describe this release" textarea field.
46+
47+
## Post release
48+
Update the [setup.py](/setup.py) `version string` with `YYYYMMDD.dev0`.

examples/audio_controller_class_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
Per session GetMute() SetMute() GetMasterVolume() SetMasterVolume() using
33
SimpleAudioVolume.
44
"""
5-
from __future__ import print_function
6-
75
from pycaw.pycaw import AudioUtilities
86

97

10-
class AudioController(object):
8+
class AudioController:
119
def __init__(self, process_name):
1210
self.process_name = process_name
1311
self.volume = self.process_volume()

examples/audio_endpoint_volume_example.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""
22
Get and set access to master volume example.
33
"""
4-
from __future__ import print_function
5-
64
from ctypes import POINTER, cast
75

86
from comtypes import CLSCTX_ALL

examples/magic_app_example.py

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
"""
2+
Note
3+
----
4+
'import pycaw.magic' must be generally at the topmost.
5+
To be more specific:
6+
It needs to be imported before any other pycaw or comtypes import.
7+
8+
9+
Reserved Atrributes
10+
-------------------
11+
Note that certain methods and attributes are reserved for the magic module.
12+
Please look into the source code of MagicApp for more information.
13+
But to avoid conflicts now and in the future, i recommend using
14+
a prefix for each of your custom methods and attributes.
15+
16+
17+
Features
18+
--------
19+
Instantiate a new MagicApp with one or more app executables:
20+
21+
magic = MagicApp({"msedge.exe", "another.exe"})
22+
23+
--------
24+
25+
you could also inherit from MagicApp and create customized callbacks:
26+
27+
class MyCustomApp(MagicApp):
28+
def __init__(self, app_execs):
29+
super().__init__(app_execs,
30+
volume_callback=self.custom_volume_callback,
31+
mute_callback=self...,
32+
state_callback=self...,
33+
session_callback=self...)
34+
35+
def custom_volume_callback(self, volume):
36+
print(volume)
37+
print(self.mute)
38+
self.mute = True
39+
print(self.mute)
40+
41+
mega_magic = MyCustomApp({"msedge.exe"})
42+
"""
43+
44+
import time
45+
from contextlib import suppress
46+
47+
from pycaw.magic import MagicApp
48+
49+
50+
def handle_all(*args):
51+
print("callback")
52+
print(args)
53+
54+
55+
magic = MagicApp({"msedge.exe"},
56+
volume_callback=handle_all,
57+
mute_callback=handle_all,
58+
state_callback=handle_all,
59+
session_callback=handle_all)
60+
61+
62+
def main():
63+
with suppress(KeyboardInterrupt):
64+
for _ in range(5):
65+
"""
66+
open and close your MagicApp app_exec (msedge.exe)
67+
and see how it will change the volume as long as
68+
the app is opened. When you close app_exec it wont change
69+
the volume and None is printed.
70+
71+
if you change for example the volume in the Windows sound mixer
72+
handle_all() is fired.
73+
"""
74+
75+
if magic.state is None:
76+
print(f"No session active for: {magic}")
77+
time.sleep(2)
78+
continue
79+
80+
print("Volume:")
81+
magic.volume = 0.1
82+
print(magic.volume)
83+
time.sleep(1)
84+
magic.volume = 0.9
85+
print(magic.volume)
86+
time.sleep(1)
87+
88+
print(f"{str(magic.state)} {magic.app_execs}")
89+
90+
print("Mute:")
91+
magic.mute = True
92+
print(magic.mute)
93+
time.sleep(1)
94+
magic.mute = False
95+
print(magic.mute)
96+
97+
print("\nTschüss")
98+
99+
100+
if __name__ == '__main__':
101+
main()

0 commit comments

Comments
 (0)