def main(): """This is the main entry point for the program to control gravimetrics """ arguments = process_args() # Double check all data has been correctly set if 'host' not in arguments or\ 'user' not in arguments or\ 'password' not in arguments or\ 'database' not in arguments: print("Error setting database credentials") print(arguments) sys.exit(1) connection = Connection() connection.create_connection(arguments['host'], arguments['user'], arguments['password'], arguments['database']) # If we're testing use the pi name test, # else we just wanna use the host name plants = connection.get_plants( arguments['pi'] if not arguments['testing_mode'] else "1") # If the retrieval if plants is None: sys.stderr.write("No plant information found\nCheck connection\n") sys.exit(1) for plant in plants: perform_reading_update(arguments['pi'], plant, connection, arguments['watering_mode']) print("| SUMMARY OF BENCH {0}".format(arguments['pi'])) for plant in plants: print(plant)