def main(): # ---> START TIMER time_util = xmatters.TimeCalc() start = time_util.getTimeNow() print('Starting Process: ' + time_util.formatDateTimeNow(start)) # prep the package ds_file.prepare_the_sync() # ---> OBTAIN CONNECTION connection = sqlite3.connect('db/xMatters.db') connection.row_factory = sqlite3.Row # This allows for referencing via column name, i.e. row['First Name'] cursor = connection.cursor() # Bulk of logic here... ds_table.generate(cursor, connection) ds_site.package(cursor) ds_user.package(cursor) ds_group.package(cursor) ds_file.output(connection) # ---> COMMIT AND CLOSE CONNECTION connection.commit() connection.close() # ZIP up the files and end the show ds_file.package_the_sync() # print the duration end = time_util.getTimeNow() print('Process Duration: ' + time_util.getDiff(end, start))
log.info("User update success: " + str(process_collection["response"])) log.info("User update failures: " + str(process_collection["errors"])) else: log.info("No updates required") # entry point when file initiated if __name__ == "__main__": # configure the logging logging.basicConfig(level=config.roles['logging']["level"], datefmt="%m-%d-%Y %H:%M:%Srm ", format="%(asctime)s %(name)s %(levelname)s: %(message)s", handlers=[RotatingFileHandler(config.roles['logging']["file_name"], maxBytes=config.roles['logging']["max_bytes"], backupCount=config.roles['logging']['back_up_count'])]) log = logging.getLogger(__name__) # time start time_util = xmatters.TimeCalc() start = time_util.get_time_now() log.info("Starting Process: " + time_util.format_date_time_now(start)) # instantiate classes environment = xmatters.xMattersAPI(config.environment["url"], config.environment["username"], config.environment["password"]) xm_roster = xmatters.xMattersRoster(environment) xm_person = xmatters.xMattersPerson(environment) xm_libraries = xmatters.xMattersLibraries(environment) xm_collection = xmatters.xMattersCollection(environment) # retrieve the group-roles mapping group_roles = None if config.roles['role_mapping']["enable_web_ui"]: libraries = xm_libraries.get_libraries(config.roles['role_mapping']["plan_name"])