示例#1
0
    # Print errors returned from DHIS2
    logger.error("POST failed with error " + str(e))
    exit()
else:
    print('Values created')

print('Deleting values')
try:
    response = api.post('dataValueSets',
                        params={
                            'mergeMode': 'REPLACE',
                            'importStrategy': 'DELETE'
                        },
                        json={"dataValues": dataValueSets})
except RequestException as e:
    # Print errors returned from DHIS2
    logger.error("POST failed with error " + str(e))
    exit()
else:
    print('Values deleted')

print('Deleting DE ' + de_uid)
try:
    response = api.delete('dataElements/' + de_uid)
except RequestException as e:
    # Print errors returned from DHIS2
    logger.error("DELETE failed with error " + str(e))
    exit()
else:
    print('DE deleted')
示例#2
0
else:
    with open(credentials_file, 'r') as json_file:
        credentials = json.load(json_file)
    if instance is not None:
        api = Api(instance, credentials['dhis']['username'],
                  credentials['dhis']['password'])
    else:
        api = Api.from_auth_file(credentials_file)

for tei_uid in [
        'mtOF630AvuW', 'murTrn4YinD', 'SShni7GDoRE', 'f06rwiTeJwc',
        'ZTue9sD5ONy', 'lrg63P8mOV2', 'k1eOcQe8CnQ', 'N8kyBO5164B',
        'raXg7iD6jYT'
]:
    try:
        response = api.delete('trackedEntityInstances/' + tei_uid)
    except RequestException as e:
        logger.error(e)
        pass
    else:
        logger.info("TEI " + tei_uid + " removed")

exit(0)

setup_logger()


def main():

    logger.warning("Server source running DHIS2 version {} revision {}".format(
        api.version, api.revision))