Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
fix: remove future dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
UsamaSadiq committed Sep 22, 2023
1 parent 96ecce4 commit 5b8036f
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 10 deletions.
1 change: 0 additions & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cloudflare
edx-opaque-keys==0.4.0
edx-rest-api-client==5.5.0
freezegun==0.3.8
future==0.16.0
GitPython==3.1.18
google-api-python-client==1.7.3
jenkinsapi==0.3.3
Expand Down
10 changes: 4 additions & 6 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ click==8.1.7
# edx-django-utils
click-log==0.4.0
# via -r requirements/base.in
cloudflare==2.11.7
cloudflare==2.12.4
# via -r requirements/base.in
cryptography==41.0.3
cryptography==41.0.4
# via
# pyjwt
# simple-salesforce
Expand All @@ -64,14 +64,12 @@ easydict==1.10
# via yagocd
edx-django-utils==5.7.0
# via edx-rest-api-client
edx-opaque-keys==0.4.0
edx-opaque-keys==0.4
# via -r requirements/base.in
edx-rest-api-client==5.5.0
# via -r requirements/base.in
freezegun==0.3.8
# via -r requirements/base.in
future==0.16.0
# via -r requirements/base.in
gitdb==4.0.10
# via gitpython
gitpython==3.1.18
Expand Down Expand Up @@ -219,7 +217,7 @@ stevedore==1.32.0
# via
# edx-django-utils
# edx-opaque-keys
typing-extensions==4.7.1
typing-extensions==4.8.0
# via asgiref
unicodecsv==0.14.1
# via -r requirements/base.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tomli==2.0.1
# pyproject-hooks
wheel==0.41.2
# via pip-tools
zipp==3.16.2
zipp==3.17.0
# via importlib-metadata

# The following packages are considered to be unsafe in a requirements file:
Expand Down
4 changes: 2 additions & 2 deletions requirements/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ code-annotations==1.5.0
# via edx-lint
coverage[toml]==7.3.1
# via pytest-cov
cryptography==41.0.3
cryptography==41.0.4
# via moto
ddt==1.6.0
# via -r requirements/testing.in
Expand Down Expand Up @@ -163,7 +163,7 @@ tomli==2.0.1
# pytest
tomlkit==0.12.1
# via pylint
typing-extensions==4.7.1
typing-extensions==4.8.0
# via
# astroid
# pylint
Expand Down
195 changes: 195 additions & 0 deletions tubular/scripts/update_release_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
#! /usr/bin/env python3

"""

Check warning on line 3 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L3

Added line #L3 was not covered by tests
Command-line script to create or update the release page for a specific release.
"""
from os import path
from datetime import datetime
import sys
import logging

Check warning on line 9 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L6-L9

Added lines #L6 - L9 were not covered by tests

import click
import click_log
import yaml

Check warning on line 13 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L11-L13

Added lines #L11 - L13 were not covered by tests


# Add top-level module path to sys.path before importing tubular code.
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))

Check warning on line 17 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L17

Added line #L17 was not covered by tests

from tubular.confluence_api import ReleasePage, publish_page, AMI, ReleaseStatus # pylint: disable=wrong-import-position
from tubular.github_api import ( # pylint: disable=wrong-import-position

Check warning on line 20 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L19-L20

Added lines #L19 - L20 were not covered by tests
default_expected_release_date,
)

logging.basicConfig(stream=sys.stdout, level=logging.INFO)
LOG = logging.getLogger(__name__)

Check warning on line 25 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L24-L25

Added lines #L24 - L25 were not covered by tests

EXPECTED_RELEASE_DATE = default_expected_release_date()

Check warning on line 27 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L27

Added line #L27 was not covered by tests


