# Query the assignment feature layer to get certain assignments
    logging.getLogger().info("Querying assignments...")
    assignments = workforcehelpers.query_feature_layer(assignment_fl_url, token, where=args.where, outSR=args.outSR)["features"]
    # Write the assignments to the csv file
    logging.getLogger().info("Writing to CSV...")
    write_assignments_to_csv(args.outCSV, assignments, args.dateFormat)
    logging.getLogger().info("Completed")


if __name__ == "__main__":
    # Get all of the commandline arguments
    parser = argparse.ArgumentParser("Export assignments from Workforce Project")
    parser.add_argument('-u', dest='username', help="The username to authenticate with", required=True)
    parser.add_argument('-p', dest='password', help="The password to authenticate with", required=True)
    parser.add_argument('-url', dest='org_url', help="The url of the org/portal to use", required=True)
    # Parameters for workforce
    parser.add_argument('-pid', dest='projectId', help="The id of the project to delete assignments from",
                        required=True)
    parser.add_argument('-where', dest='where', help="The where clause to use", default="1=1")
    parser.add_argument('-outCSV', dest="outCSV", help="The file/path to save the output CSV file", required=True)
    parser.add_argument('-logFile', dest="logFile", help="The file to log to",required=True)
    parser.add_argument('-outSR', dest="outSR", help="The output spatial reference to use", default=None)
    parser.add_argument('-dateFormat', dest='dateFormat', help="The date format to use", default="%d/%m/%Y %H:%M:%S")
    args = parser.parse_args()
    workforcehelpers.initialize_logging(args.logFile)
    try:
        main(args)
    except Exception as e:
        logging.getLogger().critical("Exception detected, script exiting")
        logging.getLogger().critical(e)
        logging.getLogger().critical(traceback.format_exc().replace("\n", " | "))
Esempio n. 2
0
                     help="The where clause to use",
                     default="1=1")
 parser.add_argument('-outCSV',
                     dest="outCSV",
                     help="The file/path to save the output CSV file",
                     required=True)
 parser.add_argument('-logFile',
                     dest="logFile",
                     help="The file to log to",
                     required=True)
 parser.add_argument('-outSR',
                     dest="outSR",
                     help="The output spatial reference to use",
                     default=None)
 parser.add_argument('-dateFormat',
                     dest='dateFormat',
                     help="The date format to use",
                     default="%d/%m/%Y %H:%M:%S")
 parser.add_argument('-timezone',
                     dest='timezone',
                     default="UTC",
                     help="The timezone to export to")
 args = parser.parse_args()
 workforcehelpers.initialize_logging(args.logFile)
 try:
     main(args)
 except Exception as e:
     logging.getLogger().critical("Exception detected, script exiting")
     logging.getLogger().critical(e)
     logging.getLogger().critical(traceback.format_exc().replace(
         "\n", " | "))