From 9420d9f5492f54a041e5a52abeaf58bc51b6d5d9 Mon Sep 17 00:00:00 2001 From: davrodgon Date: Thu, 13 Aug 2020 10:25:32 +0200 Subject: [PATCH 1/5] Added pygithub Dockerfile --- python/pygithub/Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 python/pygithub/Dockerfile diff --git a/python/pygithub/Dockerfile b/python/pygithub/Dockerfile new file mode 100644 index 0000000..eef814c --- /dev/null +++ b/python/pygithub/Dockerfile @@ -0,0 +1,11 @@ +FROM indigodatacloud/ci-images:python + + +RUN pip install pygithub + +# Standard SSH port +EXPOSE 22 + +# Default command +CMD ["/usr/sbin/sshd", "-D"] + From dae3618e7c71ec7cea200b9e7b94c2b2e1cceddf Mon Sep 17 00:00:00 2001 From: davrodgon Date: Thu, 13 Aug 2020 13:21:37 +0200 Subject: [PATCH 2/5] Added script --- python/pygithub/Dockerfile | 7 +++++-- python/pygithub/getRepoLicense.py | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 python/pygithub/getRepoLicense.py diff --git a/python/pygithub/Dockerfile b/python/pygithub/Dockerfile index eef814c..5ac6d7d 100644 --- a/python/pygithub/Dockerfile +++ b/python/pygithub/Dockerfile @@ -1,11 +1,14 @@ FROM indigodatacloud/ci-images:python +LABEL maintainer="davrodgon@users.noreply.github.com" -RUN pip install pygithub +RUN pip install PyGithub + +COPY getRepoLicense.py /usr/local/bin/getRepoLicense.py +RUN chmod +x /usr/local/bin/getRepoLicense.py # Standard SSH port EXPOSE 22 # Default command CMD ["/usr/sbin/sshd", "-D"] - diff --git a/python/pygithub/getRepoLicense.py b/python/pygithub/getRepoLicense.py new file mode 100644 index 0000000..4863826 --- /dev/null +++ b/python/pygithub/getRepoLicense.py @@ -0,0 +1,8 @@ +#!/usr/bin/python +from github import Github +import sys + +g = Github() +repo = g.get_repo(sys.argv[1]) +license = repo.get_license() +print("Found license for repository %s: %s" %(repo.name,license.license)) From 7fa005f0ae1fdbf9cbe4c95697e444f9ae157e97 Mon Sep 17 00:00:00 2001 From: davrodgon Date: Wed, 19 Aug 2020 12:13:01 +0200 Subject: [PATCH 3/5] Added python scripts --- python/pygithub/checkCitable.py | 22 ++++++++++++++++++++++ python/pygithub/checkLicense.py | 16 ++++++++++++++++ python/pygithub/getRepoLicense.py | 3 +++ 3 files changed, 41 insertions(+) create mode 100644 python/pygithub/checkCitable.py create mode 100644 python/pygithub/checkLicense.py diff --git a/python/pygithub/checkCitable.py b/python/pygithub/checkCitable.py new file mode 100644 index 0000000..fc3b81b --- /dev/null +++ b/python/pygithub/checkCitable.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +from github import Github +from github import GithubException +import sys + +def isPathInRepository(repo,path): + try: + repo.get_contents(path) + print(f"Found {path} in repository") + return True + except GithubException: + print(f"{path} not found in repository") + return False + +g = Github() +# In case an access token is needed +#g = Github("access_token") +repo = g.get_repo(sys.argv[1]) + +assert(isPathInRepository(repo,"CITATION.json") or isPathInRepository(repo,"codemeta.json")) + + diff --git a/python/pygithub/checkLicense.py b/python/pygithub/checkLicense.py new file mode 100644 index 0000000..0447b88 --- /dev/null +++ b/python/pygithub/checkLicense.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +from github import Github +from github import GithubException +import sys + +g = Github() +# In case an access token is needed +#g = Github("access_token") + +repo = g.get_repo(sys.argv[1]) +try: + license = repo.get_license() + print("Found license for repository %s: %s" %(repo.name,license.license)) +except GithubException: + print("License not found in repository") + diff --git a/python/pygithub/getRepoLicense.py b/python/pygithub/getRepoLicense.py index 4863826..a5e9bc0 100644 --- a/python/pygithub/getRepoLicense.py +++ b/python/pygithub/getRepoLicense.py @@ -3,6 +3,9 @@ import sys g = Github() +# In case an access token is needed +#g = Github("access_token") + repo = g.get_repo(sys.argv[1]) license = repo.get_license() print("Found license for repository %s: %s" %(repo.name,license.license)) From 7c97374655e27458f5bdfdcaea51d6157ff8bba3 Mon Sep 17 00:00:00 2001 From: davrodgon Date: Thu, 20 Aug 2020 12:27:15 +0200 Subject: [PATCH 4/5] Added python scripts --- python/pygithub/Dockerfile | 4 ++-- python/pygithub/checkCitable.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python/pygithub/Dockerfile b/python/pygithub/Dockerfile index 5ac6d7d..c859308 100644 --- a/python/pygithub/Dockerfile +++ b/python/pygithub/Dockerfile @@ -4,8 +4,8 @@ LABEL maintainer="davrodgon@users.noreply.github.com" RUN pip install PyGithub -COPY getRepoLicense.py /usr/local/bin/getRepoLicense.py -RUN chmod +x /usr/local/bin/getRepoLicense.py +COPY *.py /usr/local/bin/ +RUN chmod +x /usr/local/bin/*.py # Standard SSH port EXPOSE 22 diff --git a/python/pygithub/checkCitable.py b/python/pygithub/checkCitable.py index fc3b81b..52dccdc 100644 --- a/python/pygithub/checkCitable.py +++ b/python/pygithub/checkCitable.py @@ -6,10 +6,10 @@ def isPathInRepository(repo,path): try: repo.get_contents(path) - print(f"Found {path} in repository") + print("Found %s in repository %s"%(path,repo.name)) return True except GithubException: - print(f"{path} not found in repository") + print("%s not found in repository %s"%(path,repo.name)) return False g = Github() From b2673c6deed0d03127126335258c0aa6fa2fbb98 Mon Sep 17 00:00:00 2001 From: davrodgon Date: Mon, 24 Aug 2020 10:18:33 +0200 Subject: [PATCH 5/5] removed file --- python/pygithub/getRepoLicense.py | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 python/pygithub/getRepoLicense.py diff --git a/python/pygithub/getRepoLicense.py b/python/pygithub/getRepoLicense.py deleted file mode 100644 index a5e9bc0..0000000 --- a/python/pygithub/getRepoLicense.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/python -from github import Github -import sys - -g = Github() -# In case an access token is needed -#g = Github("access_token") - -repo = g.get_repo(sys.argv[1]) -license = repo.get_license() -print("Found license for repository %s: %s" %(repo.name,license.license))