@click.command("create_release_page")
@click.option(

Check warning on line 31 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L30-L31

Added lines #L30 - L31 were not covered by tests
'-c', '--compare', 'ami_pairs',
help=u"A pair of paths to AMI description yaml files.",
type=(click.File(), click.File()),
multiple=True
)
@click.option(

Check warning on line 37 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L37

Added line #L37 was not covered by tests
'--confluence-url',
help=u"The base url of the confluence instance to publish the release page to.",
default='https://openedx.atlassian.net/wiki',
)
@click.option(

Check warning on line 42 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L42

Added line #L42 was not covered by tests
'--user',
help=u"The username of the confluence user to post as.",
required=True,
)
@click.option(

Check warning on line 47 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L47

Added line #L47 was not covered by tests
'--password',
help=u"The password for the confluence user.",
required=True,
)
@click.option(

Check warning on line 52 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L52

Added line #L52 was not covered by tests
'--parent-title',
help=u"The title of the page to publish this page as a child of.",
)
@click.option(

Check warning on line 56 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L56

Added line #L56 was not covered by tests
'--space',
help=u"The space to publish this page in.",
)
@click.option(

Check warning on line 60 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L60

Added line #L60 was not covered by tests
'--title',
help=(
u"The title of this page. May contain the formatting value {timestamp} "
u"to insert the time of publishing into the wiki title. May also include `/` "
u"characters, which will create hierarchy pages that just display children."
),
)
@click.option(

Check warning on line 68 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L68

Added line #L68 was not covered by tests
'--github-token',
help=u"The token to use when accessing the github api.",
required=True,
)
@click.option(

Check warning on line 73 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L73

Added line #L73 was not covered by tests
'--jira-url',
help=u"The base url for the JIRA instance to link JIRA tickets to.",
default='https://openedx.atlassian.net'
)
@click.option(

Check warning on line 78 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L78

Added line #L78 was not covered by tests
'--gocd-url',
help=u"The url of the GoCD pipeline that build this release.",
)
@click.option(

Check warning on line 82 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L82

Added line #L82 was not covered by tests
'--status',
help=u"The current status of this deployment",
required=True,
type=click.Choice(ReleaseStatus.__members__.keys()), # pylint: disable=no-member
)
@click.option(

Check warning on line 88 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L88

Added line #L88 was not covered by tests
'--out-file',
help=u"File location to export metadata that can be used to update this page.",
type=click.File(mode='w'),
default=sys.stdout,
)
@click.option(

Check warning on line 94 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L94

Added line #L94 was not covered by tests
'--in-file',
help=u"File location to import metadata from to specify a page to update.",
type=click.File(),
)
@click_log.simple_verbosity_option(default=u'INFO')
def create_release_page(

Check warning on line 100 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L99-L100

Added lines #L99 - L100 were not covered by tests
ami_pairs, confluence_url, user, password, parent_title,
space, title, github_token, jira_url, gocd_url, status,
out_file, in_file
):
"""
Create a new release page for edxapp.
"""
if in_file and any([parent_title, space, title]):
raise click.BadOptionUsage(

Check warning on line 109 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L108-L109

Added lines #L108 - L109 were not covered by tests
"in_file",
"Either --in-file or --parent-title/--space/--title must be specified, but not both."
)

if in_file:
in_data = yaml.safe_load(in_file)
parent_title = in_data['parent_title']
space = in_data['space']
title = in_data['title']

Check warning on line 118 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L114-L118

Added lines #L114 - L118 were not covered by tests

if title is None:
title = "{:%Y-%m-%d} Release".format(EXPECTED_RELEASE_DATE)

Check warning on line 121 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L120-L121

Added lines #L120 - L121 were not covered by tests

# This allows titles of the form "{timestamp:%Y-%m-%d} Release" and the like
# to format in the current timestamp
title = title.format(timestamp=datetime.now())

Check warning on line 125 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L125

Added line #L125 was not covered by tests

folders = title.split('/')[:-1]
title = title.split('/')[-1]

Check warning on line 128 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L127-L128

Added lines #L127 - L128 were not covered by tests

if space is None:
space = 'RELEASES'

Check warning on line 131 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L130-L131

Added lines #L130 - L131 were not covered by tests

if parent_title is None:
parent_title = 'LMS/Studio Release Pages'

Check warning on line 134 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L133-L134

Added lines #L133 - L134 were not covered by tests

ami_pairs = [

Check warning on line 136 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L136

Added line #L136 was not covered by tests
(
AMI(**yaml.safe_load(old)),
AMI(**yaml.safe_load(new))
)
for old, new in ami_pairs
]

page = ReleasePage(

Check warning on line 144 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L144

Added line #L144 was not covered by tests
github_token,
jira_url,
getattr(ReleaseStatus, status),
ami_pairs,
gocd_url=gocd_url,
)

parent_id = None
parent_title_root = parent_title
for folder in folders:
result = publish_page(

Check warning on line 155 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L152-L155

Added lines #L152 - L155 were not covered by tests
confluence_url,
user,
password,
space,
folder,
"""
<ac:structured-macro
ac:name="children"
ac:schema-version="2"
data-layout="default"
ac:macro-id="f71dd203-0b29-4ece-bfaa-9f9e3106267d"
/>
""",
parent_title=parent_title,
parent_id=parent_id
)
parent_title = None
parent_id = result[u'id']

Check warning on line 173 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L172-L173

Added lines #L172 - L173 were not covered by tests

publish_page(

Check warning on line 175 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L175

Added line #L175 was not covered by tests
confluence_url,
user,
password,
space,
title,
page.format(),
parent_title=parent_title,
parent_id=parent_id
)

yaml.safe_dump({

Check warning on line 186 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L186

Added line #L186 was not covered by tests
'parent_title': parent_title_root,
'space': space,
'title': title
}, stream=out_file)


if __name__ == "__main__":

Check warning on line 193 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L193

Added line #L193 was not covered by tests
# pylint: disable=no-value-for-parameter
create_release_page()

Check warning on line 195 in tubular/scripts/update_release_page.py

View check run for this annotation

Codecov / codecov/patch

tubular/scripts/update_release_page.py#L195

Added line #L195 was not covered by tests

0 comments on commit 5b8036f

Please sign in to comment.