Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python-Redmine on a project without issues

I have a Redmine project that is a container for subprojects. This top level project does not have issues (Issue tracking is not enabled in the project settings).

I am trying to figure out a way for the Python api to detect this. Right now, when my code (which is scanning for issue counts) is going through the projects, it gets to this one and errors out.

redminelib.exceptions.ForbiddenError: Requested resource is forbidden

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What project property can I use to determine if the Issues are enabled? I tried project.issues._total_count but that always seems to evaluate to "None" for all projects (even ones with issues). I think that gets filled in later when you run an issue query. But I cannot run an issue query without failing and exiting the script.

I just want to have some logic to skip over these Issue disabled projects.

redmine = Redmine('https://redmine.server/redmine', key='1234567890987654321', requests={'verify': False})

projects = redmine.project.all()

for project in projects:
    issues = redmine.issue.filter(project_id=project.identifier, status_id='*')
    issueCount = 0
    for issue in issues:
        issueCount = issueCount + 1
    print( 'Project ' + project.identifier + ' has ' + str(issueCount) + ' issues' )

>Solution :

How about

try:
    # code assuming issues are enabled
except redminelib.exceptions.ForbiddenError:
    # code to execute for projects where issues are disabled
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading