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

Convert run_system_command to use _exec instead of _shell #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion joycontrol/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def set_class(self, cls='0x002508'):
:param cls: default 0x002508 (Gamepad/joystick device class)
"""
logger.info(f'setting device class to {cls}...')
await utils.run_system_command(f'hciconfig {self._adapter_name} class {cls}')
await utils.run_system_command(['hciconfig', self._adapter_name, 'class', cls])

async def set_name(self, name: str):
"""
Expand Down
2 changes: 1 addition & 1 deletion joycontrol/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def create_hid_server(protocol_factory, ctl_psm=17, itr_psm=19, device_id=
# The Switch does not connect to the sockets if we don't.
# For more info see: https://github.com/mart1nro/joycontrol/issues/8
logger.info('Restarting bluetooth service...')
await utils.run_system_command('systemctl restart bluetooth.service')
await utils.run_system_command(['systemctl', 'restart', 'bluetooth.service'])
await asyncio.sleep(1)

hid = HidDevice(device_id=device_id)
Expand Down
4 changes: 2 additions & 2 deletions joycontrol/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def callback(future):


async def run_system_command(cmd):
proc = await asyncio.create_subprocess_shell(
cmd,
proc = await asyncio.create_subprocess_exec(
*cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)

Expand Down