print statements fixed

This commit is contained in:
kayos 2020-08-08 22:49:49 -07:00
parent bf14bbffc5
commit 8335db586c
5 changed files with 19 additions and 19 deletions

@ -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()

@ -30,12 +30,12 @@ DAEMON_DIR = '/etc/knockknock.d/'
PROFILES_DIR = DAEMON_DIR + 'profiles/'
def usage():
print "knockknock-genprofile <profileName> <knockPort>"
print("knockknock-genprofile <profileName> <knockPort>")
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:])

@ -45,7 +45,7 @@ class ProxyServer(asyncore.dispatcher):
def usage():
print "knockknock-proxy <listenPort>"
print("knockknock-proxy <listenPort>")
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):

@ -29,7 +29,7 @@ from struct import *
from knockknock.Profile import Profile
def usage():
print "Usage: knockknock.py -p <portToOpen> <host>"
print("Usage: knockknock.py -p <portToOpen> <host>")
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__':

@ -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/")