Skip to content

Commit 629b061

Browse files
author
BoboTiG
committed
Update tests and pypi categories
1 parent 625429b commit 629b061

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ MANIFEST*
66
*.png.old
77
*.raw
88
test/test-linux
9+
test/.*

mss.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
2+
# coding: utf-8
33
''' A cross-platform multi-screen shot module in pure python using ctypes.
44
55
This module is maintained by Mickaël Schoentgen <mickael@jmsinfo.co>.
@@ -314,7 +314,7 @@ def save_img(self, data, width, height, output):
314314
self.debug('save_img', 'url', url)
315315
self.debug('save_img', 'dest', dest)
316316
if not dest:
317-
err = 'MSS : CGImageDestinationCreateWithURL() failed.'
317+
err = 'MSS: CGImageDestinationCreateWithURL() failed.'
318318
raise ScreenshotError(err)
319319

320320
CGImageDestinationAddImage(dest, data, None)
@@ -507,9 +507,8 @@ def pix(pixel, _resultats={}, b=pack):
507507
self.debug('get_pixels', 'bmask', bmask)
508508
pixels = [pix(get_pix(ximage, x, y))
509509
for y in range(height) for x in range(width)]
510-
self.image = b''.join(pixels)
511-
512510
self.xlib.XDestroyImage(ximage)
511+
self.image = b''.join(pixels)
513512
return self.image
514513

515514

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
'Programming Language :: Python :: 3.5',
5252
'Topic :: Multimedia :: Graphics :: Capture',
5353
'Topic :: Multimedia :: Graphics :: Capture :: Screen Capture',
54+
'Topic :: Software Development'
55+
'Topic :: Software Development :: Libraries'
5456
'Topic :: Software Development :: Libraries :: Python Modules'
5557
],
5658
url='https://github.com/BoboTiG/python-mss'

test/screenshot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
2+
# coding: utf-8
33
''' A simple screen shot script.
44
Use of python-mss: https://github.com/BoboTiG/python-mss/
55
pip install --upgrade mss
@@ -18,4 +18,4 @@
1818
if __name__ == '__main__':
1919
mss = mss_class()
2020
for filename in mss.save(output='monitor-%d.png', screen=1):
21-
print('File: "{}" created.'.format(filename))
21+
print('File: "{0}" created.'.format(filename))

test/test-linux.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void full_screen(void) {
9292
}
9393
*/
9494

95-
XFree(image);
95+
XDestroyImage(image);
9696
XCloseDisplay(display);
9797

9898
gettimeofday(&end, NULL);
@@ -150,8 +150,8 @@ void each_screen(void) {
150150
pixels[x * 3 + offset + 2] = pixel & image->blue_mask;
151151
}
152152
}
153-
XFree(image);
154-
XFree(crtc_info);
153+
XDestroyImage(image);
154+
XRRFreeCrtcInfo(crtc_info);
155155

156156
gettimeofday(&end, NULL);
157157
printf("Screen %d: %dx%d @ %u msec\n", n, width, height, (1000000 * end.tv_sec + end.tv_usec) - (1000000 * start.tv_sec + start.tv_usec));
@@ -162,7 +162,7 @@ void each_screen(void) {
162162
fwrite(pixels, sizeof(unsigned char), sizeof(unsigned char) * width * height * 3, fh);
163163
fclose(fh);
164164
}
165-
XFree(monitors);
165+
XRRFreeScreenResources(monitors);
166166
XCloseDisplay(display);
167167

168168
return;

test/test-raw.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
2+
# coding: utf-8
33

44
# Test raw data generated by test-linux.
55

@@ -49,23 +49,23 @@ def save_img(data, width, height, output):
4949
fileh.write(
5050
magic + b''.join(ihdr) + b''.join(idat) + b''.join(iend))
5151
if not os.path.isfile(output):
52-
msg = 'Impossible to write data to file "{}".'.format(output)
52+
msg = 'Impossible to write data to file "{0}".'.format(output)
5353
raise ScreenshotError(msg)
5454

5555
if len(sys.argv) < 4:
56-
print('python {} data.raw width height'.format(sys.argv[0]))
56+
print('python {0} data.raw width height'.format(sys.argv[0]))
5757
else:
5858
with open(sys.argv[1], 'rb') as fileh:
5959
data = fileh.read()
6060
width = int(sys.argv[2])
6161
height = int(sys.argv[3])
62-
output = '{}.png'.format(sys.argv[1])
62+
output = '{0}.png'.format(sys.argv[1])
6363
if mss.__version__ < '0.1.0':
6464
print('Outdated version of MSS, please `pip install --upgrade mss`')
6565
save_img(data, width, height, output)
6666
else:
6767
mss = mss.MSS()
6868
mss.save_img(data, width, height, output)
69-
print('File {} created.'.format(output))
69+
print('File {0} created.'.format(output))
7070
sys.exit(0)
71-
print('Impossible to get contents of "{}".'.format(sys.argv[1]))
71+
print('Impossible to get contents of "{0}".'.format(sys.argv[1]))

0 commit comments

Comments
 (0)