-
-
Save PmasonFF/80601eadf23b6b1dde1ddf6f465c1edb to your computer and use it in GitHub Desktop.
Print workflow stats for an organisation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Requires panoptes-client and (on Python 2) futures. | |
pip install panoptes-client futures | |
""" | |
import sys | |
import panoptes_client | |
from panoptes_client import Panoptes, Organization | |
ORG_ID = 16 | |
Panoptes.connect( | |
username=u'', | |
password=u'', | |
) | |
print(u"{:<8}{:<28}{:<28}{:<10}{}".format( | |
'ID', | |
'Created date', | |
'Finished date', | |
'Subjects', | |
'Workflow name', | |
)) | |
for project in Organization(ORG_ID).links.projects: | |
try: | |
print(u"{}".format(project.display_name)) | |
for workflow in project.links.workflows: | |
finished_at = workflow.finished_at | |
if finished_at is None: | |
finished_at = '' | |
print(u"{:<8}{:<28}{:<28}{:<10}{}".format( | |
workflow.id, | |
workflow.created_at, | |
finished_at, | |
workflow.subjects_count, | |
workflow.display_name, | |
)) | |
except panoptes_client.panoptes.PanoptesAPIException: | |
print(sys.exc_info()[1]) | |
# ________________________________________________________ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added error handling - private projects will result in "project not found" unless the credentials entered in lines 13, 14 allow collaborator or owner access to the project in question.