Beispiel #1
0
import os
from datetime import datetime

from obspy_github_api import (
    check_docs_build_requested, get_pull_requests, get_commit_time)


print("Checking the open PRs if a docs build is requested and needed..")

for pr in get_pull_requests(state="open"):
    number = pr.number
    fork = pr.head.user.login
    branch = pr.head.ref
    commit = pr.head.sha

    if not check_docs_build_requested(number):
        print("PR #{} does not request a docs build.".format(number))
        continue

    time = get_commit_time(commit=commit, fork=fork)
    print("PR #{} requests a docs build, latest commit {} at {}.".format(
        number, commit, str(datetime.fromtimestamp(time))))

    filename = os.path.join("pull_request_docs", str(number))
    filename_todo = filename + ".todo"
    filename_done = filename + ".done"

    # create new stub file if it doesn't exist
    if not os.path.exists(filename):
        with open(filename, "wb") as fh:
            fh.write("{}\n{}\n".format(fork, branch).encode("UTF-8"))
Beispiel #2
0
import glob
import os
import shutil

from obspy import UTCDateTime

from obspy_github_api import get_pull_requests


DIRECTORY = "/home/obspy/htdocs/docs/pull_requests"


prs = get_pull_requests(state="closed", sort="updated", direction="desc")

now = UTCDateTime()
# delete everything belonging to pull requests that have been closed for more
# than two weeks
time_threshold = now - 14 * 24 * 3600
# any files older than this will be deleted no matter what
time_threshold_hard = (now - 365 * 24 * 3600).timestamp


def delete(path):
    try:
        if os.path.isfile(file_):
            os.remove(file_)
        elif os.path.isdir(file_):
            shutil.rmtree(file_)
    except Exception as e:
        print("Failed to remove '{}' ({}).".format(file_, str(e)))
import os
from datetime import datetime

from obspy_github_api import check_docs_build_requested, get_pull_requests, get_commit_time


prs = get_pull_requests(state="open")
pr_numbers = [x[0] for x in prs]
print("Checking the following open PRs if a docs build is requested and " "needed: {}".format(str(pr_numbers)))

for pr in prs:
    number = pr.number
    fork = pr.head.user.login
    branch = pr.head.ref
    commit = pr.head.sha

    if not check_docs_build_requested(number):
        continue

    time = get_commit_time(commit=commit, fork=fork)
    print(
        "PR #{} requests a docs build, latest commit {} at {}.".format(
            number, commit, str(datetime.fromtimestamp(time))
        )
    )

    filename = os.path.join("pull_request_docs", str(number))
    filename_todo = filename + ".todo"
    filename_done = filename + ".done"

    # create new stub file if it doesn't exist
import os
from datetime import datetime

from obspy_github_api import (
    check_docs_build_requested, get_pull_requests, get_commit_time)


print("Checking the open PRs if a docs build is requested and needed..")

for pr in get_pull_requests(state="open"):
    number = pr.number
    fork = pr.head.user.login
    branch = pr.head.ref
    commit = pr.head.sha

    if not check_docs_build_requested(number):
        print("PR #{} does not request a docs build.".format(number))
        continue

    time = get_commit_time(commit=commit, fork=fork)
    print("PR #{} requests a docs build, latest commit {} at {}.".format(
        number, commit, str(datetime.fromtimestamp(time))))

    filename = os.path.join("pull_request_docs", str(number))
    filename_todo = filename + ".todo"
    filename_done = filename + ".done"

    # create new stub file if it doesn't exist
    if not os.path.exists(filename):
        with open(filename, "wb") as fh:
            fh.write("{}\n{}\n".format(fork, branch).encode("UTF-8"))