Skip to content

Commit 3a02317

Browse files
committed
pylint: fix issues in iio_readdev.py and iio_writedev.py
as pointed out by pylint: - Access to a protected member _length of a client class is bad form, and don't do it. - Comments at the top of a file should be in docstring format, so do that too Signed-off-by: Robin Getz <[email protected]>
1 parent ed8f90a commit 3a02317

File tree

2 files changed

+39
-37
lines changed

2 files changed

+39
-37
lines changed

bindings/python/examples/iio_readdev.py

100644100755
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/usr/bin/env python
2-
#
3-
# Copyright (C) 2020 Analog Devices, Inc.
4-
# Author: Cristian Iacob <[email protected]>
5-
#
6-
# This program is free software; you can redistribute it and/or
7-
# modify it under the terms of the GNU General Public License
8-
# as published by the Free Software Foundation; either version 2
9-
# of the License, or (at your option) any later version.
10-
#
11-
# This program is distributed in the hope that it will be useful,
12-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
# GNU General Public License for more details.
15-
#
16-
# You should have received a copy of the GNU General Public License
17-
# along with this program; if not, write to the Free Software
18-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2+
"""
3+
Copyright (C) 2020 Analog Devices, Inc.
4+
Author: Cristian Iacob <[email protected]>
5+
6+
This program is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU General Public License
8+
as published by the Free Software Foundation; either version 2
9+
of the License, or (at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
"""
1920

2021
import sys
2122
import argparse

bindings/python/examples/iio_writedev.py

100644100755
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#!/usr/bin/env python
2-
#
3-
# Copyright (C) 2020 Analog Devices, Inc.
4-
# Author: Cristian Iacob <[email protected]>
5-
#
6-
# This program is free software; you can redistribute it and/or
7-
# modify it under the terms of the GNU General Public License
8-
# as published by the Free Software Foundation; either version 2
9-
# of the License, or (at your option) any later version.
10-
#
11-
# This program is distributed in the hope that it will be useful,
12-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
# GNU General Public License for more details.
15-
#
16-
# You should have received a copy of the GNU General Public License
17-
# along with this program; if not, write to the Free Software
18-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2+
"""
3+
Copyright (C) 2020 Analog Devices, Inc.
4+
Author: Cristian Iacob <[email protected]>
5+
6+
This program is free software; you can redistribute it and/or
7+
modify it under the terms of the GNU General Public License
8+
as published by the Free Software Foundation; either version 2
9+
of the License, or (at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software
18+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
"""
1920

2021
import time
2122
import sys
@@ -196,15 +197,15 @@ def write(self):
196197
num_samples = self.arguments.num_samples
197198

198199
while app_running:
199-
bytes_to_read = self.buffer._length if num_samples == 0 \
200-
else min(self.buffer._length, num_samples * self.device.sample_size)
200+
bytes_to_read = len(self.buffer) if num_samples == 0 \
201+
else min(len(self.buffer), num_samples * self.device.sample_size)
201202
write_len = bytes_to_read
202203
data = []
203204

204205
while bytes_to_read > 0:
205206
read_data = sys.stdin.buffer.read(bytes_to_read)
206207
if len(read_data) == 0:
207-
exit(0)
208+
sys.exit(0)
208209
bytes_to_read -= len(read_data)
209210
data.extend(read_data)
210211

0 commit comments

Comments
 (0)