| 79 | |
| 80 | |
| 81 | def get_servers(query): # Function to get the servers from the database |
| 82 | conn = sqlite3.connect(master_db) # Connect to the database |
| 83 | cursor = conn.cursor() # Create the cursor |
| 84 | cursor.execute( |
| 85 | "select hostname from tp_servers where location =?", (query,) |
| 86 | ) # SQL Statement |
| 87 | print("\nDisplaying Servers for : " + query + "\n") |
| 88 | while True: # While there are results |
| 89 | row = cursor.fetchone() # Return the results |
| 90 | if row == None: |
| 91 | break |
| 92 | f = open(serverfile, "a") # Open the serverfile |
| 93 | f.write("%s\n" % str(row[0])) # Write the server out to the file |
| 94 | print(row[0]) # Display the server to the screen |
| 95 | f.close() # Close the file |
| 96 | |
| 97 | |
| 98 | def main(): # Main Function |