From f8d3d84363c413342796bf58b097fd752767714e Mon Sep 17 00:00:00 2001 From: "Jonatan Nordentoft (Locercus)" Date: Sat, 3 Oct 2015 23:31:50 +0200 Subject: [PATCH] Fixed issues in fork --- .gitignore | 2 +- checkdependencies.py | 10 ++++++---- cli/area.py | 8 +++++--- cli/window.py | 14 +++++++------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 31991f3..dcf7b3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ screenshot.png *.md.html -*.pyc \ No newline at end of file +*.pyc diff --git a/checkdependencies.py b/checkdependencies.py index 61443b4..a3867ec 100755 --- a/checkdependencies.py +++ b/checkdependencies.py @@ -8,6 +8,7 @@ dirname = os.path.dirname(__file__) sys.path.append(os.path.join(dirname, "lib")) + import wireutils wireutils.cprintconf.name = "Perdyshot" wireutils.cprintconf.color= wireutils.bcolors.DARKCYAN @@ -33,7 +34,7 @@ def hasModule(name): def checkModule(name): installed = hasModule(name) - wireutils.cprint("Module {name} installed: {installed}", name=name, installed=installed) + wireutils.cprint("Module {name} installed: {installed}", name = name, installed = installed) return installed @@ -51,7 +52,7 @@ def manualInstallNotify(name, tutorial): def checkApplication(name, friendlyName, tutorial): installed = spawn.find_executable(name) != None - wireutils.cprint("Executable {name} ({readable}) found: {installed} ", name=name, readable=friendlyName, installed=installed) + wireutils.cprint("Executable {name} ({readable}) found: {installed} ", name = name, readable = friendlyName, installed = installed) if not installed: manualInstallNotify(friendlyName, tutorial) @@ -63,7 +64,7 @@ def checkApplication(name, friendlyName, tutorial): try: wireutils.cprint("""Perdyshot dependency checker ============================\n""", - strip=True) + strip = True) ROOT = os.geteuid() == 0 @@ -103,4 +104,5 @@ def checkApplication(name, friendlyName, tutorial): checkApplication("convert", "ImageMagick", "http://www.imagemagick.org/script/binary-releases.php") -except (KeyboardInterrupt, EOFError): print +except (KeyboardInterrupt, EOFError): + print diff --git a/cli/area.py b/cli/area.py index cd08aec..2df35de 100755 --- a/cli/area.py +++ b/cli/area.py @@ -3,10 +3,11 @@ from configobj import ConfigObj from validate import Validator -import argparse, os, sys, signal, time, temppath +import argparse, os, sys, signal, time, tempfile dirname = os.path.dirname(__file__) sys.path.append(os.path.join(dirname, os.path.pardir, "lib")) + import wireutils wireutils.cprintconf.name = "Perdyshot" wireutils.cprintconf.color= wireutils.bcolors.DARKCYAN @@ -38,7 +39,7 @@ def main(argSource): config = ConfigObj(os.path.join(dirname, os.path.pardir, 'perdyshot.conf'), encoding = 'UTF8', configspec = os.path.join(dirname, os.path.pardir, 'perdyshot.conf.spec')) validator = Validator() if not config.validate(validator): - wireutils.cprint("Invalid configuration file", color=wireutils.bcolors.DARKRED) + wireutils.cprint("Invalid configuration file", color = wireutils.bcolors.DARKRED) sys.exit(1) @@ -428,6 +429,7 @@ def activate(): if __name__ == '__main__': try: main(sys.argv[1:]) - except (KeyboardInterrupt, EOFError): print + except (KeyboardInterrupt, EOFError): + print signal.signal(signal.SIGINT, signal.SIG_DFL) diff --git a/cli/window.py b/cli/window.py index 0c22eba..8d9980e 100755 --- a/cli/window.py +++ b/cli/window.py @@ -3,10 +3,11 @@ from configobj import ConfigObj from validate import Validator -import argparse +import subprocess, time, sys, os, signal, argparse, tempfile dirname = os.path.dirname(__file__) sys.path.append(os.path.join(dirname, os.path.pardir, "lib")) + import wireutils wireutils.cprintconf.name = "Perdyshot" wireutils.cprintconf.color= wireutils.bcolors.DARKCYAN @@ -16,8 +17,6 @@ # We use PIL for simple tasks and ImageMagick for computationally-heavy tasks from PIL import Image, ImageOps -import subprocess, time, sys, os, signal - def main(argSource): cwd = os.getcwd() @@ -47,7 +46,7 @@ def main(argSource): config = ConfigObj(os.path.join(dirname, os.path.pardir, 'perdyshot.conf'), encoding = 'UTF8', configspec = os.path.join(dirname, os.path.pardir, 'perdyshot.conf.spec')) validator = Validator() if not config.validate(validator): - wireutils.cprint("Invalid configuration file", color=wireutils.bcolors.DARKRED) + wireutils.cprint("Invalid configuration file", color = wireutils.bcolors.DARKRED) sys.exit(1) @@ -80,7 +79,7 @@ def pixbuf2image(pix): window = root.get_active_window() if window == None: - wireutils.cprint("Failed to capture window, exiting.", color=wireutils.bcolors.DARKRED) + wireutils.cprint("Failed to capture window, exiting.", color = wireutils.bcolors.DARKRED) sys.exit(1) # And its geometry @@ -340,12 +339,13 @@ def pixbuf2image(pix): wireutils.cprint("Post-processing time: %.2f seconds" % (totalTime - partialTime)) wireutils.cprint("Total time: %.2f seconds" % (totalTime - startTime)) print - wireutils.cprint("Saved as {fname}.", fname=filename) + wireutils.cprint("Saved as {name}.", name = filename) if __name__ == '__main__': try: main(sys.argv[1:]) - except (KeyboardInterrupt, EOFError): print + except (KeyboardInterrupt, EOFError): + print signal.signal(signal.SIGINT, signal.SIG_DFL)