Esempio n. 1
0
                        event=ERROR_XML_PARSING,
                        extra=e.message,
                    )
                if pk:
                    ok, message, data = put_org(pk, internal_org_id,
                                                org_as_dict, user_cred)
                    log(message, data)
                    print message.format(**data)
                else:
                    ok, message, data = post_org(internal_org_id, org_as_dict,
                                                 user_cred)
                    log(message, data)
                    print message.format(**data)
                if ok:
                    message, data = post_internal_id(user_cred, RAIN_ORG_ID,
                                                     internal_org_id,
                                                     data['pk'])
                    log(message, data)
                    print message.format(**data)


if __name__ == '__main__':
    django.setup()
    upload_organisations(sys.argv)
    log_file = init_log(RAIN_ORG_CSV_FILE)
    names = (u'pk', u'name', u'iati_org_id', u'internal_org_id', u'event',
             u'extra')
    print_log(log_file, names)

STATIC_ROOT = "/var/akvo/rsr/static/"
STATIC_URL = "/static/"
                            'participating-org[@akvo:ref="0"]',
                            namespaces={
                                'akvo': 'http://akvo.org/iati-activities'
                            }):
                        dupe_rain.getparent().remove(dupe_rain)
                    if rsr_id:
                        ok, message, data = put_an_activity(
                            activity.tree, rsr_id, user)
                        log(message, data)
                        print message.format(**data)
                    else:
                        ok, message, data = post_an_activity(
                            activity.tree, user)
                        log(message, data)
                        print message.format(**data)
                else:
                    message = "Iati-activity {iati_id} has no participating-orgs, aborting"
                    data = dict(
                        iati_id=iati_id,
                        event=ERROR_NO_ORGS,
                    )
                    log(message, data)
                    print(message.format(**data))


if __name__ == '__main__':
    upload_activities(sys.argv)
    log_file = init_log(RAIN_ACTIVITIES_CSV_FILE)
    names = (u'iati_id', u'pk', u'event', u'extra')
    print_log(log_file, names)
Esempio n. 3
0
        try:
            project_saver = ProjectSaver(activity, self.importing_org)
        except Project.DoesNotExist, e:
            log(
                "Couldn't find project ID: {rsr_id} IATI ID: {iati_id} internal ID: {internal_id}",
                dict(
                    internal_id=activity.internal_id(),
                    rsr_id=activity.rsr_id(),
                    iati_id=activity.iati_id(),
                    event=ERROR_PROJECT_NOT_FOUND,
                ))
            return None
        project_saver.process()
        return project_saver.project

    # def _process_publishing_status(self, activity, project):
    #     publishing_saver = PublishingSaver(activity, project)
    #     publishing_saver.save()


if __name__ == '__main__':
    django.setup()
    log_file = init_log(RAIN_POST_PROCESS_CSV_FILE)
    importer = PostImporter(RAIN_ORG_ID)
    importer.setup()
    importer.run()
    #logging.debug("Post import done.")
    names = (u'internal_id', u'rsr_id', u'iati_id', u'event', u'extra')
    print
    print_log(log_file, names)
                        message = "Error identifying RSR project: ID {pk}, IATI ID: {iati_id}, Error message: \n{extra}"
                        data = dict(pk=rsr_id, iati_id=iati_id, event=ERROR_IDENTIFY_RSR_PROJECT, extra=e.message)
                        log(message, data)
                        print message.format(**data)
                        continue
                    # HACK! removing duplicates of RAIN as participating-org
                    for dupe_rain in activity.tree.xpath(
                        'participating-org[@akvo:ref="0"]', namespaces={"akvo": "http://akvo.org/iati-activities"}
                    ):
                        dupe_rain.getparent().remove(dupe_rain)
                    if rsr_id:
                        ok, message, data = put_an_activity(activity.tree, rsr_id, user)
                        log(message, data)
                        print message.format(**data)
                    else:
                        ok, message, data = post_an_activity(activity.tree, user)
                        log(message, data)
                        print message.format(**data)
                else:
                    message = "Iati-activity {iati_id} has no participating-orgs, aborting"
                    data = dict(iati_id=iati_id, event=ERROR_NO_ORGS)
                    log(message, data)
                    print (message.format(**data))


if __name__ == "__main__":
    upload_activities(sys.argv)
    log_file = init_log(RAIN_ACTIVITIES_CSV_FILE)
    names = (u"iati_id", u"pk", u"event", u"extra")
    print_log(log_file, names)
Esempio n. 5
0
            project_saver = ProjectSaver(activity, self.importing_org)
        except Project.DoesNotExist, e:
            log(
               "Couldn't find project ID: {rsr_id} IATI ID: {iati_id} internal ID: {internal_id}",
               dict(
                   internal_id=activity.internal_id(),
                   rsr_id=activity.rsr_id(),
                   iati_id=activity.iati_id(),
                   event=ERROR_PROJECT_NOT_FOUND,
               )
            )
            return None
        project_saver.process()
        return project_saver.project

    # def _process_publishing_status(self, activity, project):
    #     publishing_saver = PublishingSaver(activity, project)
    #     publishing_saver.save()


if __name__ == '__main__':
    django.setup()
    log_file = init_log(RAIN_POST_PROCESS_CSV_FILE)
    importer = PostImporter(RAIN_ORG_ID)
    importer.setup()
    importer.run()
    #logging.debug("Post import done.")
    names = (u'internal_id', u'rsr_id', u'iati_id', u'event', u'extra')
    print
    print_log(log_file, names)
Esempio n. 6
0
                    message = "Error converting organisation XML to json. Error message: {extra}"
                    data = dict(
                        pk=org_id,
                        name=name,
                        iati_org_id=iati_org_id,
                        internal_org_id=internal_org_id,
                        event=ERROR_XML_PARSING,
                        extra=e.message,
                    )
                if pk:
                    ok, message, data = put_org(pk, internal_org_id, org_as_dict, user_cred)
                    log(message, data)
                    print message.format(**data)
                else:
                    ok, message, data = post_org(internal_org_id, org_as_dict, user_cred)
                    log(message, data)
                    print message.format(**data)
                if ok:
                    message, data = post_internal_id(user_cred, RAIN_ORG_ID, internal_org_id, data['pk'])
                    log(message, data)
                    print message.format(**data)

if __name__ == '__main__':
    django.setup()
    upload_organisations(sys.argv)
    log_file = init_log(RAIN_ORG_CSV_FILE)
    names = (u'pk', u'name', u'iati_org_id', u'internal_org_id', u'event', u'extra')
    print_log(log_file, names)

STATIC_ROOT = "/var/akvo/rsr/static/"
STATIC_URL = "/static/"