From dc33abe2b0dde74601b361e400eb60ba00931b9e Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Sun, 11 Jan 2015 15:27:14 +0000 Subject: [PATCH] Add hooks for tests and PEP8 compatibility. And fix some of the issues as well. No tests yet though. Also some PEP8 errors are ignored because I disagree with them. --- crypto-install.py | 32 +++++++++++++------------------- git_hooks/pre-commit/10-tests | 3 +++ git_hooks/pre-commit/20-pep8 | 3 +++ setup.cfg | 3 +++ 4 files changed, 22 insertions(+), 19 deletions(-) create mode 100755 git_hooks/pre-commit/10-tests create mode 100755 git_hooks/pre-commit/20-pep8 create mode 100644 setup.cfg diff --git a/crypto-install.py b/crypto-install.py index 22ca2d7..06b877b 100755 --- a/crypto-install.py +++ b/crypto-install.py @@ -62,7 +62,8 @@ def parse_arguments (): dest = "gui", action = "store_false", help = "Disable GUI, use text mode.") - gnupg_group = parser.add_argument_group ("GnuPG", + gnupg_group = parser.add_argument_group ( + "GnuPG", "Options related to the GnuPG setup.") gnupg_group.add_argument ( "--no-gpg", @@ -75,7 +76,8 @@ def parse_arguments (): default = "~/.gnupg", metavar = "PATH", help = "Default directory for GnuPG files.") - openssh_group = parser.add_argument_group ("OpenSSH", + openssh_group = parser.add_argument_group ( + "OpenSSH", "Options related to the OpenSSH setup.") openssh_group.add_argument ( "--no-ssh", @@ -166,7 +168,8 @@ def input_passphrase (arguments): else: del batch_env["DISPLAY"] - batch_passphrase += "GET_PASSPHRASE --data --check --qualitybar X X Passphrase X\n" + batch_passphrase += \ + "GET_PASSPHRASE --data --check --qualitybar X X Passphrase X\n" passphrase_process = subprocess.Popen (["gpg-agent", "--server"], stdin = subprocess.PIPE, @@ -254,7 +257,8 @@ def openssh_setup (arguments, comment = None): print ("Creating OpenSSH directory at '{}'.".format (openssh_home)) ensure_directories (openssh_home, 0o700) - print ("Creating OpenSSH configuration at '{}'.".format (openssh_config)) + print ("Creating OpenSSH configuration at '{}'." + .format (openssh_config)) with open (openssh_config, "w") as config: config.write (ldedented (""" ForwardAgent yes @@ -298,15 +302,12 @@ class CryptoInstall (Tk): self.create_widgets () - def create_widgets (self): self.balloon = Balloon (self, initwait = 250) - self.info_frame = Frame (self) self.info_frame.pack (fill = X) - self.user_label = Label (self.info_frame) self.user_label["text"] = "Username" self.user_label.grid () @@ -322,7 +323,6 @@ class CryptoInstall (Tk): """)) self.user.grid (row = 0, column = 1) - self.host_label = Label (self.info_frame) self.host_label["text"] = "Host Name" self.host_label.grid () @@ -338,7 +338,6 @@ class CryptoInstall (Tk): """)) self.host.grid (row = 1, column = 1) - self.name_label = Label (self.info_frame) self.name_label["text"] = "Full Name" self.name_label.grid () @@ -353,7 +352,6 @@ class CryptoInstall (Tk): """)) self.name.grid (row = 2, column = 1) - self.email_label = Label (self.info_frame) self.email_label["text"] = "Email address" self.email_label.grid () @@ -368,7 +366,6 @@ class CryptoInstall (Tk): """)) self.email.grid (row = 3, column = 1) - self.comment_label = Label (self.info_frame) self.comment_label["text"] = "Comment phrase" self.comment_label.grid () @@ -383,7 +380,6 @@ class CryptoInstall (Tk): """)) self.comment.grid (row = 4, column = 1) - self.options_frame = Frame (self) self.options_frame.pack (fill = X) @@ -395,7 +391,8 @@ class CryptoInstall (Tk): self.gnupg_var.set (1 if self.arguments.gnupg else 0) self.gnupg_var.trace ("w", self.update_widgets) - self.gnupg = Checkbutton (self.options_frame, variable = self.gnupg_var) + self.gnupg = Checkbutton (self.options_frame, + variable = self.gnupg_var) self.gnupg.grid (row = 0, column = 1) self.openssh_label = Label (self.options_frame) @@ -410,15 +407,15 @@ class CryptoInstall (Tk): variable = self.openssh_var) self.openssh.grid (row = 1, column = 1) - self.button_frame = Frame (self) self.button_frame.pack (fill = X) self._generate = Button (self.button_frame) self._generate["text"] = "Generate Keys" self._generate["command"] = self.generate - self.balloon.bind_widget (self._generate, - msg = "Generate the keys as configured above") + self.balloon.bind_widget ( + self._generate, + msg = "Generate the keys as configured above") self._generate.pack (side = LEFT, fill = Y) self._quit = Button (self.button_frame) @@ -430,7 +427,6 @@ class CryptoInstall (Tk): self.update_widgets () - def valid_state (self): if not self.openssh_var.get () and not self.gnupg_var.get (): return False @@ -449,7 +445,6 @@ class CryptoInstall (Tk): return True - def update_widgets (self, *args): valid = self.valid_state () @@ -503,7 +498,6 @@ class CryptoInstall (Tk): self.balloon.bind_widget (self.openssh, msg = msg) self.balloon.bind_widget (self.openssh_label, msg = msg) - def generate (self): # TODO: capture and show stdout and stderr if self.gnupg_var.get (): diff --git a/git_hooks/pre-commit/10-tests b/git_hooks/pre-commit/10-tests new file mode 100755 index 0000000..587ab08 --- /dev/null +++ b/git_hooks/pre-commit/10-tests @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ./setup.py test diff --git a/git_hooks/pre-commit/20-pep8 b/git_hooks/pre-commit/20-pep8 new file mode 100755 index 0000000..b85163a --- /dev/null +++ b/git_hooks/pre-commit/20-pep8 @@ -0,0 +1,3 @@ +#!/bin/sh + +exec pep8 . diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..ec36dcd --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[pep8] +exclude = build +ignore = E211,E251,E401 \ No newline at end of file -- 1.7.10.4