Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
ponty committed Jan 2, 2017
1 parent 3686d11 commit 0251781
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
4 changes: 2 additions & 2 deletions pyscreenshot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pyscreenshot.procutil import run_in_childprocess


ADDITIONAL_IMPORTS=[FailedBackendError]
ADDITIONAL_IMPORTS = [FailedBackendError]

log = logging.getLogger(__name__)
log.debug('version=%s', __version__)
Expand Down Expand Up @@ -59,7 +59,7 @@ def grab_to_file(filename, childprocess=True, backend=None):

def backends():
'''Back-end names as a list
:return: back-ends as string list
'''
return Loader().all_names
Expand Down
13 changes: 7 additions & 6 deletions pyscreenshot/check/speedtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ def run(force_backend, n, to_file, bbox=None):
start = time.time()
for _ in range(n):
if to_file:
filename=os.path.join(tmpdir, 'speedtest.png')
pyscreenshot.grab_to_file(filename, backend=force_backend, childprocess=True)
filename = os.path.join(tmpdir, 'speedtest.png')
pyscreenshot.grab_to_file(
filename, backend=force_backend, childprocess=True)
else:
pyscreenshot.grab(bbox=bbox, backend=force_backend, childprocess=True)
pyscreenshot.grab(
bbox=bbox, backend=force_backend, childprocess=True)
end = time.time()
dt = end - start

Expand All @@ -26,7 +28,6 @@ def run(force_backend, n, to_file, bbox=None):
s += '(%5d ms per call)' % (1000.0 * dt / n)
print(s)
shutil.rmtree(tmpdir)



def run_all(n, to_file, bbox=None):
Expand Down Expand Up @@ -54,7 +55,8 @@ def speedtest():
run_all(n, True)
run_all(n, False)
run_all(n, False, (10, 10, 20, 20))



@entrypoint
def main(virtual_display=False):
if virtual_display:
Expand All @@ -63,4 +65,3 @@ def main(virtual_display=False):
speedtest()
else:
speedtest()

4 changes: 2 additions & 2 deletions pyscreenshot/check/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ def print_name_version(name, version):
@entrypoint
def print_versions():
print_name_version('pyscreenshot', pyscreenshot.__version__)

for name in pyscreenshot.backends():
v=backend_version(name, childprocess=True)
v = backend_version(name, childprocess=True)
if not v:
v = 'missing'
print_name_version(name, v)
4 changes: 2 additions & 2 deletions pyscreenshot/examples/showgrabbox.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pyscreenshot as ImageGrab

if __name__ == "__main__":
if __name__ == '__main__':
# part of the screen
im=ImageGrab.grab(bbox=(10,10,510,510)) # X1,Y1,X2,Y2
im = ImageGrab.grab(bbox=(10, 10, 510, 510)) # X1,Y1,X2,Y2
im.show()
4 changes: 2 additions & 2 deletions pyscreenshot/examples/showgrabfullscreen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pyscreenshot as ImageGrab

if __name__ == "__main__":
if __name__ == '__main__':
# fullscreen
im=ImageGrab.grab()
im = ImageGrab.grab()
im.show()
15 changes: 8 additions & 7 deletions pyscreenshot/imcodec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,26 @@
# 'mode': im.mode,
# }
# return data
#
#
#
#
# def _decoder(data):
# if data:
# im = Image.frombytes(data['mode'], data['size'], data['pixels'])
# return im


def _coder(im):
if im:
b=io.BytesIO()
b = io.BytesIO()
im.save(b, format='png')
data = b.getvalue()
return data


def _decoder(data):
if data:
b=io.BytesIO(data)
b = io.BytesIO(data)
im = Image.open(b)
return im

codec = (_coder, _decoder)
codec = (_coder, _decoder)
1 change: 1 addition & 0 deletions pyscreenshot/plugins/pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


class PilWrapper(object):

"""windows only."""
name = 'pil'
childprocess = False
Expand Down
2 changes: 1 addition & 1 deletion pyscreenshot/plugins/qtgrabwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self):
self.app = None
self.QtGui = QtGui
self.Qt = Qt

def grab_to_buffer(self, buff, file_type='png'):
QApplication = self.PyQt4.QtGui.QApplication
QBuffer = self.PyQt4.Qt.QBuffer
Expand Down
2 changes: 1 addition & 1 deletion pyscreenshot/procutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def _wrapper(target, codec, queue, args, kwargs):
kwargs = {}
r = target(*args, **kwargs)
except Exception as e:
# traceback.print_exc()
# traceback.print_exc()
r = None
exc = e

Expand Down

0 comments on commit 0251781

Please sign in to comment.