From 8335db586c83b86d8921d155be6b6df73bcd21dd Mon Sep 17 00:00:00 2001 From: kayos Date: Sat, 8 Aug 2020 22:49:49 -0700 Subject: [PATCH] print statements fixed --- knockknock-daemon.py | 8 ++++---- knockknock-genprofile.py | 8 ++++---- knockknock-proxy.py | 6 +++--- knockknock.py | 14 +++++++------- setup.py | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/knockknock-daemon.py b/knockknock-daemon.py index 81e502d..2d6695a 100644 --- a/knockknock-daemon.py +++ b/knockknock-daemon.py @@ -36,16 +36,16 @@ import knockknock.daemonize def checkPrivileges(): if (not os.geteuid() == 0): - print "Sorry, you have to run knockknock-daemon as root." + print("Sorry, you have to run knockknock-daemon as root.") sys.exit(3) def checkConfiguration(): if (not os.path.isdir('/etc/knockknock.d/')): - print "/etc/knockknock.d/ does not exist. You need to setup your profiles first.." + print("/etc/knockknock.d/ does not exist. You need to setup your profiles first..") sys.exit(3) if (not os.path.isdir('/etc/knockknock.d/profiles/')): - print "/etc/knockknock.d/profiles/ does not exist. You need to setup your profiles first..." + print("/etc/knockknock.d/profiles/ does not exist. You need to setup your profiles first...") sys.exit(3) def dropPrivileges(): @@ -77,7 +77,7 @@ def main(argv): config = DaemonConfiguration('/etc/knockknock.d/config') if (profiles.isEmpty()): - print 'WARNING: Running knockknock-daemon without any active profiles.' + print('WARNING: Running knockknock-daemon without any active profiles.') knockknock.daemonize.createDaemon() diff --git a/knockknock-genprofile.py b/knockknock-genprofile.py index 09aca4f..66af66a 100644 --- a/knockknock-genprofile.py +++ b/knockknock-genprofile.py @@ -30,12 +30,12 @@ DAEMON_DIR = '/etc/knockknock.d/' PROFILES_DIR = DAEMON_DIR + 'profiles/' def usage(): - print "knockknock-genprofile " + print("knockknock-genprofile ") sys.exit(3) def checkProfile(profileName): if (os.path.isdir(PROFILES_DIR + profileName)): - print "Profile already exists. First rm " + PROFILES_DIR + profileName + "/" + print("Profile already exists. First rm " + PROFILES_DIR + profileName + "/") sys.exit(0) def checkPortConflict(knockPort): @@ -46,7 +46,7 @@ def checkPortConflict(knockPort): matchingProfile = profiles.getProfileForPort(knockPort) if (matchingProfile != None): - print "A profile already exists for knock port: " + str(knockPort) + " at this location: " + matchingProfile.getDirectory() + print("A profile already exists for knock port: " + str(knockPort) + " at this location: " + matchingProfile.getDirectory()) def createDirectory(profileName): if not os.path.isdir(DAEMON_DIR): @@ -79,7 +79,7 @@ def main(argv): profile.serialize() random.close() - print "Keys successfully generated in " + PROFILES_DIR + profileName + print("Keys successfully generated in " + PROFILES_DIR + profileName) if __name__ == '__main__': main(sys.argv[1:]) diff --git a/knockknock-proxy.py b/knockknock-proxy.py index 75e80a5..083e67c 100644 --- a/knockknock-proxy.py +++ b/knockknock-proxy.py @@ -45,7 +45,7 @@ class ProxyServer(asyncore.dispatcher): def usage(): - print "knockknock-proxy " + print("knockknock-proxy ") sys.exit(3) def getProfiles(): @@ -57,14 +57,14 @@ def getProfiles(): def checkPrivileges(): if not os.geteuid() == 0: - print "\nSorry, knockknock-proxy has to be run as root.\n" + print("\nSorry, knockknock-proxy has to be run as root.\n") usage() def checkProfiles(): homedir = os.path.expanduser('~') if not os.path.isdir(homedir + '/.knockknock/'): - print "Error: you need to setup your profiles in " + homedir + "/.knockknock/" + print("Error: you need to setup your profiles in " + homedir + "/.knockknock/") sys.exit(2) def main(argv): diff --git a/knockknock.py b/knockknock.py index f139347..ebf8cc1 100644 --- a/knockknock.py +++ b/knockknock.py @@ -29,7 +29,7 @@ from struct import * from knockknock.Profile import Profile def usage(): - print "Usage: knockknock.py -p " + print("Usage: knockknock.py -p ") sys.exit(2) def parseArguments(argv): @@ -61,18 +61,18 @@ def getProfile(host): homedir = os.path.expanduser('~') if not os.path.isdir(homedir + '/.knockknock/'): - print "Error: you need to setup your profiles in " + homedir + '/.knockknock/' + print("Error: you need to setup your profiles in " + homedir + '/.knockknock/') sys.exit(2) if not os.path.isdir(homedir + '/.knockknock/' + host): - print 'Error: profile for host ' + host + ' not found at ' + homedir + '/.knockknock/' + host + print('Error: profile for host ' + host + ' not found at ' + homedir + '/.knockknock/' + host) sys.exit(2) return Profile(homedir + '/.knockknock/' + host) def verifyPermissions(): if os.getuid() != 0: - print 'Sorry, you must be root to run this.' + print('Sorry, you must be root to run this.') sys.exit(2) def existsInPath(command): @@ -100,7 +100,7 @@ def main(argv): hping = existsInPath("hping3") if hping is None: - print "Error, you must install hping3 first." + print("Error, you must install hping3 first.") sys.exit(2) command = [hping, "-S", "-c", "1", @@ -113,10 +113,10 @@ def main(argv): try: subprocess.call(command, shell=False, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT) - print 'Knock sent.' + print('Knock sent.') except OSError: - print "Error: Do you have hping3 installed?" + print("Error: Do you have hping3 installed?") sys.exit(3) if __name__ == '__main__': diff --git a/setup.py b/setup.py index a1a1fdd..6ddef65 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ setup (name = 'knockknock', ('/etc/knockknock.d/', ['config'])] ) -print "Cleaning up..." +print("Cleaning up...") if os.path.exists("build/"): shutil.rmtree("build/")