From 5dd44f6e20d22f1ffcf14da459a1a6f660366474 Mon Sep 17 00:00:00 2001 From: Stepahn Preeker Date: Mon, 31 May 2021 14:25:55 +0200 Subject: [PATCH 1/2] python 3 fix --- cir.py | 34 ++++++++++++++++++++++++---------- requirements.txt | 5 ++++- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/cir.py b/cir.py index 96d4ebd..3fc4adf 100644 --- a/cir.py +++ b/cir.py @@ -1,14 +1,17 @@ #!python #!/usr/bin/python +""" +CIR python example +""" import logging import random import string -import ConfigParser +import configparser import os.path import sys -from suds import MethodNotFound +# from suds import MethodNotFound from suds.client import Client from suds.wsse import Security, UsernameToken from suds.sax.element import Element @@ -20,15 +23,20 @@ MUST_UNDERSTAND = Attribute('SOAP-ENV:mustUnderstand', 'true') if not os.path.isfile('credentials.ini'): - print 'First create or request credentials at:\nhttp://www.rechtspraak.nl/Uitspraken-en-Registers/centraal-insolventieregister/Pages/Aanvraag-Autorisatie.aspx' + + msg = ('First create or request credentials at', + ':\nhttps://www.rechtspraak.nl/Uitspraken-en-Registers/centraal-insolventieregister/Pages/Aanvraag-Autorisatie.aspx' + ) + print(msg) sys.exit(-1) -Config = ConfigParser.ConfigParser() +Config = configparser.ConfigParser() Config.read("credentials.ini") USERNAME = Config.get('Login', 'Username') PASSWORD = Config.get('Login', 'Password') + def main(): logging.basicConfig(level=logging.INFO) logging.getLogger('suds.client').setLevel(logging.DEBUG) @@ -38,21 +46,25 @@ def main(): add_security(client, USERNAME, PASSWORD) add_addressing(client, WEBSERVICE_URL) - # client.service.GetLastUpdate() - # client.service.searchByDate("2014-07-14T00:00:00", "01", "Uitspraken faillissement") + # method = client.service.GetLastUpdate() + # method = client.service.searchModifiedSince("2021-05-01T00:00:00") method = get_method(client, 'GetLastUpdate') + # 2021-05-31 + # method = client.service.searchModifiedSince("2021-05-30T00:00:00") + + print(method()) - print method() def add_security(client, user, passwd): sec = Security() token = UsernameToken(user, passwd) token.setnonce() - token.setcreated() + # token.setcreated() sec.tokens.append(token) client.set_options(wsse=sec) + def add_addressing(client, webservice_url): headers = [] @@ -66,12 +78,14 @@ def add_addressing(client, webservice_url): client.set_options(soapheaders=headers) + def get_method(client, method): try: m = getattr(client.service, method) action = client.wsdl.services[0].ports[0].methods[method].soap.action action = action.replace('"', '') - except MethodNotFound: + except(Exception): + print(Exception) return None action_header = Element('Action', ns=NS_WSA).setText(action) @@ -79,6 +93,7 @@ def get_method(client, method): return m + def generate_messageid(): fmt = 'xxxxxxxx-xxxxx' resp = '' @@ -93,4 +108,3 @@ def generate_messageid(): if __name__ == '__main__': main() - diff --git a/requirements.txt b/requirements.txt index 55a2df3..a45b349 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ -suds +configparser==5.0.2 +jedi==0.18.0 +parso==0.8.2 +suds-py3==1.4.4.1 From d9ef03b8b5dfe7ac14f17e85c5d5779e807a1c59 Mon Sep 17 00:00:00 2001 From: Stepahn Preeker Date: Mon, 31 May 2021 14:30:41 +0200 Subject: [PATCH 2/2] add example --- cir.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cir.py b/cir.py index 3fc4adf..67cbeeb 100644 --- a/cir.py +++ b/cir.py @@ -48,6 +48,7 @@ def main(): # method = client.service.GetLastUpdate() # method = client.service.searchModifiedSince("2021-05-01T00:00:00") + # client.service.searchByDate("2014-07-14T00:00:00", "01", "Uitspraken faillissement") method = get_method(client, 'GetLastUpdate') # 2021-05-31